About This Project
Meet The MakersJoin Team
.Automatic light that turns on upon darkness / Sun set
.using arduino mega 2560
The Mega 2560 is a microcontroller board based on the ATmega2560. It has 54 digital input/output pins (of which 15 can be used as PWM outputs), 16 analog inputs, 4 UARTs (hardware serial ports), a 16 MHz crystal oscillator, a USB connection, a power jack, an ICSP header, and a reset button. It contains everything needed to support the microcontroller; simply connect it to a computer with a USB cable or power it with a AC-to-DC adapter or battery to get started.
In this project, light dependent resistor (LDR) will be used to sense the day light and mega 2560 will be programmed to operate a relay. This relay will turn on and off the light as it will act as a switch. The decision will be made on values obtained from the LDR.
Relay module will be used to obtain a digital signal from the mega 2560 and turn on/ off power of the lamp. Given below picture shows the relay module.
On the input side of relay module, there are three terminals. As from figure, one is 5 volts supply (red cable), second one is ground (black cable) and third one is signal terminal (brown cable). You can use your own cable, I have just changed colors to identify the signals.
.Attaching lamp and mega 2560 to relay module
From the above picture we can make connection of relay module. Steps of making connection to relay module can be described as;
1. On the output side of relay module, we will connect one wire coming from lamp to the normally open (NO marked on module) terminal and common terminal will be connected to AC main line (220Volts or 110Volts as per your country supply voltages) using wire.
2. Second wire of the lamp is also connected to the AC main line to complete the circuit.
After completing both steps circuit will be look like following picture;
Power to the relay module (i.e. 5 volts and ground) is provided directly from the mega 2560 board and digital signal terminal is connected to the port 13 of the board.
Note: Port 06 of mega 2560 will operate relay module.
.Building Light dependent resistor Circuit
LDR have very high resistance in the absence of light. Usually they have near 1 megaOhm resistance in darkness. As light falls on the LDR, it resistance starts decreasing. On a fully shiny surface of LDR, it resistance can drop upto 100 Ohm. Thus, it is placed with 10 kilo Ohm resistor in series with LDR to prepare a light sensing circuit as shown in given below figure.
Note: Connect the analog input from this circuit to A0 pin on the mega 2560 board.
Once you connect the analog input to the mega 2560, you can write code to make the circuit behave in right direction. I have used bread board to demonstrate circuit. However, for outdoor mounting of circuit it is recommended that PCB must designed or proper enclosure must be placed around circuit with a window for daylight to fall on LDR.
The LDR circuit with it's cable obtained for sensing value is shown in given below figure.
A more close-up picture is shown below.
This green cable is connected to analog input of the board. In this project it is connected to the pin A0. This is shown in following picture.
The complete circuit in OFF state is shown below.
.SummaryThere are two signal cables in the circuit.
1. Connected between resistor and LDR which is shown as green cable in above diagram. This wire will be connected from sensor to the pin A0 (analog input) of the board.
2. Connected to the relay module PIN (IN). Pin 6 of the board is connected to the IN marked pin on the relay module to drive the relay.
Other four cables are just power to circuit. Two cables are obtained from 5 volts of board and other two are connected as ground to the circuit.
The schematic is shown in given below picture.
A video of working of project is as follows.
Last updated on 08/19/2016
|Qty||Item||Where to Find||Est. Cost||More Info|
Arduino Mega 2560
Item #: Mega 2560
Single Channel Relay
Item #: SRD-S-124D
Light Dependent Resistor (LDR)