additional AnalogIn example

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 
00003 AnalogIn position(A0);
00004 PwmOut servo(D3);
00005 
00006 int main() {
00007     // servo requires a 20ms period    
00008     servo.period(0.020f);
00009     while (1) {
00010         // servo position determined by a pulse width between 1-2ms
00011         servo.pulsewidth(0.001f + 0.001f * position);
00012     }
00013 }