INTRODUCTION TO PROGRAMMING AND PHYSICAL COMPUTING

Faculty : Bernat Morato I Assistant : Daniil Koshelyuk

PROJECT ABSTRACT

Clapper! develops a smart sound based system for turning on/off a LED lamp. Using Arduino as the base, a code is programmed to embedded the capacity of sensing (inputs) and acting (outputs). The develop computing demonstrates to be suitable for extra comfort when needed in the house.  The concept is based on “The Clapper , Clap On! Clap Off!” and next will show how to be replicate it using Arduino.

COMPONENTS

  1. Arduino Uno
  2. Breadboard
  3. Jumper Wires
  4. USB Cable
  5. LM393 Sound Sensor Module
  6. 5V Relay Module
  7. LED Lamp

The sound sensor module was required as it detects sound and the intensity of it, using a microphone that provides an amplifier and generates an output signal voltage.

The 5V Relay Module was also necessary as is a programmable electrical switch, used to control on/off devices in this case the LED Lamp.

Arduino components

WORKFLOW DIAGRAM

  •       Input:
  1. The sound detector sensor module for Arduino determines whether or not sound has crossed a predefined threshold value. Threshold value : 260
  2. A sample count of sound is measured to get the average noise of the environment. Sample Count: 10
  3. A margin of sound intensity is establish for the Arduino to know when to react. Margin: 3
  •       Output:
  1. If the margin sound meets the conditions the Relay acts to the LED light : ON/OFF

CODE

int SoundSensor=A0;
int SoundSensorDigital = 2;
int LED=3;
boolean LEDStatus=false;
int lastSensorData=0;
int threshold = 260;
int sampleCount = 10;
int margin = 3;
int sampleDelay = 50;
void setup() {
pinMode(SoundSensor,INPUT);
pinMode(SoundSensorDigital, INPUT);
pinMode(LED,OUTPUT);
Serial.begin(9600); //initialize serial
threshold =0;
for(int i = 0; i <sampleCount; i++){
threshold += analogRead(SoundSensor);
}
threshold /= sampleCount;
threshold+= margin;
Serial.print(“Base thresholde: “);
Serial.println(threshold);//print the value
Serial.println();
}
void loop() {
int SensorData=analogRead(SoundSensor);
int SensorDataDigital=digitalRead(SoundSensorDigital);
Serial.print(SensorData);//print the value
// Serial.print(“,”);
// Serial.print(SensorDataDigital);//print the value
Serial.println();
if((SensorData>threshold) && (lastSensorData <threshold)){
Serial.print(“Triggered”);
Serial.println(SensorData);//print the value
if(LEDStatus==false){
LEDStatus=true;
digitalWrite(LED,HIGH);
}
else if(LEDStatus==true){
LEDStatus=false;
digitalWrite(LED,LOW);
delay(1000);
}}
lastSensorData = SensorData;
delay(sampleDelay);
}

PHOTO DOCUMENTATION

VIDEO SAMPLE

 

For more information visit : arduino.cc

Clapper! is a project of IAAC, Institute for Advanced Architecture of Catalonia at Master in Advanced Architecture in 2021/2022

Student: Oscar A. Cortés Landa

Faculty: Bernat Morato & Daniil Koshelyuk