In this tutorial, we’ll build a simple light alarm system using an Arduino Uno and a 3-pin LDR sensor module. This system detects when someone blocks a light source—like breaking a beam—and triggers an LED alert, simulating a basic laser tripwire.
![]() |
Light Alarm System |
๐ What Is an LDR Sensor?
An LDR (Light Dependent Resistor) is a sensor that changes its resistance based on the amount of light it receives. In brighter light, resistance drops; in darkness, resistance increases. By using the analogRead() function, we can detect the intensity of ambient light.
๐ฆ What You’ll Need
To get started, you will need the following components:
![]() |
Components required for this tutorial |
✅ Arduino UNO × 1
✅ 3-pin LDR Module × 1
✅ Jumper Wires × 1
✅ USB cable for Arduino × 1
✅ Resistor 220ฮฉ × 1
✅ Breadboard × 1
๐ ️ Circuit Wiring
Here’s how to connect each component to the Arduino:
![]() |
3-pin LDR module wiring |
3-pin LDR Module
LED and Resistor
✅ LED Anode (long leg) → Digital pin 9 on Arduino
✅ LED Cathode (short leg) → 220ฮฉ resistor → GND on Arduino
![]() |
The connection between components and Arduino |
๐ป Uploading the Code
After wiring everything up, connect the Arduino to your computer using a USB cable. Then, upload the following code, or you can download the code HERE.
int ldrPin = A0; int ledPin = 9; int baselineLight = 800; // Adjust based on your lighting void setup() { pinMode(ledPin, OUTPUT); Serial.begin(9600); } void loop() { int ldrValue = analogRead(ldrPin); Serial.println(ldrValue); if (ldrValue < baselineLight - 200) { // Sudden drop in light digitalWrite(ledPin, HIGH); // Alert } else { digitalWrite(ledPin, LOW); } delay(100); }
![]() |
Open Arduino IDE and copy-paste the code |
The system reads the LDR sensor using analogRead(ldrPin) (range: 0–1023), compares it to the baselineLight value representing normal ambient light, and if the light level drops significantly—by more than 200 units—the LED is activated to indicate an alert.
๐งช Test the System
Once you've uploaded the code and completed the wiring, it's time to test how the system reacts to different light levels:
![]() |
Place your hand over the sensor, and the LED will turn ON. |
![]() |
Remove your hand, and once the light returns to normal, the LED will turn OFF |
๐ Conclusion
This project is a simple and fun way to get started with analog sensors, security concepts, and Arduino programming. You’ve now created a basic light alarm system that responds to interruptions in a light beam—just like a basic tripwire!
๐ฆ Where to Buy
Shopee:
Lazada:
Aliexpress:
๐ฅ Watch the Full Video Tutorial
๐ If you found this guide helpful, share it with fellow makers! For more tutorials, subscribe to our YouTube channel and follow us on social media. ๐
#Arduino #LDR #Tripwire #SecurityAlarm #ElectronicsProject #DIYAlarm #ArduinoBeginner #arduinouno
No comments:
Post a Comment