ECE4180 / Mbed 2 deprecated 4180lab2_part7_Servo

Dependencies:   Servo mbed

Fork of 4180lab2_part7_Servo by Yushan Cai

Files at this revision

API Documentation at this revision

Comitter:
ycai47
Date:
Sat Sep 05 22:50:17 2015 +0000
Parent:
1:40d2fd0b99e6
Commit message:
servo

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r 40d2fd0b99e6 -r 8b44ababac65 main.cpp
--- a/main.cpp	Tue Nov 23 16:10:35 2010 +0000
+++ b/main.cpp	Sat Sep 05 22:50:17 2015 +0000
@@ -3,11 +3,14 @@
 #include "mbed.h"
 #include "Servo.h"
 
+AnalogIn pot(p20);
 Servo myservo(p21);
 
-int main() {    
-    for(float p=0; p<1.0; p += 0.1) {
-        myservo = p;
-        wait(0.2);
+int main() {
+    while (true)
+    {
+        float vol = pot.read();
+        myservo.write(vol);
+        wait(0.02f);
     }
 }