Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of Servo_HelloWorld by
Revision 2:d9a738c0e226, committed 2017-05-10
- Comitter:
- Kevin_16
- Date:
- Wed May 10 10:40:42 2017 +0000
- Parent:
- 1:40d2fd0b99e6
- Commit message:
- megot
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file | 
| mbed.bld | Show annotated file Show diff for this revision Revisions of this file | 
--- 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);
+        }
     }
+
 }
--- a/mbed.bld Tue Nov 23 16:10:35 2010 +0000 +++ b/mbed.bld Wed May 10 10:40:42 2017 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/mbed_official/code/mbed/builds/e2ac27c8e93e +https://mbed.org/users/mbed_official/code/mbed/builds/794e51388b66 \ No newline at end of file
