4180Lab2Part7: used to create reversible DC motor with speed control

Dependencies:   Motor mbed

Fork of Motor_HelloWorld by Simon Ford

Files at this revision

API Documentation at this revision

Comitter:
CRaslawski
Date:
Mon Feb 27 22:41:15 2017 +0000
Parent:
0:7bbc230e00d6
Commit message:
initial commit

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r 7bbc230e00d6 -r dfd892e1309d main.cpp
--- a/main.cpp	Tue Nov 23 16:19:19 2010 +0000
+++ b/main.cpp	Mon Feb 27 22:41:15 2017 +0000
@@ -3,11 +3,15 @@
 #include "mbed.h"
 #include "Motor.h"
 
-Motor m(p23, p6, p5); // pwm, fwd, rev
+Motor m(p21, p6, p5); // pwm, fwd, rev
+AnalogIn pot(p20); // cookin
 
 int main() {
-    for (float s= -1.0; s < 1.0 ; s += 0.01) {
-       m.speed(s); 
-       wait(0.02);
+    
+    float r = pot.read();
+    
+    while(1){
+           m.speed(pot); 
+           wait(0.02);
     }
 }