We’re trying to use three sensors to track the white line in the autonomous mode. We’re using 1 joystick drive. Our left sensor is on rc_sw1, pin 1, our middle sensor is pm rc_sw2, pin 2, and the right one is on rc_sw3, pin 15. I have tried lots of different things, but since I don’t really understand what I’m doing I haven’t accomplished anything remotely useful, and I have managed to completely confuse myself. If anyone has any suggestions as to how to get these sensors to recognize the tape and turn and basically just WORK, I would be thrilled.
What you should do in instances like this is write psuedo-code in english. You should try this:
If the middle sensor is on, then I want to go straight.
If only the left sensor is on, then I want to turn left.
If only the right sensor is on, then I want to turn right.
If no sensors are on, then spin in a circle.
Now, go on to write your code:
If (rc_sw2) then gostraight
If (rc_sw1)&(rc_sw3 = 0) then turnleft
If (rc_sw3)&(rc_sw1 = 0) then turnright
goto turnleft
gostraight:
p1_x = 127
p1_y = 200 'random forward speed, should be tested on bot
goto restofcode
turnleft:
p1_x = 84
p1_y = 127
goto restofcode
turnright:
p1_x = 200
p1_y = 127
restofcode:
…
…
…
serout …