titaniumnitratecoatedcow
Member
my second infra red beam wont give a value
hi all, after getting my infra red beam code working (see here final lcd ir 3 code.bas)
using steady states, have tried to structure the code around 'events' like a state machine.
now my second infra red beam will not give a value
subsystem diagram here https://docs.google.com/presentation...Gvew98sAQ/edit
current code:
hi all, after getting my infra red beam code working (see here final lcd ir 3 code.bas)
using steady states, have tried to structure the code around 'events' like a state machine.
now my second infra red beam will not give a value
subsystem diagram here https://docs.google.com/presentation...Gvew98sAQ/edit
current code:
Code:
'#com 4
#no_data
symbol IR1=b1
symbol IR2=b2
symbol counter=b3
init:
counter=4 'start at max spaces availible
pause 500 ; wait for display to initialise
serout B.1,N2400,(254,1)
pause 30
main:
'do
gosub counterbeam1
gosub counterbeam2
'loop
goto main
counterbeam1:
serout B.1,N2400,(254,128) ; move to start of first line
serout B.1,N2400,("places availible") ; output text
serout b.1, n2400, ( 254, 192 ) 'second line
serout b.1, N2400, (#counter)
readadc b.4,IR1
debug IR1
if IR1 <10 then goto in_the_beam
goto counterbeam1
in_the_beam:
readadc b.4,IR1
debug IR1
pause 500
if IR1 >10 then goto out_of_the_beam
goto in_the_beam
out_of_the_beam:
let counter = counter -1 ;the car is now out of the beam so display one less space as available (count up from 4)
if counter=0 then goto full 'stop b1 from counting up (maximum spaces taken up)
'return
goto main
full:
debug counter
serout B.1,N2400,(254,1)
serout b.1, n2400, ( 254, 128 ) 'second line
serout b.1, n2400, ( "park is full " )
readadc c.4 ,IR2
if IR2 <10 then goto counterbeam2
goto main
counterbeam2:
serout B.1,N2400,(254,128) ; move to start of first line
serout B.1,N2400,("places availible") ; output text
serout b.1, n2400, ( 254, 192 ) 'second line
serout b.1, N2400, (#counter)
readadc c.4,IR2
debug IR2
if IR2 <100 then goto in_the_beam2
in_the_beam2:
readadc c.4,IR2
debug IR2
pause 500
if IR2 >100 and counter<4 then goto out_of_the_beam2
goto in_the_beam2
out_of_the_beam2:
let counter = counter +1 ;the car is now out of the beam so display one less space as available (count up from 4)
if counter=0 then goto full 'stop b1 from counting up (maximum spaces taken up)
goto main
Last edited: