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
Diff: MotorShield.h
- Revision:
- 0:f2ede00aed8a
- Child:
- 1:4c3c2b7337a6
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/MotorShield.h Mon Aug 24 20:19:03 2020 +0000
@@ -0,0 +1,33 @@
+/* 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();
+};
+