Arduino Clapswitch LAMP

2,756

40

1

Introduction: Arduino Clapswitch LAMP

PLEASE VOTE! ME IF YOU LIKE IT

Hi, this is my new Arduino clap switch lamp. This works as a Night-Light or even as an Emergency Lamp. It is powered by a 9v adapter. This lamp is very useful in our daily life and easy transportation. Double clap to turn on and again double clap to turn off. Though It runs with a single led it gives more light. You can also replace the single led with strips.

Step 1: ​YOU WILL NEED:

1.a plastic cylindrical box(optional)

2. a brighter led

3.a 9v adapter or an usb cable or battery

4.arduino board

5.mic

6.some jumper cables

Step 2: Attach the Arduino and the Mic Into the Box As Shown

Step 3: Now Attach the Led to the Cap With Tape or Glue

Step 4: Wiring

1.connect the +ve end of the led to the digital-pin 8.

2.connect the -ve end of the led to the gnd.

3.connect the vcc of the MIC to 3.3v.

4.connect the gnd of the MIC to the gnd.

5.connect the OUT of the MIC to the digital-pin 10.

Step 5: CODE

copy,paste on the ide..........

int clap = 0;
long detection_range_start = 0;

long detect_range = 0;

boolean light_state = false;

void setup(){

pinMode(2, INPUT); //mic

pinMode(8, OUTPUT); //led }

void loop(){

if(digitalRead(2) == 0){

if(clap == 0){

detection_range_start = detect_range = millis();

clap++;

}

else if(clap > 0 && millis() - detect_range >= 49){

detect_range =millis();

clap++;

} }

if(millis() - detection_range_start>= 399){

if(clap== 2){

if(!light_state){

light_state = true;

digitalWrite(8, HIGH);

}else if(light_state){

light_state = false;

digitalWrite(8, LOW); } }

clap = 0; } }

Step 6: You Are Done.

Arduino Contest 2016

Participated in the
Arduino Contest 2016

First Time Authors Contest 2016

Participated in the
First Time Authors Contest 2016

Be the First to Share

    Recommendations

    • Electronics Contest

      Electronics Contest
    • Stick It Challenge

      Stick It Challenge
    • Make It Modular: Student Design Challenge

      Make It Modular: Student Design Challenge

    Comments

    0
    RishiR28
    RishiR28

    5 years ago

    Very nice,neat andd perfect.You are the best