This code enables our mouse to go round the track using the two error methods.
Dependencies: Nucleo_blink_led mbed
Fork of Nucleo_blink_led by
Diff: findLineFunc.cpp
- Revision:
- 6:a652deaae134
- Parent:
- 5:dfea493f7a12
- Child:
- 7:11dd5581c763
--- a/findLineFunc.cpp Sun Mar 11 13:15:34 2018 +0000 +++ b/findLineFunc.cpp Sun Apr 01 18:21:50 2018 +0000 @@ -4,15 +4,16 @@ void findLineFunc() { //TURN RIGHT UNTIL SENSOR A6, POSITION 6, BEATS THERSHOLD + leftMotorVal.pulsewidth_us(300); + rightMotorVal.pulsewidth_us(0); + while (((sensorPin[6]).read_u16()>>4) < (sensorThreshold[6])) { - //LEFT WHEEL STARTS TURN - leftMotorVal.pulsewidth_us(300); - rightMotorVal.pulsewidth_us(0); + } + //CONTINUE FOR A BIT, THEN STOP MOTORS AND RETURN - wait_ms(100); - leftMotorVal.pulsewidth_us(0); - rightMotorVal.pulsewidth_us(0); + wait_ms(10); + return; } \ No newline at end of file