Parallax Activity Bot code

Dependencies:   ContinuousServo Tach mbed

Committer:
lddevrie
Date:
Fri Mar 02 17:02:06 2018 +0000
Revision:
2:f72b9dd19159
Parent:
0:ac6a1723d393
Child:
3:e33676098294
initial test

Who changed what in which revision?

UserRevisionLine numberNew contents of line
jdonnal 0:ac6a1723d393 1 #include "mbed.h"
jdonnal 0:ac6a1723d393 2 #include "ContinuousServo.h"
jdonnal 0:ac6a1723d393 3 #include "Tach.h"
jdonnal 0:ac6a1723d393 4
lddevrie 2:f72b9dd19159 5 // Test change
lddevrie 2:f72b9dd19159 6
jdonnal 0:ac6a1723d393 7 Serial pc(USBTX,USBRX);
jdonnal 0:ac6a1723d393 8 //servos
jdonnal 0:ac6a1723d393 9 ContinuousServo left(p23);
jdonnal 0:ac6a1723d393 10 ContinuousServo right(p26);
jdonnal 0:ac6a1723d393 11 //encoders
jdonnal 0:ac6a1723d393 12 Tach tLeft(p17,64);
jdonnal 0:ac6a1723d393 13 Tach tRight(p13,64);
jdonnal 0:ac6a1723d393 14
jdonnal 0:ac6a1723d393 15 int main() {
jdonnal 0:ac6a1723d393 16 //wait for MATLAB command
jdonnal 0:ac6a1723d393 17 left.speed(0.0);
jdonnal 0:ac6a1723d393 18 right.speed(0.0);
jdonnal 0:ac6a1723d393 19 //while(1);
jdonnal 0:ac6a1723d393 20 pc.getc();
jdonnal 0:ac6a1723d393 21 //spin servos from -1 to 1 and print speed
jdonnal 0:ac6a1723d393 22 for(float i=-1.0;i<=1.0;i+=0.01){
jdonnal 0:ac6a1723d393 23 left.speed(-1.0*i);
jdonnal 0:ac6a1723d393 24 right.speed(i);
jdonnal 0:ac6a1723d393 25 wait_ms(100);
jdonnal 0:ac6a1723d393 26 pc.printf("%f,%f\n", tLeft.getSpeed(),tRight.getSpeed());
jdonnal 0:ac6a1723d393 27 }
jdonnal 0:ac6a1723d393 28 left.stop();
jdonnal 0:ac6a1723d393 29 right.stop();
jdonnal 0:ac6a1723d393 30 }