Teaching Assistant / Mbed 2 deprecated PWM_generator

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
302Instructor
Date:
Thu Jan 22 20:05:48 2015 +0000
Commit message:
1/22/15

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- /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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Thu Jan 22 20:05:48 2015 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/0b3ab51c8877
\ No newline at end of file