Mouse code for the MacroRat

Dependencies:   ITG3200 QEI

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers motor.h Source File

motor.h

00001 #ifndef MOTOR_H
00002 #define MOTOR_H
00003 
00004 #include "mbed.h"
00005 //#include "main.h"
00006 
00007 #define BRAKE_VOLTAGE 0.2
00008 
00009 /*
00010 extern PwmOut left1;
00011 extern PwmOut left2;
00012 extern PwmOut right1;
00013 extern PwmOut right2;
00014 
00015 extern DigitalOut enableLeftMotor;
00016 extern DigitalOut enableRightMotor; */
00017 
00018 class Motor
00019 {
00020     public:
00021         Motor( PinName f, PinName b, PinName e ) : 
00022             enableForw( f ), enableBack( b ), motorSpeed( e ), maxSpeed( 0.2 ), minSpeed(0.07)
00023         {
00024         }
00025     
00026         void backward( double voltage );
00027         void forward( double voltage );
00028         void brake();
00029         void coast();
00030         void move( double voltage );
00031         
00032     private:
00033         DigitalOut enableForw;
00034         DigitalOut enableBack;
00035         PwmOut motorSpeed;  
00036         const double maxSpeed;
00037         const double minSpeed;
00038 };
00039 
00040 //QEI leftWheel(
00041 
00042 /*
00043 inline void enableMotors(){
00044     enableLeftMotor.write(1);
00045     enableRightMotor.write(1);
00046 }*/
00047 
00048 
00049 #endif