Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: experiment_example motor_shield_example Position_ctrl Lab3_experiment_example ... more
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();
};