State machine code on the robot code

Dependencies:   Motordriver mbed-rtos mbed

Fork of MultiModalRobot by Baijun Desai

Committer:
baijun
Date:
Mon Nov 20 01:30:46 2017 +0000
Revision:
14:f413a2b209b0
Parent:
13:4c609396ed75
Child:
15:9bc36f47c8cf
Robot test to rotate counterclockwise and then clockwise

Who changed what in which revision?

UserRevisionLine numberNew contents of line
baijun 14:f413a2b209b0 1 //This will rotate the wheels so that after 5 seconds the robot counterclockwise and then clockwise
emilmont 1:491820ee784d 2 #include "mbed.h"
mbed_official 11:0309bef74ba8 3 #include "rtos.h"
baijun 14:f413a2b209b0 4 #include "motordriver.h"
baijun 14:f413a2b209b0 5
baijun 14:f413a2b209b0 6
baijun 14:f413a2b209b0 7 Motor lw(p26, p29, p30, 1); // pwm, fwd, rev LEFT WHEEL
baijun 14:f413a2b209b0 8 Motor rw(p25, p28, p27, 1); // pwm, fwd, rev RIGHT WHEEL
baijun 13:4c609396ed75 9
emilmont 1:491820ee784d 10
emilmont 1:491820ee784d 11 int main() {
baijun 14:f413a2b209b0 12 wait(5);
baijun 13:4c609396ed75 13 for (float s= -1.0; s < 1.0 ; s += 0.01) {
baijun 14:f413a2b209b0 14 lw.speed(s);
baijun 14:f413a2b209b0 15 rw.speed(-s);
baijun 13:4c609396ed75 16 wait(0.02);
emilmont 1:491820ee784d 17 }
baijun 14:f413a2b209b0 18 lw.stop(0.5);
baijun 14:f413a2b209b0 19 rw.stop(0.5);
baijun 13:4c609396ed75 20 }