Buzzer Alarm Using LDR and Arduino
by abhirooprobotics in Circuits > Arduino
27349 Views, 19 Favorites, 0 Comments
Buzzer Alarm Using LDR and Arduino
![2014-08-30 23.jpg](/proxy/?url=https://content.instructables.com/F41/FLHF/HZH6V5WM/F41FLHFHZH6V5WM.jpg&filename=2014-08-30 23.jpg)
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!
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
Wiring
![dgfdg.jpg](/proxy/?url=https://content.instructables.com/FNX/YQUX/HZH6V5X1/FNXYQUXHZH6V5X1.jpg&filename=dgfdg.jpg)
![FP9NMC3HYWT4U4R.LARGE.jpg](/proxy/?url=https://content.instructables.com/FD0/5GM9/HZH6V6TN/FD05GM9HZH6V6TN.jpg&filename=FP9NMC3HYWT4U4R.LARGE.jpg)
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!
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);
}
FINISHED!
Upload The Code And BOOM! There You Go!
You Just Made Your LDR Buzzer Without Any Hassles!
Congrats!