Learning Arduino for beginners EP#25 laser trip wire alarm

In this episode we will take a look at how you can use a laser with a LDR to make a simple laser trip wire burglar alarm…

 

 

SCHEMATIC:

Parts List:

ARDUINO

Laser

LDR

MOSFET

resistor

 

 

ARDUINO Code:

 

void setup() {
Serial.begin(9600); //start serial

}

void loop() {
int light=(analogRead(A3)); //read photo eye
Serial.println(light); //print light value 4 testing
delay(10); //delay for stability
if (light<600) //check if beam broken
{
for (int x = 0; x < 25; x++) //set alarm duration
{
tone(3,400,100); //set tone to be played
delay(200);
}
}
}

Advertisements