Creating LDR Sensor program using Arduino UNO
Required Components
- LED -1 no
- LDR -1 no
- Resistor 10K Ω -1 no
- Resistor 220 Ω -1 no
- Bread board -1 no
- Arduino UNO board -1 no
- Connecting cables -1 set
Circuit
Steps
- Make sure the components are working properly.
- Connect the Arduino UNO A0 pin to the LDR.
- Connect the Arduino UNO 13th pin to the LED.
- Connect the Arduino Uno 5V, GND to the LDR Sensor using jumper wires.
- Check the Arduino program.
- Check the circuit connections.
- Run the Arduino program.
Arduino Program
const int ledPin=13;
const int ldrPin=A0;
void setup( )
{
Serial.begin(9600);
pinMode (ledPin,OUTPUT);
pinMode (ldrPin,INPUT);
}
void loop( )
{
int ldrstatus = analogRead(ldrPin);
if (ldrstatus<=300)
{
digitalWrite(ledPin,HIGH);
Serial.print("LDR in Dark,LED is ON");
}
else
{
digitalWrite(ledPin,LOW);
Serial.print ("LDR in Light,LED Is Off");
}
}
Usage
- Alarm clocks
- Street lights
- Light intensity meters
- Burglar alarm circuits
Projects
- Shooting game