titaniumnitratecoatedcow
Member
hi
my code involves cars entering a beam and then variable b3 count up only once the car exits the beam.
currently i am using two sub routines that have to happen in order to get b3 to count up(in_the_beam and out_of_the_beam).
i was wondering if there is a simpler way of getting this to happen:
1) the beam is broken
2) the beam is unbroken
if both of these things happen get b3 to count up
here is my code, thanks for an help available
my code involves cars entering a beam and then variable b3 count up only once the car exits the beam.
currently i am using two sub routines that have to happen in order to get b3 to count up(in_the_beam and out_of_the_beam).
i was wondering if there is a simpler way of getting this to happen:
1) the beam is broken
2) the beam is unbroken
if both of these things happen get b3 to count up
here is my code, thanks for an help available
Code:
init:
b3=4
pause 500 ; wait for display to initialise
serout B.1,N2400,(254,1)
pause 30
main:
serout B.1,N2400,(254,128) ; move to start of first line
serout B.1,N2400,("places availible") ; output text
irout b.2, 1, 16 ; Send the command
'pause 45 ; Pause after each command sent
readadc b.3,b1
debug
if b1 <50 then goto in_the_beam 'the car needs to be in the beam, but the exit the beam for b2 to count down,
'otherwise a car could sit in the beam for too long and cause multiple spaces to be displayed as taken.
'if b1 >50 then
serout b.1, n2400, ( 254, 192 ) 'second line
'pause 500
serout b.1, N2400, (#b3)
goto main
in_the_beam:
readadc b.3,b1
pause 500
if b1 >50 then goto out_of_the_beam
goto in_the_beam
out_of_the_beam:
let b3 = b3 -1 ;the car is now out of the beam so display one less space as available (count up from 4)
if b1 < 50 then goto in_the_beam
if b3=0 then goto full 'stop b1 from counting up (maximum spaces taken up)
goto main
full:
let b3=4 'stop at 0
serout B.1,N2400,(254,1)
serout b.1, n2400, ( 254, 128 ) 'second line
serout b.1, n2400, ( "park is full " )
[code]
Last edited: