;=================================================================================
;V1.1 MULTIPLE SIGNAL CNTL UNIT 8 SIGNALS VIA 3 8BIT SHIFT REGISTERS USING A 20X2
;=================================================================================
symbol counter=w8
powerup:
read 0,b2 ;READ MEMORY ON POWER UP
if b2=1 then goto signal1
if b2=2 then goto signal2
if b2=3 then goto signal3
if b2=4 then goto signal4
if b2=41 then goto signal4A
if b2=5 then goto signal5
initalize: ;SETS THE VARIABLES TO ZERO FIRST TIME USE
b4=0
write 1,b4
b5=0
write 2,b5
b6=0
write 3,b6
start:
serin c.2, n1200_8,("ABC"),b0 ;FOR FIRST TIME USE
if b0=1 then goto signal1
if b0=2 then goto signal2
if b0=5 then goto signal4
if b0=7 then goto signal3
if b0=6 then goto signal4
if b0=8 then goto signal4A
;==============================================================================
;SIGNAL 1
;==============================================================================
SIGNAL1: ;SET SIGNAL TO GREEN
b2=1
write 0, b2 ;WRITE SIGNAL TO MEMORY
counter=0 ;SET COUNTER TO ZERO
b1 = %00100100 :gosub registers ;DATA TO SHIFT REGISTER
b1 = %10010010 :gosub registers ;DATA TO SHIFT REGISTER
b1 = %01001100 :gosub registers ;DATA TO SHIFT REGISTER
pulsout c.4,10 ;LATCH REGISTERS
Monitor1: ;MONITOR SIGNAL1'S SENSOR
readadc 1,b3 ;READ ADC1
if b3 <120 then goto red1 ;IF INPUT IS DARK THEN CHANGE THE SIGNAL TO RED
serin [1000,monitor1], c.2, n1200_8,("ABC"),b0
if b0=1 then goto signal1
if b0=2 then goto signal2
if b0=5 then goto signal4
if b0=6 then goto signal4
if b0=7 then goto signal3
if b0=8 then goto signal4A
if b0=9 then goto vd1
if b0=10 then goto vd2
if b0=13 then goto vd3
if b0=14 then goto vd4
red1:
pause 800
b1 = %00100100 :gosub registers ;DATA TO SHIFT REGISTER
b1 = %10010010 :gosub registers ;DATA TO SHIFT REGISTER
b1 = %01001001 :gosub registers ;DATA TO SHIFT REGISTER
pulsout c.4,10 ;LATCH REGISTERS
counter=0
red11:
counter=counter+1
if counter=20 then goto yellow1
readadc 1,b3 ;MONITOR SENSOR FOR INPUT
if b3 <120 then goto red1
serin [1000,red11], c.2, n1200_8,("ABC"),b0
if b0=1 then goto signal1
if b0=2 then goto signal2
if b0=5 then goto signal4
if b0=6 then goto signal4
if b0=7 then goto signal3
if b0=8 then goto signal4A
if b0=9 then goto vd1
if b0=10 then goto vd2
if b0=13 then goto vd3
if b0=14 then goto vd4
yellow1:
b1 = %00100100 :gosub registers ;DATA TO SHIFT REGISTER
b1 = %10010010 :gosub registers ;DATA TO SHIFT REGISTER
b1 = %01001010 :gosub registers ;DATA TO SHIFT REGISTER
pulsout c.4,10 ;LATCH REGISTERS
counter=0
yellow11:
readadc 1,b3 ;READ ADC1
if b3 <120 then goto red1
counter=counter+1
if counter=15 then goto signal1
serin [1000,yellow11], c.2, n1200_8,("ABC"),b0
if b0=1 then goto signal1
if b0=2 then goto signal2
if b0=5 then goto signal4
if b0=6 then goto signal4
if b0=7 then goto signal3
if b0=8 then goto signal4A
if b0=9 then goto vd1
if b0=10 then goto vd2
if b0=13 then goto vd3
if b0=14 then goto vd4
;==============================================================================
;SIGNAL 2
;==============================================================================
SIGNAL2:
b2=2
write 0, b2
counter=0
b1 = %00100100 :gosub registers
b1 = %10010010 :gosub registers
b1 = %01100001 :gosub registers
pulsout c.4,10
Monitor2:
readadc 2,b3
if b3 <120 then goto red2
serin [1000,monitor2], c.2, n1200_8,("ABC"),b0
if b0=1 then goto signal1
if b0=2 then goto signal2
if b0=5 then goto signal4
if b0=6 then goto signal4
if b0=7 then goto signal3
if b0=8 then goto signal4A
if b0=9 then goto vd1
if b0=10 then goto vd2
if b0=13 then goto vd3
if b0=14 then goto vd4
red2:
pause 800
b1 = %00100100 :gosub registers
b1 = %10010010 :gosub registers
b1 = %01001001 :gosub registers
pulsout c.4,10
counter=0
red21:
counter=counter+1
if counter=20 then goto yellow2
readadc 2,b3
if b3 <120 then goto red2
serin [1000,red21], c.2, n1200_8,("ABC"),b0
if b0=1 then goto signal1
if b0=2 then goto signal2
if b0=5 then goto signal4
if b0=6 then goto signal4
if b0=7 then goto signal3
if b0=8 then goto signal4A
if b0=9 then goto vd1
if b0=10 then goto vd2
if b0=13 then goto vd3
if b0=14 then goto vd4
yellow2:
b1 = %00100100 :gosub registers
b1 = %10010010 :gosub registers
b1 = %01010001 :gosub registers
pulsout c.4,10
counter=0
yellow21:
readadc 2,b3
if b3 <120 then goto red2
counter=counter+1
if counter=15 then goto signal2
serin [1000,yellow21], c.2, n1200_8,("ABC"),b0
if b0=1 then goto signal1
if b0=2 then goto signal2
if b0=5 then goto signal4
if b0=6 then goto signal4
if b0=7 then goto signal3
if b0=8 then goto signal4A
if b0=9 then goto vd1
if b0=10 then goto vd2
if b0=13 then goto vd3
if b0=14 then goto vd4
;==============================================================================
;SIGNAL 3
;==============================================================================
SIGNAL3:
b2=3
write 0, b2
;=============================================================================
;SIGNAL 4
;=============================================================================
SIGNAL4:
b2=4
write 0, b2
;============================================================================
;SIGNAL 4A
;============================================================================
SIGNAL4A:
b2=41
write 0, b2
;============================================================================
;SIGNAL 5
;============================================================================
SIGNAL5:
b2=5
write 0,b2
counter=0
b1 = %00100100 :gosub registers
b1 = %11000010 :gosub registers
b1 = %01001001 :gosub registers
pulsout c.4,10
Monitor5:
readadc 6,b3
if b3 <120 then goto red5
serin [1000,monitor5], c.2, n1200_8,("ABC"),b0
if b0=1 then goto signal1
if b0=2 then goto signal2
if b0=5 then goto signal4
if b0=6 then goto signal4
if b0=7 then goto signal3
if b0=8 then goto signal4A
if b0=9 then goto vd1
if b0=10 then goto vd2
if b0=13 then goto vd3
if b0=14 then goto vd4
red5:
pause 800
b1 = %00100100 :gosub registers
b1 = %10010010 :gosub registers
b1 = %01001001 :gosub registers
pulsout c.4,10
counter=0
red51:
counter=counter+1
if counter=20 then goto signal5
readadc 5,b3
if b3 <120 then goto red5
serin [1000,red51], c.2, n1200_8,("ABC"),b0
if b0=1 then goto signal1
if b0=2 then goto signal2
if b0=5 then goto signal4
if b0=6 then goto signal4
if b0=7 then goto signal3
if b0=8 then goto signal4A
if b0=9 then goto vd1
if b0=10 then goto vd2
if b0=13 then goto vd3
if b0=14 then goto vd4
;==============================================================================
;SET ALL SIGNALS TO RED
;==============================================================================
allred:
b1 = %00100100 :gosub registers ;DATA TO SHIFT REGISTER
b1 = %10010010 :gosub registers ;DATA TO SHIFT REGISTER
b1 = %01001001 :gosub registers ;DATA TO SHIFT REGISTER
pulsout c.4,10 ;LATCH REGISTERS
pause 10
goto start
;============================================================================
;REGISTERS
;============================================================================
registers:
for b0= 1 to 8
if b1 > 127 then high c.7 else low c.7
endif
pulsout c.5,10
b1 = b1 *2
next b0
return
;==============================================================================
;VARIBLE DATA USED TO CALCULATE WHICH WAY SWITCHS 9,10,13,14 ARE SET
;==============================================================================
vd1:
b4=0
write 1,b4
goto vd5
vd2:
b4=4
write 1,b4
goto vd5
vd3:
b5=0
write 2,b5
goto vd5
vd4:
b5=5
write 2,b5
goto vd5
vd5:
b6=b4+b5
write 3,b6
if b6=9 then goto signal5
if b6=4 then goto allred
if b6=5 then goto powerup
if b6=0 then goto powerup