日本語コメント付き
Dependencies: mbed
Fork of PwmOut_HelloWorld_mbedos2 by
Diff: main.cpp
- Revision:
- 3:49bf69fdf479
- Parent:
- 2:51cd5763b12f
diff -r 51cd5763b12f -r 49bf69fdf479 main.cpp --- a/main.cpp Fri Jun 29 04:51:26 2018 +0000 +++ b/main.cpp Fri Jul 27 15:56:19 2018 +0000 @@ -1,12 +1,10 @@ #include "mbed.h" -PwmOut led(LED1); +PwmOut led(dp24); // dp24ピンをPWM出力として利用、led変数に割当 int main() { // specify period first - led.period(1.0f); // 4 second period - led.write(0.10f); // 50% duty cycle, relative to period - //led = 0.5f; // shorthand for led.write() - //led.pulsewidth(2); // alternative to led.write, set duty cycle time in seconds - while(1); + led.period(2.0f); // PWM周期を4秒に設定 + led.write(0.50f); // デューティー比を 50% に設定(つまり2秒点灯・2秒消灯の繰り返し) + while(1); // 「何もしない」状態を無限に繰り返す → 上記で設定したPWM制御の状態がずっと続く } \ No newline at end of file