LCD 課題2 @アニメーション 周回数カウント

Dependencies:   TextLCD mbed

Revision:
1:8c27d4a7a04d
Parent:
0:5912664cbcc5
--- a/main.cpp	Fri Sep 30 02:08:26 2016 +0000
+++ b/main.cpp	Thu Oct 06 05:03:38 2016 +0000
@@ -1,48 +1,41 @@
 #include "mbed.h"
 #include "TextLCD.h"
 
-TextLCD lcd(D8,D10,D11,D12,D13,D14); // rs, e, d4, d5, d6, d7)
+TextLCD lcd(D8,D10,D11,D12,D13,D14); // rs, e, d4, d5, d6, d7)      //LCD出力設定
 int main(){
-    int cnt = 0;
-    while(1)
+    int cnt = 0;        //関数cntを定義
+    while(1)        //無限ループ
     {
-        lcd.cls();
-        int a = 0;
-        
-        
-        for(a = 0; a <= 13; a++)
+        lcd.cls();      //LCD表示初期化
+        int a = 0;      //関数aを定義
+
+        for(a = 0; a <= 13; a++)    //aの初期値0,aが13以下の間繰り返す,1周ごとに1足す
         {
-            lcd.locate(a,0);
-            lcd.puts("@");
-            lcd.locate(14,1);
-            lcd.putc((cnt/10) % 10 + '0');
-            lcd.putc((cnt/1)  % 10 + '0');
-            wait(0.2);
-            
+            lcd.locate(a,0);        //表示座標
+            lcd.puts("@");          //文字表示
+            lcd.locate(14,1);       //表示座標
+            lcd.putc((cnt/10) % 10 + '0');      //cntの10の位を表示
+            lcd.putc((cnt/1)  % 10 + '0');      //cntの1の位を表示
+            wait(0.2);      //0.2秒待つ
 
+            lcd.cls();      //LCD表示初期化    
+        }
+        for(a = 13; a >= 0; a--)    //aの初期値13,aが0以上の間繰り返す,1周ごとに1引く
+        {
+            lcd.locate(a,1);        //表示座標
+            lcd.puts("@");          //文字表示
+            lcd.locate(14,1);       //表示座標
+            lcd.putc((cnt/10) % 10 + '0');      //cntの10の位を表示
+            lcd.putc((cnt/1)  % 10 + '0');      //cntの1の位を表示
+            wait(0.2);      //0.2秒待つ
             
-            lcd.cls();                    
+            lcd.cls();      //LCD表示初期化
         }
-    
-        for(a = 13; a >= 0; a--)
+        cnt++;      //cntに1足す
+        if(cnt==100)        //cntが100になったら{}内実行
         {
-            lcd.locate(a,1);
-            lcd.puts("@");
-    
-            
-            lcd.locate(14,1);
-            lcd.putc((cnt/10) % 10 + '0');
-            lcd.putc((cnt/1)  % 10 + '0');
-            wait(0.2);
-            
-            lcd.cls();
-        }
-            cnt++;
-        if(cnt==100)
-        {
-            //wait(3.0);
-            cnt = 0;
+            cnt = 0;        //cntを初期化
         }
         
     }
-}
+}
\ No newline at end of file