0% found this document useful (0 votes)
100 views9 pages

Simplified Traffic Lights Using 8051 Maxim DS89C4XX Embedded Controller (MDE)

This document describes a program written for a microcontroller-based traffic light system using LEDs and switches. The program controls the LEDs representing traffic lights in a sequence: green, yellow, red. It turns individual LEDs on and off, then makes them blink. The program is improved to read switch states and control the LEDs based on the switches, representing a walk button and car sensor. Finally, a subroutine is added so the traffic lights stay on as long as the corresponding switch is activated. The program aims to simplify an embedded system for traffic light control.

Uploaded by

Kiran Neog
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
100 views9 pages

Simplified Traffic Lights Using 8051 Maxim DS89C4XX Embedded Controller (MDE)

This document describes a program written for a microcontroller-based traffic light system using LEDs and switches. The program controls the LEDs representing traffic lights in a sequence: green, yellow, red. It turns individual LEDs on and off, then makes them blink. The program is improved to read switch states and control the LEDs based on the switches, representing a walk button and car sensor. Finally, a subroutine is added so the traffic lights stay on as long as the corresponding switch is activated. The program aims to simplify an embedded system for traffic light control.

Uploaded by

Kiran Neog
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

See discussions, stats, and author profiles for this publication at: https://www.researchgate.

net/publication/336020390

Simplified Traffic Lights Using 8051 Maxim DS89C4XX Embedded Controller


(MDE)

Article · September 2019

CITATIONS READS

0 149

2 authors:

Rotimi-Williams Bello Daniel A. Olubummo


University of Africa Robert Morris University
43 PUBLICATIONS   17 CITATIONS    7 PUBLICATIONS   1 CITATION   

SEE PROFILE SEE PROFILE

Some of the authors of this publication are also working on these related projects:

PhD research in vision & image processing (Detection and tracking of non-linear moving and occlusion object) View project

Computer Systems View project

All content following this page was uploaded by Rotimi-Williams Bello on 25 September 2019.

The user has requested enhancement of the downloaded file.


ISSN 2581-3463

RESEARCH ARTICLE

Simplified Traffic Lights Using 8051 Maxim DS89C4XX Embedded Controller


(MDE)
Rotimi-Williams Bello1, Daniel Adebiyi Olubummo2
1
Department of Mathematical Sciences, University of Africa, Toru-Orua, Bayelsa, Nigeria, 2Department of
Computer Science, Federal Polytechnic, Ekowe, Bayelsa, Nigeria
Received: 20-05-2019; Revised: 10-06-2019; Accepted: 20-07-2019
ABSTRACT
Traffic lights are signaling devices positioned at road intersections, pedestrian crossings, and other
locations to control flows of traffic. An actual traffic light alternates the right way of road users by
displaying lights of a standard color (red, yellow/amber, and green), using a universal color code (and
a precise sequence to enable comprehension by those who are color blind). In the typical sequence
of colored light, (1) illumination of the green light allows traffic to proceed in the direction denoted;
(2) illumination of the yellow/amber light denoting ready to proceed in the direction denoted; and
(3) illumination of the red signal prohibits any traffic from proceeding. Usually, the red light contains
some orange in its hue, and the green light contains some blue, for the benefit of people with red-green
color blindness, and green lights in many areas are in fact blue lenses on a yellow light (which together
appear green). Program was written for the MDE trainer kit to control the outputs of the microcontroller
in a given sequence. Green and red light-emitting diodes (LEDs) are connected to the microcontroller
outputs. First, the assembly language programs were written to turn on only one LED and then turn off
the same LED. Next, the program is improved by making the LED blink, and then, the input switches are
read. The walk push button and the other indicating a car at the crossing light are turned on. As switches
are mechanical objects, some debounce time (timer programmed dead time of 50 ms) is also placed in
the program. The light is controlled as long as each LED with one switch is pressed, and the LED is ON
and when the switch is not depressed, the LED is OFF. Then, the LED will be made to blink once per
second as long as the associated switch is ON. Finally, the program is improved when a subroutine is
added where the traffic light controller is on green or red stays ON while the corresponding switch is ON.
If more than one switch is activated, then the ON is for the red light. The LEDs simulate the traffic lights
and switches simulate the walk push button and the car presence sensor at a crossroad.
Key words: Traffic light, red light, green light, yellow light, light-emitting diodes, switch,
microcontroller

INTRODUCTION area and to ensure the safety of the pedestrians


crossing the roads. The method of operating
The essence of traffic lights is to avert road this gas-fuelled traffic lights involved manual
accidents which can lead to catastrophic. The operation where the controller (policeman) would
history behind the development of traffic light can have to either raise or lower the semaphore arms
be traced to the 18th century when the first gas-lit used for the operation during the daytime to signal
traffic lights earlier proposed by British railway moving vehicles to either stop or proceed. Gas-lit
engineer, J. P. Knight, were installed outside the red and green lights were used at night instead of
houses of parliament in London. This was to the semaphore arms where red signaled stoppage
control the traffic of horse carriages around the of vehicles and green signaled proceed. Red
color was used to signal stop due to its danger
Address for correspondence: and caution attributes while green was used to
Rotimi-Williams Bello, signal proceed because most cultures accepted it
E-mail: [email protected] to be more reassuring danger-free color. Different
www.ajms.com 51
Bello and Olubummo: Simplified traffic lights using embedded controller

negative incidents of light explosion were recorded


with the use of gas-lit traffic lights; this caused so
much injury to the operators and controllers of the
gas-lit traffic lights making it not completely save
to rely on.
a
The limitation of the traditional method of
controlling traffic coupled with the growth
in industrialization and automobiles which
made cities to become crowded motivated the
development of electric traffic light method of
controlling traffic. This electric traffic light was
conceived in 1912 by Lester Wire, an American
policeman to replace the gas-lit traffic lights, but
this technology lacked the yellow light, instead of b

the yellow light, it used buzzer sound to signal get Figure 1: (a) Traffic lights, (b) Traffic light control module
using sensors
ready status. The limitation found in the work of
Lester Wire motivated another policeman named
APPLICATION PROGRAM TRAFFIC
William Potts in Detroit, Michigan, to invent first
LIGHT
four-way and three-colored traffic lights that had
yellow/amber as the third color [Figure 1a]. Presented in this section is a program we wrote
The automated traffic lights were a huge success for the application simplified traffic light. The
toward the middle of the 19th century; lights application program traffic light is the foundation
were changed by themselves at a fixed interval on which the application simplified traffic lights in
though causing unnecessary queuing as the light Section 3 is based.
would be red even in the absence of traffic.
This also led to what motivated engineers and
scientists to think of a better traffic monitoring Simple traffic light program
system. Charles Adler Jr. had a brief contribution • THIS PROGRAM WILL MAKE THE
to traffic system with his invented machine
LED TURN OFF AND THEN ON. LED IS
that could detect vehicle’s honking and change
CONNECTED TO P1.1
signals accordingly, but the noise generated
1. ORG 00H
by this invention during its operation due to
THE ORG OOH TELLS THE
the unnecessary honking of vehicles, thereby
MICROCONTROLLER FROM WHERE
causing excruciating experience to passerby and
IT SHOULD START
people living around the place the machine was
mounted, this led to its ban.[1] 2. AGAIN: CLR P1.1; NOW THE BIT P1.1
Traffic lights started to become computer-aided IS LOW. THIS MEANS THAT THE LED
during the early 1960s [Figure 1b] making all the IS OFF
limitations experienced in the early inventions 3. MOV R1, #0FFH; MOVES FF HEXA I.E
perfected. Powerful software applications were 255 (DECIMAL) TO R1
designed that could predict and control the traffic 4. HERE: DJNZ R1, HERE; DECREMENTS
of congested cities. This paper contributes to R1 AND THEN CHECKS IF R1 IS ZERO
the traffic lights technology by writing program • OTHERWISE JUMPS TO HERE AND
for the MDE trainer kit to control the outputs of DECREMENTS R1
the microcontroller in a given sequence, thereby 5. SETB P1.1; SETB SETS THE P1.1 AND
simplifying traffic light. The remainder of the THE LED IS NOW TURNED ON
paper is structured as follows. In Section 2, the THE CODE BELOW IS TO ADD A LITTLE
programs involved in application simplified DELAY TO OBSERVE THE OUTPUT
traffic light are shown. Laboratory experimental 6. MOV R1, #0FFH
results and discussion of application simplified 7. HERE2: DJNZ R1, HERE2
traffic light are presented in Section 3. Section 4 • IMPROVE THE PROGRAM BY MAKING
concludes the paper. THE LED BLINK. THIS WILL MAKE

AJMS/Jul-Sep-2019/Vol 3/Issue 3 52
Bello and Olubummo: Simplified traffic lights using embedded controller

THE LED BLINK INDEFINITELY. LED IS 24. MOV P1, #0FFH; MAKES THE PORT
CONNECTED TO P1.1 1 AS INPUT PORT SO IT BEHAVE AS
8. ORG 30H; THIS ORG 30H TELLS THE INPUT
MICROCONTROLLER FROM WHERE 25. MOV P3, #00H; MOVES ALL ZEROS
IT SHOULD START TO PORT 3 MAKES THEM TO BEHAVE
9. CLR P1.1; NOW THE BIT P1.1 IS LOW. AS OUTPUTS
THIS MEANS THAT THE LED IS OFF 26. CHKSW1: JNB SW1, CHKSW2; IF
10. MOV R1, #0FFH; MOV COMMAND SWITCH 1 IS OFF P1.1 IS LOW THEN
MOVES FF HEXA I.E 255 (DECIMAL) CHECK IF SWITCH 2 IS ON
TO R1 27. CLR LED2; TO SWITCH OFF LED IF IT
11. DJNZ R1, HERE; DJNZ DECREMENTS WAS ON
R1 AND THEN CHECKS IF R1 IS ZERO 28. CPL LED1; MAKE THE LED BLINK.
OTHERWISE JUMPS TO HERE WHERE CPL IS THE COMMAND FOR
IT DECREMENTS R1 AGAIN COMPLIMENT WILL INVERT THE
12. SETB P1.1; SETB SETS THE P1.1 AND LED FROM ITS PREVIOUS STATE IF
THE LED IS NOW TURNED ON THE LED IS ON THEN NOW IT WILL
13. MOV R1, #0FFH BE OFF AND VICE VERSA
14. DJNZ R1, HERE2; DELAY TO OBSERVE 29. MOV R1, #0A0H
THE OUTPUT 30. DJNZ R1, HERE
15. JMP AGAIN; JUMPS THE PROGRAM • CALL DEADTIME; CALL A SUBROUTINE
BACK TO LINE 07 AND THE “DEADTIME.” AS THIS WILL BE USED
PROGRAM CONTINUES.IN THIS III. A COUPLE OF TIMES SO IT IS BETTER
WAY WE CAN MAKE THE LED BLINK TO MAKE SUBROUTINE RATHER THAN
16. END WRITING THE CODE AGAIN AND AGAIN
• THE NEXT PART OF THE LABORATORY 31. JMP CHKSW1; THIS CHECKS
IS TO READ THE INPUT SWITCHES, WHETHER THE SW1 IS STILL ON OR
ONE FROM THE WALK PUSH BUTTON NOT IF YES IT WIL MAKE THE LED
AND THE OTHER INDICATING A CAR BLINK
AT THE CROSSING. AS SWITCHES 32. CHKSW2: JNB SW2, CHKSW1
ARE MECHANICAL OBJECTS; SOME 33. CLR LED1; TO WITCH THE LED1 OFF
DEBOUNCE TIME (DEAD TIME) WILL IT WAS STILL ON
ALSO BE PLACED IN THE PROGRAM. 34. CPL LED2; MAKE THE LED BLINK.
EACH LED WILL BE CONTROLLED WITH CPL IS THE COMMAND FOR
ONE SWITCH; AS LONG AS THE SWITCH COMPLIMENT WILL INVERT THE
IS ACTIVE; THE RESPECTIVE LED IS ON LED FROM ITS PREVIOUS STATE IF
AND WHEN SWITCH IS INACTIVE, THE THE LED IS ON THEN NOW IT WILL
CORRESPONDING LED IS OFF. THEN, BE OFF AND VICE VERSA
THE LED WILL BE MADE TO BLINK AS 35. MOV R1, #0A0H
LONG AS SWITCH IS ON 36. DJNZ R1, HERE2
• THIS PROGRAM WILL TAKE THE INPUT 37. CALL DEADTIME; CALL A
FROM A SWITCH AND CONTROL THE SUBROUTINE “DEADTIME.” AS
LED THIS WILL BE USED A COUPLE OF
17. SW1=P1.1;SW2=P1.3; LED1=P3.1; TIMES SO IT IS BETTER TO MAKE
LED2=P3.2 SUBROUTINE RATHER THEN
18. EQU; TAKES THE INPUT AND WRITING THE CODE AGAIN AND
ASSIGNS IT A NAME AGAIN
19. SW1 EQU P1.1 38. JMP CHKSW2; THIS CHECKS
20. SW2 EQU P1.3 WHETHER THE SW2 IS STILL ON OR
21. LED1 EQU P3.1 NOT IF YES IT WIL MAKE THE LED
22. LED2 EQU P3.3 BLINK
23. ORG 00H 39. DEADTIME

AJMS/Jul-Sep-2019/Vol 3/Issue 3 53
Bello and Olubummo: Simplified traffic lights using embedded controller

40. MOV R1, #0AH; MOVES 10 HEXA TO R1 4. TF0=0;


41. MOV R2, #0FFH; MOVES FFHEXA TO R2 5. TMOD=0X01;
42. BACK: DJNZ R2, BACK; THIS IS 6. TH0=0X3C;
CALLED THE INNER LOOP IT WILL 7. TL0=0X60;
DECREMENT R2 255 TIMES BEFORE 8. TR0=1;
GOING TO THE NEXT STATEMENT 9. while(TF0==0);
43. DJNZ R1, AGAIN; THIS IS THE OUTER 10. TF0=0;
LOOP ONCE THE INNER LOOP IS 11. }
COMPLETED IT DECREMENTS BY 1. 12. void delay(unsigned int sec)
THIS MAKES THE INNER LOOP RUN 13. {
10 TIMES 14. unsigned int i,j;
44. RET; THIS COMMAND TELLS THE 15. for(i=0;i<=sec;i++)
MICROCONTROLLER TO RETURN 16. for(j=0;j<=10;j++)
TO THE LAST COMMAND 17. {
• CHECK: CHECKING INPUT OF SWITCHES. 18. timer();
45. ORG 0000H 19. }
46. MOV R0, #SW1; MOVING SWITCH1 20. }
INPUT IN R0 21. void disp(unsigned int a)
47. MOV R1, #SW2; MOVING SWITCH2 22. {
INPUT IN R1 23. int j;
48. CPL SW1 24. unsigned int i[]={0XC0,0XF9,0XA4, 0XB0,
49. CPL SW2 0X99, 0X92,0X82, 0XF8,0X80,0X98};
50. JMP RED 25. for(j=a;j>=0;j--)
51. JMP GREEN 26. {
52. JMP CHECK 27. P1=i[j];
53. GREEN 28. delay(1);
54. LOOP1 29. }
55. CLR P1.1 30. }
56. CALL DELAY 31. void main()
57. SETB P1.1 32. {
58. CALL DELAY 33. while(1)
59. JMP LOOP1 34. {
60. RED 35. P2=0x87;
61. LOOP 36. P3=0xFF;
62. CLR P1.3 37. disp(9);
63. CALL DELAY 38. P3=0x30;
64. SETB P1.3 39. disp(2);
65. CALL DELAY 40. P2=0x4b;
66. JMP LOOP 41. P3=0xFF;
67. DELAY 42. disp(9);
68. MOV R7, #100 43. P3=0x90;
69. L1_DELAY 44. disp(2);
70. DJNZ R7, L1_DELAY 45. P2=0x2D;
71. RET 46. P3=0xFF;
72. END. 47. disp(9);
48. P3=0xC0;
Simple traffic light program 49. disp(2);
50. P2=0x1E;
1. #include<reg51.h> 51. P3=0xFF;
2. void timer() 52. disp(9);
3. { 53. P3=0x60;

AJMS/Jul-Sep-2019/Vol 3/Issue 3 54
Bello and Olubummo: Simplified traffic lights using embedded controller

54. disp(2);
55. }
56. }

EXPERIMENTAL RESULTS AND


DISCUSSION
In this section, we present the application
simplified traffic light. Microprocessor and its
various electronic components used in developing
the traffic light were diagrammatically illustrated
and discussed. A light-emitting diode (LED), a
semiconductor light source was used in carrying Figure 2: Traffic light application using light-emitting diode
out the experiment [Figure 2]. The color of
the light is determined by the energy gap of
the semiconductor. When a LED is forward
biased, electrons are able to recombine with
electron holes within the device, releasing
energy in the form of photons. This effect is
called electroluminescence (EL). EL is an
optical and electrical phenomenon, in which a
material emits light in response to the passage
of an electric current or to a strong electric field.
The wavelength of the light emitted, and thus,
its color depends on the band gap energy of the
materials forming the p-n junction. The materials
used for the LED have a direct band gap with
energies corresponding to near-infrared, visible, Figure 3: A seven-segment display
or near-ultraviolet light.

Seven-segment display
A seven-segment display is an electronic display
device for displaying decimal numerals. A seven-
segment display is composed of seven elements.
Individually on or off, they can be combined to
produce simplified representations of the Arabic Figure 4: Cathode type display
numerals.
The set values and the selected time intervals are
shown on the seven-segment display [Figure 3].
There are two types of displays available. One
is common anode type display and the other is
common cathode type display. In common cathode
type display, all the cathodes of the segments are
tied together and connected to ground [Figure 4].
The supply will be given to the required segment Figure 5: Anode type display
from the decoder or driver.
In common anode type display, the anodes of Port 1 is used for the seven-segment data. The
all the segments are tied together and connected seven segments are arranged as a rectangle of two
to supply and the required segments will be vertical segments on each side with one horizontal
connected to ground from the decoder or driver segment on the top, middle, and bottom. In
[Figure 5]. addition, the seventh segment bisects the rectangle

AJMS/Jul-Sep-2019/Vol 3/Issue 3 55
Bello and Olubummo: Simplified traffic lights using embedded controller

horizontally. In a simple LED package, typically, false indication due to infrared leakage. An object
all of the cathodes (negative terminals) or all of moving nearby actually reflects the infrared rays
the anodes (positive terminals) of the segment emitted by the infrared LED.
LEDs are connected together and brought out to The infrared receiver has a sensitivity angle (lobe)
a common pin; this is referred to as a “common of 0–60°, hence, when the reflected IR ray is sensed,
cathode” or “common anode” device. Hence, a the mono in the receiver part is triggered. The
seven-segment plus decimal point package will output from the mono may be used in any desired
only require nine pins.[2-5] fashion. For example, it can be used to turn on a
A single byte can encode the full state of a
seven-segment display. The most popular bit Table 1: Hexadecimal reference for seven segments LED
encodings are gfedcba and abcdefg – both light on/off functions
usually assume 0 is off and 1 is on [Table 1]. Digit gfedcba abcdefg a b c d e f g
0 0X3F 0X7E On On On On On On Off
Figure 6 gives the hexadecimal encodings for
1 0X06 0X30 Off On On Off Off Off Off
displaying the digits 0–9.
2 0X5B 0X6D On On Off On On Off On
The timer of microcontroller is interfaced with
3 0X4F 0X79 On On On On Off Off On
seven-segment display to display the delay of
4 0X66 0X33 Off On On Off Off On On
light. The decoder enhances the capability of
5 0X6D 0X5B On Off On On Off On On
accommodation for more number of seven-
6 0X7D 0X5F On Off On On On On On
segment displays with the same number of port
7 0X07 0X70 On On On Off Off Off Off
pins. The current-limiting resistor associated with 8 0X7F 0X7F On On On On On On On
each segment limits the current at the cost of 9 0X6F 0X7B On On On On Off On On
illumination. The drop across each segment will
be 2 V approximately. The maximum current that
the segment can handle is 10 mA.
Current drawn by segment = (Supply voltage–
Drop across segment)/Resistance = (5 v–2 v)/
1k = 3 mA (1)
This proximity detector using an infrared detector
shown in Figure 5 can be used in various equipment
like alarm devices. The circuit primarily consists
of an infrared transmitter and an infrared receiver.
The transmitter section consists of a 555 timer
IC functioning in a stable mode. It is wired as
shown in Figure 7. The output from a stable is
fed to an infrared LED through resistor R4, which
limits its operating current. This circuit provides
Figure 6: A seven-segment display
a frequency output of 38 kHz at 50% duty cycle,
which is required for the infrared detector/receiver
module [Figure 8].
The receiver section comprises an infrared
receiver module, a 555 monostable multivibrator,
and an LED indicator. On reception of infrared Figure 7: Serial interrupt example
signals, 555 timer (mono) turns on and remains on
as long as infrared signals are received. When the
signals are interrupted, the mono goes off after a
few seconds (period = 1.1 R7 × C6) depending
on the value of R7–C6 combination. Thus, if
R7 = 470 kΩ and C6 = 4.7 μF, the mono period
will be around 2.5 s.[6,7]
Both the transmitter and the receiver parts can
be mounted on a single breadboard or printed
circuit board. The infrared receiver [Figure 9]
must be placed behind the infrared LED to avoid Figure 8: A proximity detector using an infrared detector

AJMS/Jul-Sep-2019/Vol 3/Issue 3 56
Bello and Olubummo: Simplified traffic lights using embedded controller

Figure 9: IR receiver circuit

Figure 10: 8051 MDE trainer board architecture descriptions

light when a person comes nearby by energizing a For example, in our LED flashing program, the
relay. The light would automatically turn off after LED was turned on for a specific length of time
sometime as the person moves away and the mono and then turned off for a specific length of time.
pulse period is over. The sensitivity of the detector We achieved this through the use of time delays.
depends on current-limiting resistor R4 in series Since the microcontroller operates at a specific
with the infrared LED. Range is approximately frequency, we could work out exactly how many
40 cm. For 20-ohm value of R4, the object at 25 cm iterations of the time delay were needed to give us
can be sensed, while for 30-ohm value of R4, the the desired delay. However, this is cumbersome
sensing range reduces by 22.5 cm. and prone to error. Moreover, there is another
disadvantage; the central processing unit (CPU) is
occupied, stepping through the loops. If we use
CONCLUSION the on-chip timers, the CPU could be off doing
something more useful while the timers take on
This article has exposed the use of microprocessor the menial task of keeping track of time.
and various electronic components used in For the control and program of the serial port of
developing an embedded system found in traffic the microcontroller in a given sequence, we left
lights. We studied the application of 8051 that as future work.
microcontroller to traffic lights. The basic 8051
has two on-chip timers [Figure 10] that can be
used for timing durations or for counting external REFERENCES
events. Interval timing allows the programmer to 1. Mazidi MA, Mazidi JG, McKinlay RD. The 8051
perform operations at specific instants in time. Microcontroller and Embedded Systems: Using

AJMS/Jul-Sep-2019/Vol 3/Issue 3 57
Bello and Olubummo: Simplified traffic lights using embedded controller

Assembly and C. Vol. 626. Upper Saddle River, NJ: Publication; 1999.


Pearson/Prentice Hall; 2006. 5. Mano MM. Digital Design. United States: EBSCO
2. Ayala KJ. The 8051 Microcontroller. San Francisco, Publishing, Inc.; 2002.
CA: Cengage Learning; 2004. 6. Deshmukh AV. Microcontrollers: Theory and
3. Singh BP, Singh R. Advanced Microprocessors and Applications. New York: Tata McGraw-Hill Education;
Microcontrollers. New Delhi: New Age International; 2005.
2008. 7. Predko M. Programming and Customizing the 8051
4. Yashwant K. Let us C. Array and Pointers. 7th ed. BPB Microcontroller. New York: McGraw-Hill, Inc.; 1999.

AJMS/Jul-Sep-2019/Vol 3/Issue 3 58
View publication stats

You might also like