Blink all LEDs

Dependencies:   TextLCD mbed

Is here public?

Committer:
seethe
Date:
Mon Feb 10 07:27:24 2014 +0000
Revision:
0:498a45e38bed
blink all leds

Who changed what in which revision?

UserRevisionLine numberNew contents of line
seethe 0:498a45e38bed 1 // Hello World! for the TextLCD
seethe 0:498a45e38bed 2
seethe 0:498a45e38bed 3 #include "mbed.h"
seethe 0:498a45e38bed 4 #include "TextLCD.h"
seethe 0:498a45e38bed 5
seethe 0:498a45e38bed 6 //TextLCD lcd(p15, p16, p17, p18, p19, p20); // rs, e, d4-d7
seethe 0:498a45e38bed 7 TextLCD lcd(p24, p26, p27, p28, p29, p30); // rs, e, d4-d7
seethe 0:498a45e38bed 8
seethe 0:498a45e38bed 9
seethe 0:498a45e38bed 10 DigitalOut DO[4]={LED1, LED2, LED3, LED4};
seethe 0:498a45e38bed 11
seethe 0:498a45e38bed 12 void led_blink()
seethe 0:498a45e38bed 13 {
seethe 0:498a45e38bed 14 for(int n=0; n<4; n++){
seethe 0:498a45e38bed 15 DO[n] = !DO[n];
seethe 0:498a45e38bed 16 }
seethe 0:498a45e38bed 17 }
seethe 0:498a45e38bed 18
seethe 0:498a45e38bed 19 int main() {
seethe 0:498a45e38bed 20 double cnt;
seethe 0:498a45e38bed 21 cnt = 0.1;
seethe 0:498a45e38bed 22 while(1){
seethe 0:498a45e38bed 23 lcd.printf("Hello World!_%.1f\n", cnt);
seethe 0:498a45e38bed 24 //lcd.printf("...\n");
seethe 0:498a45e38bed 25 led_blink();
seethe 0:498a45e38bed 26 wait(cnt);
seethe 0:498a45e38bed 27 lcd.printf("xxxxxxxxxxxx\n");
seethe 0:498a45e38bed 28 lcd.printf("...\n");
seethe 0:498a45e38bed 29 led_blink();
seethe 0:498a45e38bed 30 wait(cnt);
seethe 0:498a45e38bed 31 cnt+=0.1;
seethe 0:498a45e38bed 32 if(cnt>=1.0) cnt = 0.1;
seethe 0:498a45e38bed 33 }
seethe 0:498a45e38bed 34 }