;LEDs are connected to GPIO 2,4 & 5
list p=12C508
include <P12C508.inc>
__CONFIG _WDT_OFF &_IntRC_OSC
cblock 0x007
d1
d2
Count ;loop counter
LCount ;longer counter
endc
org 0
movlw b'11001110'
option
Start
; Green will flash for 1/2 the time (Advance Green for Turning)
movlw .6
movwf LCount
clrf Count ;Reset Count
RlGr call Red1 ;Red left
btfss LCount, 2
goto NoFlash
btfsc Count, 6
call Green2 ;Green on
btfss Count, 6
call LEDoff ;All LEDs off
goto Done1
NoFlash call Green2
Done1 decfsz Count
goto RlGr ;Wait
decfsz LCount
goto RlGr
movlw .150
movwf Count ;Loop count
RlAr call Red1 ;Red left
call Amber2 ;Green right
decfsz Count
goto $-3 ;Wait
movlw .150
movwf Count ;Loop count
RR call Red1 ;Red left
call Red2 ;Green right
decfsz Count
goto $-3 ;Wait
movlw .6
movwf LCount
clrf Count ;Reset Count
RrGl call Red2 ;Red left
btfss LCount, 2
goto N_Flash
btfsc Count, 6
call Green1 ;Green on
btfss Count, 6
call LEDoff ;All LEDs off
goto Done2
N_Flash call Green1
Done2 decfsz Count
goto RrGl ;Wait
decfsz LCount
goto RrGl
movlw .150
movwf Count ;Loop count
RrAl call Red2 ;Red right
call Amber1 ;Green left
decfsz Count
goto $-3
;Red Red
movlw .150
movwf Count ;Loop count
call Red1 ;Red left
call Red2 ;Green right
decfsz Count
goto $-3 ;Wait
goto Start
Red1 movlw b'11011011' ;RED left
tris GPIO
movlw b'00100000'
movwf GPIO
goto R80ms
Red2 movlw b'11001111' ;RED left
tris GPIO
movlw b'00100000'
movwf GPIO
goto R80ms
Amber1 movlw b'11101011' ;Amber left
tris GPIO
movlw b'00010000'
movwf GPIO
goto R80ms
Amber2 movlw b'11101011' ;Amber right
tris GPIO
movlw b'00000100'
movwf GPIO
goto R80ms
Green1 movlw b'11011011' ;Green left
tris GPIO
movlw b'00000100'
movwf GPIO
goto R80ms
Green2 movlw b'11001111' ;Green right
tris GPIO
movlw b'00010000'
movwf GPIO
goto R80ms
LEDoff movlw b'11111111' ;No LEDs
tris GPIO
nop ;Timing
nop
goto R80ms
R80ms movlw 0x57 ;refresh loop 2x40ms
movwf d1
movlw 0x03
movwf d2
Delay_0
decfsz d1, f
goto $+2
decfsz d2, f
goto Delay_0
retlw 0
end