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.
Diff: Motor/Motor.cpp
- Revision:
- 0:db8d4af513c0
- Child:
- 1:5b0303768126
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Motor/Motor.cpp Mon Jan 20 08:46:24 2020 +0000
@@ -0,0 +1,29 @@
+#include "Motor.h"
+
+#include "mbed.h"
+
+MOTOR::MOTOR(PinName D1, PinName D2, PinName pwm)
+ :D1_(D1), D2_(D2), pwm_(pwm)
+{
+ D1_.write(0);
+ D2_.write(0);
+ pwm_.write(0);
+}
+
+void MOTOR::Dir(dire mode, uint8_t pwm)
+{
+ D1_.write((char)mode & 0x01);
+ D1_.write((char)mode & 0x02);
+ pwm_.write((float)(pwm / 100.0));
+}
+
+void MOTOR::Dir(dire mode)
+{
+ D1_.write((char)mode & 0x01);
+ D1_.write((char)mode & 0x02);
+}
+
+void MOTOR::PWM(uint8_t pwm)
+{
+ pwm_.write((float)(pwm / 100.0));
+}
\ No newline at end of file