You are on page 1of 4

EXPERIMENT NO: 2

August 2015

Date:7th

AUTOMATIC STREET

LIGHT
AIM: To design and implement an automatic street light using an 89552 microcontroller.
THEORY: The circuit can be implemented both automatically and manually. Automatic
operation needs no manual operation for switching ON and OFF. When there is a need of
light it automatically switches ON. When darkness rises to a certain level then sensor
circuit gets activated and switches ON and when there is other source of light i.e.
daytime, the street light gets OFF.
LM311: The LM311 series is a monolithic, low input current voltage comparator. The
device is also designed to operate from dual or single supply voltage.

AT89S52: The AT89S52 is a low-power, high-performance CMOS 8-bit microcontroller


with 8K bytes of in-system programmable Flash memory. The on-chip Flash allows the
program memory to be reprogrammed in-system or by a conventional nonvolatile
memory programmer. By combining a versatile 8-bit CPU with in-system programmable
Flash on a monolithic chip, the Atmel AT89S52 is a powerful microcontroller which
provides a highly-flexible and cost-effective solution to many embedded control
applications.

SYSTEM REQUIREMENTS:
1) Street light should have two modes. A) Auto B) Manual. Mode selection may be
done using a master switch.
2) In manual mode, street light should be turned ON and OFF irrespective of ambient
light conditions.
3) In auto mode, street light should automatically turn ON and OFF according to the
ambient light conditions irrespective of manual switch position.

BLOCK DIAGRAM:
Ambient
light
sensing
mechanis

MICROCONTROL
LER

Bulb
Control
ler

SWITCHE

COMPONENTS REQUIRED:
1)
2)
3)
4)
5)
6)
7)

AT89S52
Resistors
LDR
LED
Comparators
Switches
Relay

WORKING PRINCIPLE:
Two switches S1 and S2 are present in which S2 is the master switch. When S2 is
open, the system is in the automatic condition. So irrespective of the users choice,
the circuit works in accordance with the abundance of light which is detected using
an LDR and then fed to the comparator. It is programmed in such a way that in the

presence of light, LED is turned off and else, it is turned on. Now, when the switch S2
is closed, it is in the manual mode. With switch S1 now open, the LED is manually OFF
and with switch S2 closed, it is manually ON.

PROGRAMME IN C
#include<at89x52>
void main()
{
int P1=0x07;
while (1)
{
if ((P1&0x01)==0x01)
{
if((P1&0x04)==0x00)
{
P1=P1&0xF7;
}
else
{
P1=P1|0X08;
}}
else
{
If((P1&0X02)==0X02)
{
P1==1&0XF7;
}
else
{
P1=p1|0x08;
}}}}}

ASSEMBLY CODE:
ORG 00H
MOV A,#0x07H
MOV P1,A
HERE:
MOV A,P1
ANL A,#0x01
CJNE A,#0x01,MANUAL
ANL A,#0x04
CJNE A,#0x00,GLOW1
CLR P1.3
SJMP HERE
GLOW1:
SETB P1.3
SJMP HERE
MANUAL:
ANL A,#0x02
CJNE A,#0x02,GLOW2
CLR P1.3
SJMP HERE

GLOW2:
SETB P1.3
SJMP HERE
THERE: SJMP THERE
END

PROCEDURE:

The circuit was designed and drawn as per the given specifications.
The c language and assembly language programs were typed in and compiled in
Keil Vision 2.0.
The C code was flashed in to .
Circuitry to check the working of comparator IC LM311 was assembled and tested
to be found working.
Other hardware components which include LED, microcontroller AT89S52 and
switches were assembled on a breadboard.
The working of the circuit was verified with the logic required to design the
system.
Above steps were repeated by flashing the ASM codes also.

OBSERVATION:
S2
S1
LIGHT
CONDITION

OPEN
OPEN/CLOSE
AUTOMATIC
TRANSITION

CLOSE
OPEN
OFF

CLOSE
CLOSE
ON

Outputs were observed as per our desired results. When the switch S2 is open, the LED lit
irrespective of manual switching and depending on availability of light. When S2 is closed
and S1 kept open, LED was OFF and with S2 closed and S1 closed, LED was ON.

RESULT: An automatic street light was set up which would work under both automatic
and manual conditions. The experiment was conducted and verified.

You might also like