w1 = 0 'srf005front covering the front w2 = 0 'srf005front covering the left w3 = 0 'srf005back covering (the left area) turnon: 'sub-routine of checking if I started the robot if pin0=1 then pwmin goto turnon pwmin: 'pwm input pwmout 1,100,400 pwmout 2,100,400 goto sense sense: '1st sensing momentum - the servo is directed to the front, so the srf005front is covering the front area servo 7,225 pause 200 pulsout 4,2 pulsin 1,1,w1 pause 10 let w1 = w1 * 10/58 '2nd sensing momentum - the servo is directed to the left, so the srf005front is covering the left area servo 7,150 pause 200 pulsout 4,2 pulsin 1,1,w2 pause 10 let w2 = w2 * 10/58 '3rd sensing momentum - this is the srf005back measuring pause 50 pulsout 5,2 pulsin 2,1,w3 pause 10 let w3 = w3 * 10/58 goto condition condition: 'sub-routine forhe conditions if w1>20 and w2<20 and w3<20 then wall 'follow wall if w1<20 and w2<20 and w3<20 then left 'surrounded by walls if w1<20 and w2>20 and w3>20 then left 'object at front if w1>20 and w2<20 and w3>20 then backleft 'object in the right corner if w1>20 and w2>20 and w3<20 then wall 'correction in raltion with the wall if w1<20 and w2<20 and w3>20 then back 'corner if w1<20 and w2>20 and w3<20 then left 'triangle if w1>20 and w2>20 and w3>20 then front 'follow, without any object goto sense front: 'sequence of highs/lows that drives the robot forwards low 0 high 1 high 2 low 3 goto sense back: 'sequence of highs/lows that drives the robot backs high 0 low 1 low 2 high 3 pause 300 goto sense right: 'sequence of highs/lows that drives the robot right low 0 high 1 low 2 high 3 pause 500 goto sense left: 'sequence of highs/lows that drives the robot left high 0 low 1 high 2 low 3 pause 500 goto sense backright: 'sequence of highs/lows that drives the robot back and then to the right low 1 low 2 high 3 pause 500 low 0 high 1 low 2 high 3 pause 300 goto sense backleft: 'sequence of highs/lows that drives the robot back and then to the left high 0 low 1 low 2 high 3 pause 500 high 0 low 1 high 2 low 3 pause 300 goto sense wall: 'sub-routine to cover a wall, if detected low 0 high 1 high 2 low 3 'conditions of this sub-routine if w2<10 and w3<10 then left 'too much closer to a wall if w2>10 and w3<10 then rightfront 'turn a little bit to right if w2<10 and w3>10 then left 'turn a little bit to left if w2>10 and w3>10 then frontright 'too away from the wall goto sense frontright: 'sequence of highs/lows that drives the robot forwards, and then to the right low 0 high 1 high 2 low 3 pause 500 low 0 high 1 low 2 high 3 pause 300 goto senses senses: '4 sensing momentum of srf005front - with the servo directed to the front servo 7,225 pause 200 pulsout 4,2 pulsin 1,1,w1 pause 10 let w1 = w1 * 10/58 '5 sensing momentum of srf005front - with the servo directed to the left servo 7,150 pause 200 pulsout 4,2 pulsin 1,1,w2 pause 10 let w2 = w2 * 10/58 goto parede rightfront: 'sequence of highs/lows that drives the robot right and then to the front low 0 high 1 low 2 high 3 pause 300 goto frente