Sequence LEDs

Dependencies:   TextLCD mbed

Fork of Y_01 by Yoshiyuki Takahashi

Revision:
0:fbbd6271c1ac
Child:
1:80eb2d3e5974
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Wed Feb 12 00:21:39 2014 +0000
@@ -0,0 +1,39 @@
+// Hello World! for the TextLCD
+
+#include "mbed.h"
+#include "TextLCD.h"
+
+//TextLCD lcd(p15, p16, p17, p18, p19, p20); // rs, e, d4-d7
+TextLCD lcd(p24, p26, p27, p28, p29, p30); // rs, e, d4-d7
+
+
+DigitalOut DO[4]={LED1, LED2, LED3, LED4};
+int     nCnt;
+
+void led_blink()
+{
+    for(int n=0; n<4; n++){
+        if(n == nCnt)   DO[n] = 1;
+        else            DO[n] = 0;
+    }
+}
+
+int main() {
+    double  cnt;
+    nCnt = 0;
+    cnt = 0.1;
+    while(1){
+        lcd.printf("Hello World!_%d\n", nCnt);
+        //lcd.printf("...\n");
+        led_blink();
+        wait(cnt);
+        //lcd.printf("xxxxxxxxxxxx\n");
+        lcd.printf("...\n");
+        //led_blink();
+        wait(cnt);
+        //cnt+=0.1;
+        if(cnt>=1.0)  cnt = 0.1;
+        nCnt++;
+        if(nCnt > 3)   nCnt = 0;
+    }
+}