loading

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!

<p>Is it possible that I can hook up a flashing light. If so what code should i use</p>
<p>Will it work with a 10k ohm or a 330ohm resistor?</p>
<p>Yes, the difference is how sensitive is gonna be the LDR</p>
<p>can it work for a 220 ohm resistor</p>
<p>Great Work !!! Very Simple and easy . If implemented can save you a lot of money for day/night control of light or heat. Thank you</p>
<p>Cool! You did a nice job explaining your process. Thanks for saying!</p>

About This Instructable

18,716views

17favorites

License:

More by abhirooprobotics:Arduino Temperature and Humidity on 7 Segment Display Mains Hum Detector / Static Electricity Detector Arduino Temperature and Humidity Display With 7-Segment Display  
Add instructable to: