working example of final project code (in development)

Dependencies:   ContinuousServo TCS3472_I2C Tach mbed

Fork of ES202FinalProject by John Donnal

main.cpp

Committer:
jdonnal
Date:
2018-03-02
Revision:
0:ac6a1723d393
Child:
2:f72b9dd19159

File content as of revision 0:ac6a1723d393:

#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();
}