SUMOBOT question
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
'
[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
Byte = 8 bits (indexed 0...7)
Nib (nibble) = 4 bits (indexed 0...3)
Bit = 1 bit (index 0)
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
When the going gets weird, the weird turn pro. -- HST
1uffakind.com/robots/povBitMapBuilder.php
1uffakind.com/robots/resistorLadder.php