Arduino light clapper project

To make this light, you’ll need:

Male to Female jump-leads to connect the bread-board to the audio board/relay Male to Male jump-leads to link between the breadboard tracks.
Arduino Compatible Board (though I may soon use an Arduino Pro Micro for its size)
Analogue/Digital sound board to detect analogue sound levels
Relay switch to switch on and off the lights
Breadboard to link everything up
Electrical Tape so we don’t kill ourselves while testing the system.
Heat-Shrink/Wrap for electrical safety and to make the project safe to use after testing.
Desk lamp which I was able to pick up for £5 from Wilkinsons.

I’ll post schematics at some point soon, however the 5V out of the arduino should go to the red positive long track on the breadboard, and GND should go to the negative track. From there, everything with VCC (the relay, and sound board) should connect to the positive 5V track, and GND should to go the negative track. You should then take the A0 pin from the sound board and wire that to one of the Arduinos analogue pins- I chose A0. Equally, for the relay, you should select one of the relay pins and connect that to the Arduinos digital pins, I chose D2.

From there, you should splice the lamp, and wire it up to the relay, using electrical tape while testing that it all works, and then apply the heat-shrink to the wiring once the project works. Word of warning: the underside pins of the relay are connected to the live wires. I had the joy of connecting the two pins with my little finger.


From there, you should be good to load up the program:

int analogPin = A1;
int val = 0;

int relay = 2;
unsigned long startTime;
boolean light = false;
boolean finish = false;

void setup()
  pinMode(2, OUTPUT); 

void loop()
  val = analogRead(analogPin);
  //  Serial.println(val); // Good for seeing what values work for you!
  if (val > 64){ // 64 was a reasonable clap for me!
    startTime = millis();
    while (((unsigned long)(millis() - startTime) <= 1000)){ // While one second has not yet gone by, check for the second clap.
      val = analogRead(analogPin); // Get new values for val

      if (val >= 62){

        if (light == false){
          digitalWrite(relay, HIGH);
          light = true;
        } else {
          digitalWrite(relay, LOW);
          light = false;
      } else {
        Serial.print("loop ");
        Serial.print(millis() - startTime);
        Serial.print(" - ");


And if everything works, and you’re still alive or haven’t yet set the house on fire, you should have something which resembles the following: