Keiju Nakano
/
mbed_blinky_analog
Platform : mbed LPC1114FN28 , pwmが更新する度に長時間停波するので今回の用途にはつかえない
Diff: main.cpp
- Revision:
- 0:5ac8ea653724
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Tue May 05 08:25:50 2015 +0000 @@ -0,0 +1,18 @@ +#include "mbed.h" + +AnalogIn position(dp4); +PwmOut servo(dp1); + +Serial device (USBTX,USBRX); + +int main() +{ + // servo requires a 20ms period + servo.period(0.015f); + while (1) { + wait(0.5); + // servo position determined by a pulse width between 1-2ms + servo.pulsewidth(0.001f + 0.001f * position); + + } +} \ No newline at end of file