Mouse code for the MacroRat
motor.h
- Committer:
- sahilmgandhi
- Date:
- 2017-05-05
- Revision:
- 7:6f5cb6377bd4
- Parent:
- 4:b5b7836ca2b0
- Child:
- 8:a0760acdc59e
File content as of revision 7:6f5cb6377bd4:
#ifndef MOTOR_H #define MOTOR_H #include "mbed.h" #include "main.h" #include "QEI.h" #define BRAKE_VOLTAGE 0.2 extern PwmOut left1; extern PwmOut left2; extern PwmOut right1; extern PwmOut right2; extern DigitalOut enableLeftMotor; extern DigitalOut enableRightMotor; //QEI leftWheel( inline void enableMotors(){ enableLeftMotor.write(1); enableRightMotor.write(1); } inline void rightWheelBackward(double voltage) { right1.write(voltage); right2.write(0); } inline void rightWheelForward(double voltage) { right1.write(0); right2.write(voltage); } inline void leftWheelForward(double voltage) { left1.write(0); left2.write(voltage); } inline void leftWheelBackward(double voltage) { left1.write(voltage); left2.write(0); } inline void brakeLeftWheel() { left1.write(BRAKE_VOLTAGE); left2.write(BRAKE_VOLTAGE); } inline void brakeRightWheel() { right1.write(BRAKE_VOLTAGE); right2.write(BRAKE_VOLTAGE); } inline void brake() { brakeLeftWheel(); brakeRightWheel(); } inline void coastLeftWheel() { left1.write(0); left2.write(0); } inline void coastRightWheel() { right1.write(0); right2.write(0); } inline void coast() { coastLeftWheel(); coastRightWheel(); } #endif