Tachinit

Dependencies:   mbed Tach ContinuousServo

main.cpp

Committer:
m215910
Date:
2019-04-17
Revision:
0:9acdbbfa4eb2
Child:
1:66d0178e8f40

File content as of revision 0:9acdbbfa4eb2:

//Satre Gagnon, Ewing, Batten 
//Tach Initial 

#include "mbed.h"
#include "ContinuousServo.h"
#include "Tach.h"
 

Serial pc(USBTX,USBRX); //Establish serial connection

//speed
float wL, wR;
 
ContinuousServo left(p23);
ContinuousServo right(p26);
 
//encoders
Tach tleft(p17,64);
Tach tright(p13,64);
 
int main()
{ 
    
    pc.baud(9600); //set baud rate
    
    while(1) {
        
        left.speed(0.5);
        right.speed(-0.5); //right negative to go forward
        
        wL = tleft.getSpeed(); //speed of left wheel (rev/sec)
        wR = tright.getSpeed(); //speed of right wheel (rev/sec)
        
        pc.printf("%f, %f\n", wL, wR);
        wait(1);
     
}  //while
}  //main