Motor Shield Example code for 2.74 Class @ MIT
Dependents: experiment_example motor_shield_example Lab3_experiment_example jumping_leg_clicky
MotorShield.h
- Committer:
- elijahsj
- Date:
- 2020-08-24
- Revision:
- 0:f2ede00aed8a
- Child:
- 1:4c3c2b7337a6
File content as of revision 0:f2ede00aed8a:
/* Library to interface with 2.74 Motor Shield ** Uses a modified version of FastPWM library to improve PWM accuracy */ #include "FastPWM.h" class MotorShield { public: /** Receives two PinName variables. * @param echoPin mbed pin to which the echo signal is connected to * @param triggerPin mbed pin to which the trigger signal is connected to */ MotorShield(PinName forwardPin, PinName reversePin); /** Calculates the distance in cm, with the calculation time of 25 ms. * @returns distance of the measuring object in cm. */ void write(double duty_cycle); void period(double period); void direction(int direction); private: int direction_val; double duty_cycle_val; double period_val; void init(); void writePWM(); };