Jose Rios
/
Nucleo_ServoKnob
Control a servo with an analog value (knob). A basic example of using a servo.
Revision 0:3a3bfe92df7c, committed 2014-09-19
- Comitter:
- jose_23991
- Date:
- Fri Sep 19 15:26:02 2014 +0000
- Commit message:
- Version 1.0
Changed in this revision
diff -r 000000000000 -r 3a3bfe92df7c Servo.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Servo.lib Fri Sep 19 15:26:02 2014 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/simon/code/Servo/#36b69a7ced07
diff -r 000000000000 -r 3a3bfe92df7c main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Fri Sep 19 15:26:02 2014 +0000 @@ -0,0 +1,19 @@ +#include "mbed.h" +#include "Servo.h" + +int main() +{ + Servo myservo(D3); // Create the servo object + AnalogIn knob(A0); // Create the analog input object + + float val; + + 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 + } +}
diff -r 000000000000 -r 3a3bfe92df7c mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Fri Sep 19 15:26:02 2014 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/552587b429a1 \ No newline at end of file