Pulse width modulate a pin using the MultiTech mDot.

Dependencies:   mbed

Fork of Dragonfly_PwmOut_Example by MultiTech

Revision:
0:4a3a5f1bdca6
Child:
1:8c4800b7cfc7
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Fri Oct 02 14:00:17 2015 +0000
@@ -0,0 +1,26 @@
+/** Dragonfly PwmOut Example Program
+ *
+ * This program demonstrates how to do pulse width modulation on
+ * and output pin using the MultiTech Dragonfly and MultiTech UDK2
+ * hardware. The only additional hardware required is a LED.
+ *
+ * This program PWMs the D12 pin. It should go from 0% to 100% duty
+ * cycle in 5% increments and then from 100% to 0% in 5% increments.
+ */
+ 
+#include "mbed.h"
+ 
+int main() {
+    PwmOut out(D12);
+    
+    while (true) {
+        for (float f = 0.0f; f < 1.0f; f += 0.05f) {
+            out = f;
+            wait_ms(50);
+        }
+        for (float f = 1.0f; f > 0.0f; f -= 0.05f) {
+            out = f;
+            wait_ms(50);
+        }
+    }
+}
\ No newline at end of file