Threshold 80 sLeftNum 275169 sFrontNum 287522 sRightNum 287517 sBackNum 190224 case Used in backing up to know when to stop backing up and which way to turn 0 lastTurn This variable will be set to what the last turn is, either 1 if left or 2 if right. It is used in the backing up case so that it will not go down the same path it just did. 0 This code goes to the right one 255 LT If the middle sensor is lower then the treshold drive forward sFrontNum Threshold 255 LT Otherwise see if the left sensor is below threshold and if it is turn left sLeftNum Threshold lastTurn 1 WHILE While the front still senses a value above the treshold turn. This one stays off while the ohter is on GT sFrontNum Threshold 0 Give a little exttra time to help avoid collisions 200 LT If it is possible turn right sRightNum Threshold lastTurn 2 WHILE While the front still senses a value above the treshold turn. This one stays on while the ohter is off GT sFrontNum Threshold 255 200 WHILE The robot will back up until it can turn left (if it did not turn left last time) or turn right (if it didn't just turn right) or if it can not back up any more it will go forward ans try agian. EQ Case initially 0 so should go through first time case 0 Set cases based on if it can turn, what the last turn was and if it can still back up. AND LT sLeftNum Threshold NEQ lastTurn 1 case 1 AND LT sRightNum Threshold NEQ lastTurn 2 case 2 GTE sBackNum Threshold case 3 case 0 450 EQ case 1 If a left turn can be made chack to see if a right turn also can be made. If so turn left based on time. Ohterwise turn until the right sensor value isn't above threshold. This will be more accurate. LT sRightNum Threshold 0 600 WHILE causes it to turn left wihile the right is below the treshold GTE sRightNum Threshold 0 100 lastTurn 1 EQ case 1 WHILE Causes to turn right until the left sensor value is below threshold GTE sLeftNum Threshold 255 100 lastTurn 2 If it can no longer back up it will go forward and try again. Chances are that it has reached a dead end. 255 lastTurn 2 case Return case back to 0 0