Traffic Light
This application uses red, green and yellow LEDs to simulate a crossroads
traffic light function. Initially R1 and G2 are illuminated. After a delay the
green light flashes followed by the yellow light. After another delay R2 and
G1 are illuminated. This cycle will continue in this way indefinitely in the
same way as the traffic lights at a traffic crossroad intersection. Within the
application the different time durations for the red and green light as well
as the flashing time can be programmed.
Circuit design
The circuit uses the two port sections PA0~PA2 and PA4~PA6 with each one
representing a set of traffic lights on each road at a crossroad intersection.
The operation of the circuit will be self explanatory from the contents of the
program. See the circuit diagram for more details of the hardware.
Program
#include ht48c10.inc
;------------------------------------------------------------
data .section ’data’
;== data section ==
count1 db ?
;delay loop counter 1
count2 db ?
;delay loop counter 2
count3 db ?
;delay loop counter 3
flash
db ?
;light flash register
rglight db ?
;light register
;------------------------------------------------------------
code .section at 0 ’code’
;== program section ==
org
00H
;
jmp
start
;
org
04h
;external interrupt subroutine
reti
;for safeguard
HT-IDE User’s Guide
188
Summary of Contents for HT-IDE
Page 11: ...P a r t I Integrated Development Environment Part I Integrated Development Environment 1 ...
Page 12: ...HT IDE User s Guide 2 ...
Page 20: ...Fig 1 6 Fig 1 7 HT IDE User s Guide 10 ...
Page 24: ...HT IDE User s Guide 14 ...
Page 70: ...HT IDE User s Guide 60 ...
Page 76: ...HT IDE User s Guide 66 ...
Page 92: ...HT IDE User s Guide 82 ...
Page 93: ...P a r t I I Development Language and Tools Part II Development Language and Tools 83 ...
Page 94: ...HT IDE User s Guide 84 ...
Page 148: ...HT IDE User s Guide 138 ...
Page 150: ...Fig 12 1 Fig 12 2 HT IDE User s Guide 140 ...
Page 154: ...HT IDE User s Guide 144 ...
Page 192: ...HT IDE User s Guide 182 ...
Page 194: ...HT IDE User s Guide 184 ...
Page 218: ...HT IDE User s Guide 208 ...
Page 235: ...P a r t V Appendix Part V Appendix 225 ...
Page 236: ...HT IDE User s Guide 226 ...
Page 250: ...HT IDE User s Guide 240 ...