Guys, In this project we are going to detect something when it crosses the laser beam. If something or somebody crosses the laser beam fixed here it will gives a sound .This is a useful and simple project. Okey,let's make it.
Components Required
1. | Arduino UNO | * 1 |
2. | LDR(5 Mohm) | * 1 |
3. | Laser Module | * 1 |
4. | Resistor(220 Ohm) | * 1 |
5. | Resistor(10K Ohm) | * 1 |
6. | Bread Board | * 1 |
7. | Buzzer | * 1 |
8. | Jumper Wires | * 1 |
Circuit Diagram
Program
const int ledPin = 13;
const int buzzerPin = 12;
const int ldrPin = A0;
const int laserPin = 7;
void setup () {
Serial.begin(9600);
pinMode(ledPin, OUTPUT);
pinMode(buzzerPin, OUTPUT);
pinMode(ldrPin, INPUT);
pinMode( laserPin , OUTPUT);
digitalWrite( laserPin , HIGH);
}
void loop() {
int ldrStatus = analogRead(ldrPin);
if (ldrStatus > 1) {
tone(buzzerPin, 100);
digitalWrite(ledPin, HIGH);
delay(100);
noTone(buzzerPin);
digitalWrite(ledPin, LOW);
delay(100);
Serial.println(" ALARM ACTIVATED ");
}
else {
noTone(buzzerPin);
digitalWrite(ledPin, LOW);
Serial.println("ALARM DEACTIVATED");
}
Serial.println( ldrStatus );
//delay(10);
}