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.
Revision 1:86ea1eb9c60b, committed 2015-05-14
- Comitter:
- julientiron
- Date:
- Thu May 14 20:34:59 2015 +0000
- Parent:
- 0:3a3bfe92df7c
- Commit message:
- servo;
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r 3a3bfe92df7c -r 86ea1eb9c60b main.cpp --- a/main.cpp Fri Sep 19 15:26:02 2014 +0000 +++ b/main.cpp Thu May 14 20:34:59 2015 +0000 @@ -3,17 +3,21 @@ int main() { - Servo myservo(D3); // Create the servo object - AnalogIn knob(A0); // Create the analog input object + Servo myservo(D7); // Create the servo object - float val; - + float butee_droite=0.1; + float butee_gauche=1; + float position=0.1; myservo.calibrate(0.00095, 90.0); // Calibrate the servo - - while(1) - { - val = knob.read(); // Reads the value of the potentiometer (value between 0 and 1) - myservo.write(val); // Sets the servo position according to the scaled value (0-1) - wait_ms(15); // Waits for the servo to get there + + while(1) { + while(position<butee_gauche){ + myservo.write(position); + position = position + 0.01; + wait_ms(100); + } + myservo.write(butee_droite); + position = 0.1; + wait_ms(500); } }