hirobe aikawa
/
20151114_mbed_PWMblinky_SimpleIoTBoard
PWMでLチカ
main.cpp@0:d37007237832, 2015-11-14 (annotated)
- Committer:
- hirobe0913
- Date:
- Sat Nov 14 05:15:14 2015 +0000
- Revision:
- 0:d37007237832
Simple IoT Board LED?PWM???
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
hirobe0913 | 0:d37007237832 | 1 | #include "mbed.h" |
hirobe0913 | 0:d37007237832 | 2 | |
hirobe0913 | 0:d37007237832 | 3 | /* |
hirobe0913 | 0:d37007237832 | 4 | DigitalOut myled(dp18); |
hirobe0913 | 0:d37007237832 | 5 | |
hirobe0913 | 0:d37007237832 | 6 | int main() { |
hirobe0913 | 0:d37007237832 | 7 | while(1) { |
hirobe0913 | 0:d37007237832 | 8 | myled = 1; |
hirobe0913 | 0:d37007237832 | 9 | wait(0.2); |
hirobe0913 | 0:d37007237832 | 10 | myled = 0; |
hirobe0913 | 0:d37007237832 | 11 | wait(0.2); |
hirobe0913 | 0:d37007237832 | 12 | } |
hirobe0913 | 0:d37007237832 | 13 | } |
hirobe0913 | 0:d37007237832 | 14 | */ |
hirobe0913 | 0:d37007237832 | 15 | |
hirobe0913 | 0:d37007237832 | 16 | // Fade a led on. |
hirobe0913 | 0:d37007237832 | 17 | #include "mbed.h" |
hirobe0913 | 0:d37007237832 | 18 | |
hirobe0913 | 0:d37007237832 | 19 | PwmOut led(dp18); |
hirobe0913 | 0:d37007237832 | 20 | |
hirobe0913 | 0:d37007237832 | 21 | int main() { |
hirobe0913 | 0:d37007237832 | 22 | while(1) { |
hirobe0913 | 0:d37007237832 | 23 | led = led + 0.01; |
hirobe0913 | 0:d37007237832 | 24 | wait(0.2); |
hirobe0913 | 0:d37007237832 | 25 | if(led == 1.0) { |
hirobe0913 | 0:d37007237832 | 26 | led = 0; |
hirobe0913 | 0:d37007237832 | 27 | } |
hirobe0913 | 0:d37007237832 | 28 | } |
hirobe0913 | 0:d37007237832 | 29 | } |