Laser Beam Break alarm with Arduino, LDR and Buzzer

 



Arduino sketch for Laser Beam Break alarm

           #define LDR A0 // connect LDR to Pin A0 of Arduino #define LED 8 // connect LED to Pin 8 of Arduino #define Buzzer 7 // connect Buzzer to Pin 7 of Arduino float x; void setup() { Serial.begin(9600); pinMode (LED, OUTPUT); pinMode (Buzzer, OUTPUT); } void loop() { x = analogRead(A0); x = x / 10; Serial.print("Value"); Serial.println(x); if (x < 75) { for (int i = 0; i < 10; i++) { digitalWrite(LED, HIGH); Serial.println("ALARM"); tone(Buzzer, 1000); delay(500); tone(Buzzer, 500); delay(500); } } else { digitalWrite(LED, LOW); Serial.println("NORMAL"); noTone(Buzzer); } delay(100); }

Comments

Popular posts from this blog

4 Stage Timer With DS3231RTC Module.

Interfacing KY038 sound sensor with Raspberry pi Pico

Interfacing MQ2 Gas & Smoke Sensor With Raspberry Pi Pico