Automatic Night Lamp Using Arduino
Automatic Night Lamp Using Arduino
PHYSICS LAB -1
BTECH CSE – 1ST SEMESTER
Components Required :
1. Arduino – microcontroller
2. Relay 5 Volts
3. LDR (Light Dependent Resistor)
4. 10K Ohms
5. Transistor BC547
6. DC Supply 9volts
Software Required :
1.Arduino IDE
2.Proteus
Relay
9 is an electromagnetic switch which can be operated electrically and
made to turn on and off AC/DC appliances. It can be controlled even
with a low voltage of 5 volts like the output provided by the Arduino
pins.
LDR
LDR (Light Dependent Resistor) is a variable resistance component
that can vary its resistance value with the change in intensity of light
and it works on the photoconductivity principle. The value of
resistance decreases with increase in the intensity of light. It is used
in light-sensitive detector circuits and light activated switching
circuits.
Transistor
A transistor is basically a semiconductor device which is employed to
amplify or switch electronic signals and power. It is made up of
semiconductor material and has 3 terminals to connect with an
external circuit.
A small value of current at its base terminal controls a large value of
current at its emitter and collector terminals. A fixed dc voltage is
required at transistor terminals to operate in the desired region of its
characteristic curves. Transistor, when used for amplification
purpose, is kept biased so that it is partly on for all inputs and the
amplified output signal is taken at the emitter. For switching
applications, the transistor is biased so that it remains fully ON if
signal at base terminal is present and it gets completely OFF in the
absence of base signal.
Software Description
Proteus
Proteus design suite comes under the category of proprietary
software which is employed to perform electronic design
automation. This software is very handy for the electronic design
engineers and respective technicians for the purpose of creating
schematics and the prints in electronic form termed as PCB layout.
The software was developed in Yorkshire, England by Labcenter
Electronics Ltd. and comes with multi-language support which are
English, French, Spanish and Mandarin.
Arduino IDE
Arduino IDE is a software that can be used on various platforms.
Hence, it’s a cross-platform application and was developed using the
programming language java. It has a soul purpose of writing the
sketch and uploading it on Arduino compatible boards. The
supported languages are C and C++ which are a bit modified and
depends upon the library being used.
Code in Arduino :
void setup()
{
Serial.begin(9600);
}
void loop()
{
//only change value of the sesitivty "nothing else"....
int sensitivity = 80;
Code explanation :
In void setup , it talks about basic structure setup.
Serial.begin(9600)-sets the baud rate for serial data communication.
In void loop
Sensitivity- we set sensitivity of the photo resistor to detect the
change in luminous conditions
Here we apply “if else” conditions for comparison. Initially it is set to
a analog value of 80.
Then if the value is more than 80 means the light is on and if the
value is less then the room is dark
Sensor value = analogRead(A0)
It tells the jumper wire of the photo resistor is connected to analog
pin “A0”
DigitalWrite is just a kind of function which has High value for just
turn on and low for turn off and 13 tells the pin no. Of Arduino which
supplies signals for it.
Delay (100 mili second) tells there will be a delay after a continuous
on situation to off conditions
Serial.println(sensorValue) prints the analog signal on the serial
monitor
Nigh Lamp Circuit Working
The working of the circuit, here we have used a 9V DC supply
(Arduino’s 9V) and connected a 10k ohm resistor and an LDR. The
voltage which can be taken across the resistor or the LDR and fed
into the analog pin of the Arduino, pin A3 in this case.
With the help of the code mentioned above, the board will be able to
detect the analog input provided to it. This value read is in
accordance with the intensity of the light which is detected by the
LDR.
While we can check the coming value on the serial monitor to
calibrate the circuit according to the intensity of the light. Hence we
can change the condition in the conditional statement provided in
the code to turn the lamp “ON” & “OFF” at a desired intensity of
light, hence making it dynamic.
Now when the conditional statement is satisfied i.e. the light
intensity falls down below the value provided by you (in ADC
equivalent form) the board will generate a” HIGH” output at the pin
12 By “HIGH” it is meant that it produces 9V output as pin 12.
In this case a sufficient voltage is developed at the base of the
transistor and the transistor starts conducting. As a result, the
current starts flowing in the coils of the relay and it switches on
which means the NO terminal is switched to an active state to which
the lamp circuit has been connected to and upon the completion of
the circuit the lamp turns “ON”.
The lamp turns “OFF” when the else condition in the code becomes
true i.e. the intensity of light increases from the threshold value
provided given by us. Hence, output at pin 12 becomes “LOW” and
subsequently relay is turned OFF which turn the Lamp OFF.