IR remote program help
Annoying
Posts: 50
so I want to use the IR remote to turn my robot on and off (If button 1 is pressed, start program, if button 2 is pressed, stop), and this basic program that I wrote doesn't work. I tried a lot of debug statements but I can't figure it out. It's just very inconsistent and so if you could find the flaw in logic I'd appreciate it!
'{$STAMP BS2}
'{$PBASIC 2.5}
time VAR Word(2) ' SONY TV remote variables.
Start:
·· DEBUG "Start"
·DO ' Wait for rest between messages.
RCTIME 12, 1, time(0)
LOOP UNTIL time(0) > 1000
PULSIN 12, 0, time(0) ' Measure/store data pulses.
PULSIN 12, 0, time(1)
IF (time(1) < 500) AND (time(0) < 500) THEN··· 'If Button 1 is pressed start program
GOTO Main
ENDIF
GOTO Start
Main:
DEBUG "Main"
PULSIN 12, 0, time(0) ' Measure/store data pulses.
PULSIN 12, 0, time(1)
IF (time(1) < 500) AND (time(0) > 500) THEN···· ·'If button 2 is pressed stop program
GOTO Start
ENDIF
GOTO Main
·
'{$STAMP BS2}
'{$PBASIC 2.5}
time VAR Word(2) ' SONY TV remote variables.
Start:
·· DEBUG "Start"
·DO ' Wait for rest between messages.
RCTIME 12, 1, time(0)
LOOP UNTIL time(0) > 1000
PULSIN 12, 0, time(0) ' Measure/store data pulses.
PULSIN 12, 0, time(1)
IF (time(1) < 500) AND (time(0) < 500) THEN··· 'If Button 1 is pressed start program
GOTO Main
ENDIF
GOTO Start
Main:
DEBUG "Main"
PULSIN 12, 0, time(0) ' Measure/store data pulses.
PULSIN 12, 0, time(1)
IF (time(1) < 500) AND (time(0) > 500) THEN···· ·'If button 2 is pressed stop program
GOTO Start
ENDIF
GOTO Main
·
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
··Thanks for any··that you may have and all of your time finding them
·
·
·
·
Sam
Post Edited (sam_sam_sam) : 2/24/2010 2:28:19 AM GMT
My most recent encoder project was very timing-critical, and I could not wait for the whole readIR routine to execute, yet I needed to exit my main program by an IR remote signal. In that case, I had a single, fast-executing IF statement inside my main program loop that looked at the IR sensor output. Any LOW signal (IF IN0=0 THEN...) would exit the main loop, so any keypress on the remote triggered the exit routine. That may or may not work in your case.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·"If you build it, they will come."
www.parallax.com/dl/docs/prod/compshop/IRremoteAppKit.pdf