DC motor control using pot

Dependencies:   Motor mbed

Fork of Motor_HelloWorld by Simon Ford

Files at this revision

API Documentation at this revision

Comitter:
kzar
Date:
Tue Oct 16 19:02:00 2018 +0000
Parent:
0:7bbc230e00d6
Commit message:
DC motor control using pot

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r 7bbc230e00d6 -r 53fc5a32c407 main.cpp
--- a/main.cpp	Tue Nov 23 16:19:19 2010 +0000
+++ b/main.cpp	Tue Oct 16 19:02:00 2018 +0000
@@ -1,13 +1,13 @@
-// Sweep the motor speed from full-speed reverse (-1.0) to full speed forwards (1.0)
+  // Sweep the motor speed from full-speed reverse (-1.0) to full speed forwards (1.0)
 
 #include "mbed.h"
 #include "Motor.h"
 
-Motor m(p23, p6, p5); // pwm, fwd, rev
+AnalogIn pot(p19);
+Motor m(p25, p6, p5); // pwm, fwd, rev
 
 int main() {
-    for (float s= -1.0; s < 1.0 ; s += 0.01) {
-       m.speed(s); 
-       wait(0.02);
+    while (1) {
+        m.speed((pot*2)-1);
     }
 }