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: main.cpp
- Revision:
- 0:7fd3327ceec4
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Fri Sep 28 13:43:53 2018 +0000
@@ -0,0 +1,25 @@
+#include "mbed.h"
+
+DigitalOut DirectionPin1(D4);
+PwmOut PwmPin1(D5);
+DigitalOut DirectionPin2(D7);
+PwmOut PwmPin2(D6);
+
+
+
+int main()
+{
+PwmPin1.period_us(120); //60 microseconds pwm period, 16.7 kHz
+ for(;;)
+ {
+ float u = -0.4f; //determine useful value, this is not final
+ DirectionPin1 = u > 0.0f; //either true or false
+ // True = CW, for False = CW
+ PwmPin1 = fabs(u); //PWM duty cycle can only be positive, floating point absolute value
+
+ float v = 0.5f;
+ DirectionPin2 = v > 0.0f;
+ // FIXED! True = CCW, Flase = CW
+ PwmPin2 = fabs(v);
+ }
+}
\ No newline at end of file