Arduino Based Automatic AC Bulb Triggered in Dark
by Utsource in Circuits > Arduino
803 Views, 0 Favorites, 0 Comments
Arduino Based Automatic AC Bulb Triggered in Dark
In this project, we will see a simple circuit where an Arduino UNO will control a 5V relay, which will light up in dark and to Sense the darkness we will use LDR to sensor to sense the darkness to trigger the bulb.
Things You Need
For this instructables we will need following things :
ARDUINO UNO
5V Relay Module
LDR
10K potentiometer
Lamp / AC bulb
Wires for connecting DC Voltage components
Wires for connecting AC Mains and lamp
Schmatics
Coming to the design of the circuit, it is very simple as we used a 5V relay module and not the individual components. Although the circuit diagram explains the detailed connections, practically we didn’t need to make all the connections.
Most relay modules (whether 5V or 12V) will come with the aforementioned connection and hence all you need is to give power supply to the relay module i.e. 5V and GND and connect the control signal from Arduino to control pin on the relay board.
Coming to the load part i.e. the lamp, hot wire from the mains supply is connected to one terminal of the lamp. Other terminal of the lamp is connected to Normally Open (NO) contact of the 5V Relay. Finally, the neutral wire from the mains is connected to the Common (COMM) contact of the relay.
A small light sensor in the form of LDR (Light Dependent Resistor) is used to switch on or off the light automatically. The output of the LDR sensor is given to the Analog Input pin A0.
Code
Please copy the following code and upload it to the arduino Board :
const int relay=8;
const int Ainput=A0;
int ldrValue = 0;
int range = 0;
void setup()
{
pinMode(relay,OUTPUT);
digitalWrite(relay,HIGH); // My Relay is an active LOW Relay.
Serial.begin(9600);
}
void loop()
{
ldrValue = analogRead(Ainput);
range = map(ldrValue, 0, 1023, 0, 255);
Serial.println(range);
if(range>125)
digitalWrite(relay,LOW);
else
digitalWrite(relay,HIGH);
}
view raw5V_