This program manually generates a PWM signal. For educational use.

Dependencies:   mbed

Revision:
0:0cb6f477149a
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Thu Jan 22 20:05:48 2015 +0000
@@ -0,0 +1,39 @@
+#include "mbed.h"
+
+void countDirection(int);
+DigitalOut steering_pwm(PTE20);
+int count = 0;
+int ref = 120e3;
+int countDir = 0;
+
+/*void countDirection(int)
+{
+    if (countDir = 0) {
+        count++;
+    } else (countDir = 1) {
+        count--;
+    }
+}*/
+
+int main()
+{
+    while(1) {
+        if (count == 1) {
+            countDir = 0;
+        }   else if(count == 240e3){
+            countDir = 1;
+        }
+
+        if (countDir == 0) {
+            count+=1;
+        } else if (countDir == 1) {
+            count+=-1;
+        }
+
+        if (count <= ref) {
+            steering_pwm = 1;
+        } else {
+            steering_pwm = 0;
+        }
+    }
+}
\ No newline at end of file