Code for our FYDP -only one IMU works right now -RTOS is working

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers motors.cpp Source File

motors.cpp

00001 #include "motors.h"
00002 
00003 Motors::Motors(TB6612 * L, TB6612 * R, PinName STBY):
00004     Left(L), Right(R), enable(STBY)
00005 {
00006     enable = 1;
00007 }
00008 
00009 void Motors::flip()
00010 {
00011     TB6612 * temp = Left;
00012     Left = Right;
00013     Right = temp;
00014 
00015     Left->scale *= -1;
00016     Right->scale *= -1;              
00017 }    
00018 void Motors::reverse(bool m)
00019 {
00020     if(m)
00021         Right->scale *= -1; //reverse right motor
00022     else
00023         Left->scale *= -1;  //reverse left motor
00024 }
00025 
00026 //TODO: write in a function that automatically sets the motors to be oriented properly. Use the
00027 //gyroscopes and accelerometer to do this.