26
PICAXE
PICAXE
Two Sensors for Crossing
•Program 4:
PauseBeforeStart: 'prevents detecting slow button push
low 1 ‘turn off LED 1
low 2 ‘turn off LED 2
pause 1000 'pause 1 second
CheckButtons:
b1=0:b2=0
if pin3 = 1 and pin4 = 1 then CheckButtons
if pin3=0 then
  b1=1 ‘save which button hit first
  goto flash
endif
b2=1 ‘save which button hit first
Flash:
  high 1 ‘LED 1 on
  low 2 ‘LED 2 off
FlashAgain:
  for w3= 1 to 250 'check for button before changing lights
    if b2=1 and pin3=0 then PauseBeforeStart
    if b1=1 and pin4=0 then PauseBeforeStart
  next w3
  toggle 1:toggle 2 ‘switch lights
goto FlashAgain: 'continue checking buttons
Show crossing demo – need batteries & sensors  #7