Pages

Thursday, March 10, 2011

Traffic Light Control Using 8051/AT89C2051

Microcontroller has the function of a very broad one, this time I will use a microcontroller as a controller of a traffic light or traffic light,

Taking advantage of the AT89C2051 2 ports we've been able to control the traffic light with 4 intersection / crossroad.

Below is a scheme of the circuit:

To view please click on the image size

Circuit requires 5V voltage that has been regulated, in this project the light used is a LED light. if you want to use the lamp 220V or higher voltage you will need the Relay Board as a liaison microcontroller with lights.
To Relay Board I will publish at a later post.

Source Code series:

NR EQU P3.5
NY EQU P3.4
NG EQU P3.3

SR EQU P1.2
SY EQU P1.3
SG EQU P1.4

ER EQU P1.5
EY EQU P1.6
EG EQU P1.7

WR EQU P3.7
WY EQU P1.0
WG EQU P1.1

CSEG AT 0; RESET VECTOR
;---------==========----------==========---------= ========---------
; Interrupt PROCESSOR AND RESET VECTORS
;---------==========----------==========---------= ========---------

Taking advantage of the AT89C2051 2 ports we've been able to control the traffic light with 4 intersection / crossroad.

Below is a scheme of the circuit:
ORG 00H ; Reset
JMP MAIN
;---------==========----------==========---------=========---------
MAIN:
MOV SP,#40H
MOV P1,#0FFH
MOV P3,#0FFH

TOP: CLR NR
CLR SR
CLR ER
CLR WY
SETB WG
CALL Y_DELAY
SETB NR
CLR NY
CLR WR
SETB WY
CALL Y_DELAY
SETB NY
CLR NG
CALL DELAY

CLR NY
SETB NG
CALL Y_DELAY
CLR NR
SETB NY
SETB SR
CLR SY
CALL Y_DELAY
SETB SY
CLR SG
CALL DELAY

CLR SY
SETB SG
CALL Y_DELAY
CLR SR
SETB SY
SETB ER
CLR EY
CALL Y_DELAY
SETB EY
CLR EG
CALL DELAY

CLR EY
SETB EG
CALL Y_DELAY
CLR ER
SETB EY
SETB WR
CLR WY
CALL Y_DELAY
SETB WY
CLR WG
CALL DELAY
AJMP TOP



;**********************************************************
DELAY:
MOV R3,#3FH
REPA3: MOV R1,#0FFH
REPA2: MOV R2,#0FFH
REPA1: NOP
DJNZ R2,REPA1
DJNZ R1,REPA2
DJNZ R3,REPA3
RET
; ---------==========----------==========---------=========---------
Y_DELAY:
MOV R3,#1AH
RQPA3: MOV R1,#0FFH
RQPA2: MOV R2,#0FFH
RQPA1: NOP
DJNZ R2,RQPA1
DJNZ R1,RQPA2
DJNZ R3,RQPA3
RET
;**********************************************************
END

No comments:

Post a Comment