titaniumnitratecoatedcow
Member
I am making a model parking garage which involves cars passing through an infra red beam.
the amount of cars that pass through the beam makes variable b1 count up, the value of b1 is then displayed on an lcd screen.
the problem is i want b1 to only count up once the cars have exited the beam.
this is how i have tried to solve this but now it wont make b1 count up at all any help would be much appreciated.
the amount of cars that pass through the beam makes variable b1 count up, the value of b1 is then displayed on an lcd screen.
the problem is i want b1 to only count up once the cars have exited the beam.
this is how i have tried to solve this but now it wont make b1 count up at all any help would be much appreciated.
Code:
#no_data
#com 3
init:
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 taken") ; output text
'for b0 = 1 to 10
irout b.2, 1, 16 ; Send the command
pause 45 ; Pause after each command sent
'next b0
'pause 1000 ; Wait 10 seconds
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
goto main
in_the_beam:
pause 500
if b1 >50 then goto out_of_the_beam
out_of_the_beam:
pause 200
let b2 = b2 +1 ;the car is now out of the beam so display one less space as availible (count down from 4)
if b1 < 50 then goto in_the_beam
if b2 =4 then goto four
if b2 =3 then goto three
if b2 =2 then goto two
if b2 =1 then goto one
if b2>4 then goto full 'stop b1 from counting up (maximum spaces taken up)
goto main
one:
serout b.1, n2400, ( 254, 192 ) 'second line
serout b.1, n2400, ( b1, "1" ) 'display one
goto main
two:
serout b.1, n2400, ( 254, 192 ) 'second line
serout b.1, n2400, ( b1, "2" ) 'display 2
goto main
three:
serout b.1, n2400, ( 254, 192 ) 'second line
serout b.1, n2400, ( b1, "3" ) 'display 3
goto main
four:
serout b.1, n2400, ( 254, 192 ) 'second line
serout b.1, n2400, ( b1, "4" ) 'display 4
goto main
full:
let b2=b2 'stop at 0
'serout b.1, n2400, ( 254, 128 ) 'second line
'serout b.1, n2400, ( b1, "the park is full " )
Last edited by a moderator: