0% found this document useful (0 votes)
31 views

Automatic Traffic-Light Control: P0.0 P0.1 P0.2 P0.3 P0.4 P0.5 P0.6 P0.7 P2.3 P2.2 P2.1 P2.0

This document describes an automatic traffic light controller project using a microcontroller. It uses LEDs connected to ports on the microcontroller to represent traffic lights. The controller cycles through the lights in a specific sequence, with reds lights on for 10 seconds, yellow for 5 seconds, then the next light turns green and the cycle repeats infinitely. The microcontroller uses internal timers to generate delays between light changes.

Uploaded by

sanchit2418
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
31 views

Automatic Traffic-Light Control: P0.0 P0.1 P0.2 P0.3 P0.4 P0.5 P0.6 P0.7 P2.3 P2.2 P2.1 P2.0

This document describes an automatic traffic light controller project using a microcontroller. It uses LEDs connected to ports on the microcontroller to represent traffic lights. The controller cycles through the lights in a specific sequence, with reds lights on for 10 seconds, yellow for 5 seconds, then the next light turns green and the cycle repeats infinitely. The microcontroller uses internal timers to generate delays between light changes.

Uploaded by

sanchit2418
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

AUTOMATIC TRAFFIC-LIGHT CONTROL

The project we have chosen for the microcontroller lab is of an automatic traffic light controller. The approach we have used is quite simple. We would be handling the lights one by one. The delay is provided by the internal timer of 8051 microcontroller. In this example we have used timer 1 in mode 1. Now let us have a look at the color of LEDs attached to various ports.

P0.0 P0.1 P0.2 P0.3 P0.4 P0.5 P0.6 P0.7 P2.3 P2.2 P2.1 P2.0

RED YELLOW GREEN RED YELLOW GREEN RED YELLOW GREEN RED YELLOW GREEN

The device works in accordance with the following algorithm: 1. All the red lights are on. 2. Switch off one red light and turn on the corresponding green light. This is done for 10 seconds. 3. Switch off the green light and turn on the corresponding yellow light. This is done for 5 seconds. 4. Switch off the yellow light and once again turn on the red light. 5. Repeat these steps for all the 4 red lights in a cyclic manner. 6. Keep on following these steps for infinite number of times.

On the next page we have shown the code that we have written for this purpose.

PROGRAM
ORG 00H MOV P0,#OFFH MOV P2,#0FFH CPL P0.0 CPL P0.3 CPL P0.6 CPL P2.2 LCALL DELAY HERE: CPL P0.0 CPL P0.2 LCALL DELAY LCALL DELAY CPL P0.2 CPL P0.1 LCALL DELAY CPL P0.1 CPL P0.0 CPL P0.3 CPL P0.5 LCALL DELAY LCALL DELAY CPL P0.5 CPL P0.4 LCALL DELAY

CPL P0.4 CPL P0.3 CPL P0.6 CPL P2.3 LCALL DELAY LCALL DELAY CPL P2.3 CPL P0.7 LCALL DELAY CPL P0.7 CPL P0.6 CPL P2.2 CPL P2.0 LCALL DELAY LCALL DELAY CPL P2.0 CPL P2.6 LCALL DELAY CPL P2.6 CPL P2.2 LJMP HERE DELAY: MOV TMOD,#10H MOV R0,#71 J1: MOV TL1,#00H MOV TH1,#00H

SETB TR1 AGAIN: JNB TF1,AGAIN DJNZ R0,J1

The code uses the concept of the internal times to generate the delay. On the next page we have described the circuit diagram for our project. The dark lines indicate the connections made for the application whereas the light lines indicate the basic circuit. We have also provided t long lines, one on top and another on the bottom. The upper one will act as a source for +5 V and the lower one will act as ground.

You might also like