Can anyone HELP ME with this coding
EP7
Posts: 4
'{$STAMP BS2}
'{$PBASIC 2.5}
DIR0 = 1
Holdbit VAR·· Bit
Start:
·· FREQOUT 0,1,38500
·· Holdbit = IN0
DEBUG 1, "sensor = ",DEC Holdbit, CR
DO
IF (IN0 = 0) THEN
PULSOUT 14, 1000
PAUSE 20
IF (IN0 = 1) THEN
PULSOUT 14, 100
PAUSE 20
ENDIF
ENDIF
LOOP
using this coding I get sensor response, but not any servo movement
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
THANKS,····· EP
'{$PBASIC 2.5}
DIR0 = 1
Holdbit VAR·· Bit
Start:
·· FREQOUT 0,1,38500
·· Holdbit = IN0
DEBUG 1, "sensor = ",DEC Holdbit, CR
DO
IF (IN0 = 0) THEN
PULSOUT 14, 1000
PAUSE 20
IF (IN0 = 1) THEN
PULSOUT 14, 100
PAUSE 20
ENDIF
ENDIF
LOOP
using this coding I get sensor response, but not any servo movement
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
THANKS,····· EP
Comments
Change the IF (IN0 = 1) THEN to an ELSE and eliminate one of the ENDIF statements
but the sensor/servo is not communicating·with each other and rotating the servo in opposite directions! any thoughts!
I was also wondering what
"DIR0" AND "Holdbit" means in the coding
Thanks for the help mike!
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
THANKS,····· EP
2) Holdbit is the name of a one bit variable that holds the state of the IR detector. You need to have "Holdbit = IN0" immediately after the FREQOUT because the IR detector will turn off (logic one) very quickly after the end of the FREQOUT.
3) Along those lines, you should replace IN0 with Holdbit in the IF statement so the IF refers to the saved value rather than the current input pin value (which will always be one at that point).