Leo Veenstra
/
PWM
main.cpp
- Committer:
- SED9008
- Date:
- 2012-03-19
- Revision:
- 0:95ac8e26a28f
File content as of revision 0:95ac8e26a28f:
#include "mbed.h" AnalogIn control(p18); PwmOut servo(p21); int main() { servo.period(0.020); // servo requires a 20ms period float input = control.read(); while (1) { input = control.read()/1000; servo.pulsewidth(0.001 + input); // servo position determined by a pulsewidth between 1-2ms wait(0.25); } }