
Program to restrict the movement of servos by using ReedSwitch
main.cpp
- Committer:
- gerardoeh
- Date:
- 2013-12-14
- Revision:
- 0:73919552e1de
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); } } }