Shop OBEX P1 Docs P2 Docs Learn Events
SUMOBOT question — Parallax Forums

SUMOBOT question

jbodjbod Posts: 46
edited 2008-04-25 03:30 in Robotics
Any one on here have any experience with the Parallax Sumobot ... Looking to add two more IR senors to the BOT. One on each side ... ok with adding the I/O Defs ... just not sure best way to combine the extra left VAR to the existing one so I have one VAR storage for IR target?

'
[noparse][[/noparse] I/O Definitions ]
LfIrOut····· PIN······· 4······················ ' left IR LED output
LfIrIn······ PIN······· 11····················· ' left IR sensor input
RtIrOut····· PIN······· 15····················· ' right IR LED output
RtIrIn······ PIN······· 14····················· ' right IR sensor input
xLfIrOut····· PIN········6······················ ' xleft IR LED output
xLfIrIn······ PIN········7····················· ' xleft IR sensor input
xRtIrOut····· PIN·······8···················· ' xright IR LED output
xRtIrIn······ PIN········9····················· ' xright IR sensor input

'
[noparse][[/noparse] Variables ]
irBits······ VAR······· Nib···················· ' storage for IR target data
irLeft······ VAR······· irBits.BIT1
irRight····· VAR······· irBits.BIT0
'
[noparse][[/noparse] Program Code ]
Main:
· DO
··· FREQOUT LfIrOut, 1, 38500·················· ' modulate left IR LED
··· irLeft = ~LfIrIn··························· ' read input (1 = target)
··· FREQOUT RtIrOut, 1, 38500·················· ' modulate right IR LED
··· irRight = ~RtIrIn·························· ' read input (1 = target)
··· DEBUG HOME,
········· "L R", CR,
········· "----", CR,
········· BIN1 irLeft, " ", BIN1 irRight
··· PAUSE 20
· LOOP
· END

Comments

Sign In or Register to comment.