sami fendri
/
servo_control
servo motor with two pushbutton
Fork of ReedSwitch by
main.cpp
- Committer:
- gerardoeh
- Date:
- 2013-12-14
- Revision:
- 0:73919552e1de
- Child:
- 1:edc70fba9d80
File content as of revision 0:73919552e1de:
#include "mbed.h" #include "Servo.h" DigitalIn rSwitch(D10); Servo servoRotado(D11); int valSwitch; float pos=0; int main() { rSwitch.mode(PullUp); servoRotado.calibrate(0.001, 45.0); while(1) { valSwitch=rSwitch; while(pos<=1 and valSwitch==1){ valSwitch=rSwitch; pos=pos+0.05; servoRotado=pos; wait(0.3); } while(pos>=0){ pos=pos-0.05; servoRotado=pos; wait(0.3); } } }