Hbridge Motor Code

Dependencies:   mbed Motor

Files at this revision

API Documentation at this revision

Comitter:
jlee3588
Date:
Tue Mar 03 01:04:13 2020 +0000
Parent:
0:7bbc230e00d6
Commit message:
abc

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r 7bbc230e00d6 -r 4f9e3d0c8d6e main.cpp
--- a/main.cpp	Tue Nov 23 16:19:19 2010 +0000
+++ b/main.cpp	Tue Mar 03 01:04:13 2020 +0000
@@ -3,11 +3,19 @@
 #include "mbed.h"
 #include "Motor.h"
 
-Motor m(p23, p6, p5); // pwm, fwd, rev
+Motor m(p22, p13, p14); // pwm, fwd, rev
+AnalogIn pot(p20);
 
 int main() {
-    for (float s= -1.0; s < 1.0 ; s += 0.01) {
-       m.speed(s); 
-       wait(0.02);
+    //for (float s= -1.0; s < 1.0 ; s += 0.1) {
+//       m.speed(s); 
+//       wait(1);
+//    }
+    float control;
+    while(1){
+        control = 2*(1-pot)-1;       
+        m.speed(control);
+        wait(0.3);
     }
+
 }