mbed_robotcar
/
Servo
サーボ制御
Diff: resources/main.cpp
- Revision:
- 0:bccc9aa87794
diff -r 000000000000 -r bccc9aa87794 resources/main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/resources/main.cpp Mon Jul 13 03:27:34 2020 +0000 @@ -0,0 +1,17 @@ +#include "mbed.h" + +PwmOut pwm(p21); + +int main() { + int start= 0, end= 180; + while(1){ + for(int p = start; p < end; p += 20 ) { + pwm.pulsewidth_us(p); + wait_ms(20); + } + for(int p = end; p >=start; p -= 20) { + pwm.pulsewidth_us(p); + wait_ms(20); + } + } +} \ No newline at end of file