3m

Dependencies:   mbed

Fork of hudo by albatross

Revision:
2:e1b3f635701b
Parent:
1:28852d0667a9
diff -r 28852d0667a9 -r e1b3f635701b main.cpp
--- a/main.cpp	Wed Nov 23 07:53:46 2016 +0000
+++ b/main.cpp	Wed Nov 23 11:31:48 2016 +0000
@@ -4,6 +4,8 @@
 #define MaxDeg 25.0
 
 PwmOut servo(p21);
+AnalogIn input(p20);
+double bairitu;
 
 double calcPulse(int deg){
     return (0.0006+(deg/180.0)*(0.00235-0.00045));
@@ -11,7 +13,8 @@
 
 int main() {
     while(1){
-      servo.pulsewidth(calcPulse(71.0 + SERVODEG - MaxDeg));//calcPulse = 90の時がニュートラル
-      wait(1);
+      bairitu = (input-0.5)*2;
+      servo.pulsewidth(calcPulse(71.0 + SERVODEG + bairitu*MaxDeg));//calcPulse = 90の時がニュートラル
+      wait(0.1);
       }
   }