Simple Code to Run An IR Detector

'This is example code only. You should know how to program a Stamp 'before you attempt all this. ' TempLeft var byte TempRight var byte x var byte dirs=%11111110 ' set the first pin to input from IR rx, rest to output ' start: ' put your normal robot code here ' gosub irdetect ' ' check variables here for avoidance, homing, etc ' goto start irdetect: TempRight=0 TempLeft=0 for x=1 to 10 high 1 pause 1 TempRight=TempRight + in0 low 1 high 2 pause 1 TempLeft=TempLeft + in0 low 2 next ' ' remove debug statements on final code ' debug TempRight,cr debug TempLeft,cr pause 500 ' pause so you can see results return