projet megot

Dependencies:   Servo mbed

Fork of Servo_HelloWorld by Simon Ford

Revision:
2:d9a738c0e226
Parent:
1:40d2fd0b99e6
--- a/main.cpp	Tue Nov 23 16:10:35 2010 +0000
+++ b/main.cpp	Wed May 10 10:40:42 2017 +0000
@@ -3,11 +3,42 @@
 #include "mbed.h"
 #include "Servo.h"
 
-Servo myservo(p21);
+// init pin for Nucleo-L476RG
+// Servo myservo(PB_3);
+
+// init pin for Nucleo-L432KC
+Servo myservo(D6);
+
+AnalogIn ain (A2);
 
 int main() {    
-    for(float p=0; p<1.0; p += 0.1) {
-        myservo = p;
-        wait(0.2);
+ 
+    float p = 0.0;
+    float pRead;
+    
+    // myservo.position(0);
+    while(1){
+       /*myservo.write(0);
+       wait(5);
+       myservo.write(1);
+       wait(5);*/
+        //myservo.position(90);
+        //myservo.write(p);
+        //pRead = myservo.read();
+       // printf("val = %f \n",pRead);
+        //wait(0.8);
+        /*if(p > 0.9)
+            p=0.0;
+        else
+            p+=0.1;*/
+        if (ain == 1)
+        {
+            myservo.write(1);
+           // myservo.position(180);
+            wait(2);
+         //   myservo.position(0);
+           myservo.write(0);
+        }
     }
+
 }