Buzzer Alarm Using LDR and Arduino

24,144

18

6

Hello Guyz

I Wanted To Build A LDR Buzzer And Got Many Instructables Which Were Using Transistors To Do This Project.

So I Bulid This Project With The Help Of Arduino Which Many People Have.

Just Follow The Steps And You'll Get Your LDR Buzzer Ready Within 5 Minutes!

Step 1: REQUIREMENTS

So,For Making This Project You Need A Couple Of Things Which Are Described Below:-

1. 1 X Arduino (UNO/MEGA/NANO)

2. 1 X Piezzo Buzzer

3. 1 X 470k Resistor

4. 1 X Breadboard

5. 1 X LDR

6. Some Wires

Step 2: Wiring

Just Follow The Fritzing Diagram And Do The Wiring As Described In The Image!

You Will Get Your LDR Buzzer Circuit Ready In A Couple Of Minutes!

Step 3: CODE

Here's The Code Which You Have To Upload To Your Arduino :-

int rcvpin=A0;
int buzzpin=9;

void setup()

{

pinMode(rcvpin,INPUT);

pinMode(buzzpin,OUTPUT);

buzz(200);

buzz(200);

buzz(200);

delay(2000);

Serial.begin(9600);

}

void loop()

{

int ldrval=analogRead(rcvpin);

Serial.println(ldrval);

if(ldrval>=900)

{

buzz(50);

}

}

void buzz(unsigned char time)

{

analogWrite(buzzpin,170);

delay(time);

analogWrite(buzzpin,0);

delay(time);

}

Step 4: FINISHED!

Upload The Code And BOOM! There You Go!

You Just Made Your LDR Buzzer Without Any Hassles!

Congrats!

Share

Recommendations

  • Warm and Fuzzy Contest

    Warm and Fuzzy Contest
  • Epilog X Contest

    Epilog X Contest
  • Toys Contest

    Toys Contest

6 Discussions

0
None
mrivas6

5 months ago

thank you

0
None
Respecttheboss47

2 years ago

Is it possible that I can hook up a flashing light. If so what code should i use

0
None
johnstallone1

2 years ago

can it work for a 220 ohm resistor