Basically and LDR picks up a laser and activates an LED and buzzer. I want my sound instead of the buzzer.
The circuit in action can be seen on youtube and instructables under 2 minute laser target:
Code: Select all
int ldrPin = A4; // the cell and 10K pulldown are connected to a0
int sirenPin = 11; //pin 3 selected!!
int ledPin = A0;
long ldrValue1, ldrValue2;
void setup(void) {
pinMode (sirenPin,OUTPUT); // set the siren pin as output
pinMode (ledPin,OUTPUT); // set the siren pin as output
pinMode (ldrPin,INPUT); // set the siren pin as output
//Serial.begin(9600);
}
void loop(void) {
ldrValue1 = analogRead(ldrPin);
delay(10);
ldrValue2 = analogRead(ldrPin);
if (ldrValue1-ldrValue2 > 20||ldrValue2-ldrValue1 > 20){
digitalWrite(sirenPin,HIGH);
digitalWrite(ledPin,HIGH);
delay(1000);
}
else{