Open Loop drive forward

Dependencies:   mbed Tach ContinuousServo

Committer:
m211482
Date:
Tue Apr 16 14:54:18 2019 +0000
Revision:
0:072052527879
Child:
1:da5831bec373
Open Loop drive forward;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
m211482 0:072052527879 1 #include "mbed.h"
m211482 0:072052527879 2 #include "ContinuousServo.h"
m211482 0:072052527879 3 #include "Tach.h"
m211482 0:072052527879 4
m211482 0:072052527879 5 //servos
m211482 0:072052527879 6 ContinuousServo left(p23);
m211482 0:072052527879 7 ContinuousServo right(p26);
m211482 0:072052527879 8 //ecnoders
m211482 0:072052527879 9 Tach tLeft(p17,64);
m211482 0:072052527879 10 Tach tRight(p13,64);
m211482 0:072052527879 11 float wL;
m211482 0:072052527879 12 float wR;
m211482 0:072052527879 13 int main() {
m211482 0:072052527879 14 while(1) {
m211482 0:072052527879 15 left.speed(0.49);
m211482 0:072052527879 16 wL=tLeft.getSpeed();
m211482 0:072052527879 17 right.speed(-0.5); //the servo is inverted so much be negative
m211482 0:072052527879 18 wR=tRight.getSpeed();
m211482 0:072052527879 19 printf("Both moving, l=%f, r=%f\n\r",wL,wR);
m211482 0:072052527879 20 wait(0.5);
m211482 0:072052527879 21 left.stop();
m211482 0:072052527879 22 right.stop();
m211482 0:072052527879 23
m211482 0:072052527879 24 }
m211482 0:072052527879 25 }