Yoshiyuki Takahashi
/
Y_02
Sequence LEDs
Fork of Y_01 by
main.cpp@0:fbbd6271c1ac, 2014-02-12 (annotated)
- Committer:
- seethe
- Date:
- Wed Feb 12 00:21:39 2014 +0000
- Revision:
- 0:fbbd6271c1ac
- Child:
- 1:80eb2d3e5974
Sequence LED
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
seethe | 0:fbbd6271c1ac | 1 | // Hello World! for the TextLCD |
seethe | 0:fbbd6271c1ac | 2 | |
seethe | 0:fbbd6271c1ac | 3 | #include "mbed.h" |
seethe | 0:fbbd6271c1ac | 4 | #include "TextLCD.h" |
seethe | 0:fbbd6271c1ac | 5 | |
seethe | 0:fbbd6271c1ac | 6 | //TextLCD lcd(p15, p16, p17, p18, p19, p20); // rs, e, d4-d7 |
seethe | 0:fbbd6271c1ac | 7 | TextLCD lcd(p24, p26, p27, p28, p29, p30); // rs, e, d4-d7 |
seethe | 0:fbbd6271c1ac | 8 | |
seethe | 0:fbbd6271c1ac | 9 | |
seethe | 0:fbbd6271c1ac | 10 | DigitalOut DO[4]={LED1, LED2, LED3, LED4}; |
seethe | 0:fbbd6271c1ac | 11 | int nCnt; |
seethe | 0:fbbd6271c1ac | 12 | |
seethe | 0:fbbd6271c1ac | 13 | void led_blink() |
seethe | 0:fbbd6271c1ac | 14 | { |
seethe | 0:fbbd6271c1ac | 15 | for(int n=0; n<4; n++){ |
seethe | 0:fbbd6271c1ac | 16 | if(n == nCnt) DO[n] = 1; |
seethe | 0:fbbd6271c1ac | 17 | else DO[n] = 0; |
seethe | 0:fbbd6271c1ac | 18 | } |
seethe | 0:fbbd6271c1ac | 19 | } |
seethe | 0:fbbd6271c1ac | 20 | |
seethe | 0:fbbd6271c1ac | 21 | int main() { |
seethe | 0:fbbd6271c1ac | 22 | double cnt; |
seethe | 0:fbbd6271c1ac | 23 | nCnt = 0; |
seethe | 0:fbbd6271c1ac | 24 | cnt = 0.1; |
seethe | 0:fbbd6271c1ac | 25 | while(1){ |
seethe | 0:fbbd6271c1ac | 26 | lcd.printf("Hello World!_%d\n", nCnt); |
seethe | 0:fbbd6271c1ac | 27 | //lcd.printf("...\n"); |
seethe | 0:fbbd6271c1ac | 28 | led_blink(); |
seethe | 0:fbbd6271c1ac | 29 | wait(cnt); |
seethe | 0:fbbd6271c1ac | 30 | //lcd.printf("xxxxxxxxxxxx\n"); |
seethe | 0:fbbd6271c1ac | 31 | lcd.printf("...\n"); |
seethe | 0:fbbd6271c1ac | 32 | //led_blink(); |
seethe | 0:fbbd6271c1ac | 33 | wait(cnt); |
seethe | 0:fbbd6271c1ac | 34 | //cnt+=0.1; |
seethe | 0:fbbd6271c1ac | 35 | if(cnt>=1.0) cnt = 0.1; |
seethe | 0:fbbd6271c1ac | 36 | nCnt++; |
seethe | 0:fbbd6271c1ac | 37 | if(nCnt > 3) nCnt = 0; |
seethe | 0:fbbd6271c1ac | 38 | } |
seethe | 0:fbbd6271c1ac | 39 | } |