mbed_example
/
AnalogIn_ex_1
additional AnalogIn example
Diff: main.cpp
- Revision:
- 0:490818b6238b
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Thu Jan 19 14:19:28 2017 -0600 @@ -0,0 +1,13 @@ +#include "mbed.h" + +AnalogIn position(A0); +PwmOut servo(D3); + +int main() { + // servo requires a 20ms period + servo.period(0.020f); + while (1) { + // servo position determined by a pulse width between 1-2ms + servo.pulsewidth(0.001f + 0.001f * position); + } +}