![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
working example of final project code (in development)
Dependencies: ContinuousServo TCS3472_I2C Tach mbed
Fork of ES202FinalProject by
Diff: main.cpp
- Revision:
- 0:ac6a1723d393
- Child:
- 2:f72b9dd19159
diff -r 000000000000 -r ac6a1723d393 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Fri Mar 02 16:55:01 2018 +0000 @@ -0,0 +1,28 @@ +#include "mbed.h" +#include "ContinuousServo.h" +#include "Tach.h" + +Serial pc(USBTX,USBRX); +//servos +ContinuousServo left(p23); +ContinuousServo right(p26); +//encoders +Tach tLeft(p17,64); +Tach tRight(p13,64); + +int main() { + //wait for MATLAB command + left.speed(0.0); + right.speed(0.0); + //while(1); + pc.getc(); + //spin servos from -1 to 1 and print speed + for(float i=-1.0;i<=1.0;i+=0.01){ + left.speed(-1.0*i); + right.speed(i); + wait_ms(100); + pc.printf("%f,%f\n", tLeft.getSpeed(),tRight.getSpeed()); + } + left.stop(); + right.stop(); +}