vmh

Dependencies:   mbed

Revision:
1:b4814760d8ee
Parent:
0:4562b55bbb43
diff -r 4562b55bbb43 -r b4814760d8ee main.cpp
--- a/main.cpp	Mon Dec 11 08:43:44 2017 +0000
+++ b/main.cpp	Mon Dec 11 20:25:27 2017 +0000
@@ -14,6 +14,8 @@
 int main(void)
 {
     int ch;
+    int ch2;
+    int roll;
     int x=0;
     int x0=0;
     int x1=0;
@@ -24,7 +26,8 @@
     int x6=0;
     int x7=0;
     int x8=0;
-    int amount =0;
+    int state = 0;
+    int amount =1;
     int stateprint1 = 0;
     int stateprint2 = 0;
     int stateprint3 = 0;
@@ -59,7 +62,14 @@
   uint8_t pic7[8] = {0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80};*/
   
   
-  
+  uint8_t st1[8] = {0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00};  // ติด1ดวง
+  uint8_t st2[8] = {0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00}; // ติด 2 ดวง
+  uint8_t st3[8] = {0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00};
+  uint8_t st4[8] = {0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00};
+  uint8_t st5[8] = {0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00};
+  uint8_t st6[8] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0x00};
+  uint8_t st7[8] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00};
+  uint8_t st8[8] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
   
   
   
@@ -122,221 +132,304 @@
      do{
         if(bt.readable()){
             ch=bt.getc();
-            pc.printf("%d\n",ch);
-        }
-        if ((ch <=15 and ch >=0) or x==1){
+            ch2=bt.getc();
+            roll=bt.getc();
+            
+            pc.printf("CH1:%d\n",ch);
+            pc.printf("CH2:%d\n",ch2);
+            pc.printf("roll:%d\n",roll);
+        
+        if (((ch <=15 and ch >=0)and(ch2 <=15 and ch2 >=0)and (roll>=0 and roll<=10)) or x==1){
             if (stateprint1 == 0){
                 pc.printf("   pass step1   ");
                 lcd.cls();
                 lcd.printf("   pass step1   ");
                 stateprint1 =1;
             }
-            
-            dotmatrix.display_pic(one,green);
-            dotmatrix.display_pic(step1,green);
-//            
-//                                if (amount==0){
-//                                    pc.printf("   amount %d   ",amount);
-//                                    lcd.cls();
-//                                    lcd.printf("   amount %d   ",amount);             
-//                                    dotmatrix.display_pic(one,green);
-//                                    dotmatrix.display_pic(step1,green);
-//                                } 
-//                                     
-//                                if (amount==1){
-//                                    pc.printf("   amount %d   ",amount);
-//                                    lcd.cls();
-//                                    lcd.printf("   amount %d   ",amount);      
-//                                    dotmatrix.display_pic(two,green);
-//                                    dotmatrix.display_pic(step1,green);
-//                                    
-//                                } 
-//                                
-//                                if (amount==2){
-//                                    pc.printf("   amount %d   ",amount);
-//                                    lcd.cls();
-//                                    lcd.printf("   amount %d   ",amount);      
-//                                    dotmatrix.display_pic(three,green);
-//                                    dotmatrix.display_pic(step1,green);
-//                                    
-//                                }
-//                                 
-//                                if (amount==3){
-//                                    pc.printf("   amount %d   ",amount);
-//                                    lcd.cls();
-//                                    lcd.printf("   amount %d   ",amount);      
-//                                    dotmatrix.display_pic(four,green);
-//                                    dotmatrix.display_pic(step1,green);
-//                                    
-//                                } 
-//                                
-//                                if (amount==4){
-//                                    pc.printf("   amount %d   ",amount);
-//                                    lcd.cls();
-//                                    lcd.printf("   amount %d   ",amount);      
-//                                    dotmatrix.display_pic(five,green);
-//                                    dotmatrix.display_pic(step1,green);
-//                                    
-//                                } 
-//                                
-//                                if (amount==5){
-//                                    pc.printf("   amount %d   ",amount);
-//                                    lcd.cls();
-//                                    lcd.printf("   amount %d   ",amount);      
-//                                    dotmatrix.display_pic(six,green);
-//                                    dotmatrix.display_pic(step1,green);
-//                                    
-//                                } 
-//                                
-//                                if (amount==6){
-//                                    pc.printf("   amount %d   ",amount);
-//                                    lcd.cls();
-//                                    lcd.printf("   amount %d   ",amount);      
-//                                    dotmatrix.display_pic(seven,green);
-//                                    dotmatrix.display_pic(step1,green);
-//                                    
-//                                } 
-//                                
-//                                if (amount==7){
-//                                    pc.printf("   amount %d   ",amount);
-//                                    lcd.cls();
-//                                    lcd.printf("   amount %d   ",amount);      
-//                                    dotmatrix.display_pic(eight,green);
-//                                    dotmatrix.display_pic(step1,green);
-//                                    
-//                                } 
-//                                
-//                                if (amount==8){
-//                                    pc.printf("   amount %d   ",amount);
-//                                    lcd.cls();
-//                                    lcd.printf("   amount %d   ",amount);      
-//                                    dotmatrix.display_pic(nine,green);
-//                                    dotmatrix.display_pic(step1,green);
-//                                    
-//                                } 
-//                                
-//                                if (amount==9){
-//                                    pc.printf("   amount %d   ",amount);
-//                                    lcd.cls();
-//                                    lcd.printf("   amount %d   ",amount);      
-//                                    dotmatrix.display_pic(ten,green);
-//                                    dotmatrix.display_pic(step1,green);
-//                                    
-//                                }             
+                
+            if(amount==1)
+           {        
+            for (int i = 1; i <= 40; i++){        
+              dotmatrix.display_pic(step1,green);
+              dotmatrix.display_pic(one,green);}
+            }
+            if(amount==2)
+           {        
+                       for (int i = 1; i <= 40; i++){        
+
+              dotmatrix.display_pic(step1,green);
+              dotmatrix.display_pic(two,green);}
+              }
+            if(amount==3)
+           {        
+                       for (int i = 1; i <= 40; i++){        
+
+              dotmatrix.display_pic(step1,green);
+              dotmatrix.display_pic(three,green);}
+            }
+
+            if(amount==4)
+           {        
+                       for (int i = 1; i <= 40; i++){        
+
+                dotmatrix.display_pic(step1,green);
+                dotmatrix.display_pic(four,green);}}
+
+            if(amount==5)
+           {                  
+                for (int i = 1; i <= 40; i++){        
+                dotmatrix.display_pic(step1,green);
+                dotmatrix.display_pic(five,green);} }         
+
+            if(amount==6)
+           {      
+                for (int i = 1; i <= 40; i++){        
+                dotmatrix.display_pic(step1,green);
+                dotmatrix.display_pic(six,green);}}  
+            if(amount==7)
+           {      
+            for (int i = 1; i <= 40; i++){        
+                dotmatrix.display_pic(step1,green);
+                dotmatrix.display_pic(seven,green);}}
+            if(amount==8)
+           {      
+            for (int i = 1; i <= 40; i++){        
+                dotmatrix.display_pic(step1,green);
+                dotmatrix.display_pic(eight,green);} }
+            if(amount==9)
+           {      
+            for (int i = 1; i <= 40; i++){        
+                dotmatrix.display_pic(step1,green);
+                dotmatrix.display_pic(nine,green);} }
+            if(amount==10)
+           {      
+            for (int i = 1; i <= 40; i++){        
+                dotmatrix.display_pic(step1,green);
+                dotmatrix.display_pic(ten,green);}}
+            if(amount==11)
+           {      
+                       for (int i = 1; i <= 40; i++){        
+                dotmatrix.display_pic(step1,green);
+                dotmatrix.display_pic(eleven,green);}}
+            if(amount==12)
+           {      
+            for (int i = 1; i <= 40; i++){        
+                dotmatrix.display_pic(step1,green);
+                dotmatrix.display_pic(twelve,green);} }
+            if(amount==13)
+           {                  for (int i = 1; i <= 40; i++){        
+
+                dotmatrix.display_pic(step1,green);
+                dotmatrix.display_pic(thirteen,green);} }
+            if(amount==14)
+           {      
+            for (int i = 1; i <= 40; i++){        
+                dotmatrix.display_pic(step1,green);
+                dotmatrix.display_pic(fourteen,green);}
+                }
+            if(amount==15)
+           {      
+            for (int i = 1; i <= 40; i++){        
+                dotmatrix.display_pic(step1,green);
+                dotmatrix.display_pic(fifteen,green);}}
+
+  
                                 x=1;
-            if((ch <=30 and ch >=16) or x2==1){
+                                state=1;
+                        
+//*******************************************************************************************************************step2
+
+            if(((ch <=30 and ch >=16)and(ch2 <=30 and ch2 >=16)and (roll>=0 and roll<=10)) or x2==1){
                 if (stateprint2 == 0){
                     pc.printf("   pass step2   ");
                     lcd.cls();
                     lcd.printf("   pass step2   ");
                     stateprint2 =1;
-                }
-//                                if (amount==0){
-//                                    pc.printf("   amount %d   ",amount);
-//                                    lcd.cls();
-//                                    lcd.printf("   amount %d   ",amount);             
-//                                    dotmatrix.display_pic(one,green);
-//                                    dotmatrix.display_pic(step1,green);
-//                                } 
-//                                     
-//                                else if (amount==1){
-//                                    pc.printf("   amount %d   ",amount);
-//                                    lcd.cls();
-//                                    lcd.printf("   amount %d   ",amount);      
-//                                    dotmatrix.display_pic(two,green);
-//                                    dotmatrix.display_pic(step1,green);
-//                                    
-//                                } 
-//                                
-//                                else if (amount==2){
-//                                    pc.printf("   amount %d   ",amount);
-//                                    lcd.cls();
-//                                    lcd.printf("   amount %d   ",amount);      
-//                                    dotmatrix.display_pic(three,green);
-//                                    dotmatrix.display_pic(step1,green);
-//                                    
-//                                }
-//                                 
-//                                else if (amount==3){
-//                                    pc.printf("   amount %d   ",amount);
-//                                    lcd.cls();
-//                                    lcd.printf("   amount %d   ",amount);      
-//                                    dotmatrix.display_pic(four,green);
-//                                    dotmatrix.display_pic(step1,green);
-//                                    
-//                                } 
-//                                
-//                                else if (amount==4){
-//                                    pc.printf("   amount %d   ",amount);
-//                                    lcd.cls();
-//                                    lcd.printf("   amount %d   ",amount);      
-//                                    dotmatrix.display_pic(five,green);
-//                                    dotmatrix.display_pic(step1,green);
-//                                    
-//                                } 
-//                                
-//                                else if (amount==5){
-//                                    pc.printf("   amount %d   ",amount);
-//                                    lcd.cls();
-//                                    lcd.printf("   amount %d   ",amount);      
-//                                    dotmatrix.display_pic(six,green);
-//                                    dotmatrix.display_pic(step1,green);
-//                                    
-//                                } 
-//                                
-//                                else if (amount==6){
-//                                    pc.printf("   amount %d   ",amount);
-//                                    lcd.cls();
-//                                    lcd.printf("   amount %d   ",amount);      
-//                                    dotmatrix.display_pic(seven,green);
-//                                    dotmatrix.display_pic(step1,green);
-//                                    
-//                                } 
-//                                
-//                                else if (amount==7){
-//                                    pc.printf("   amount %d   ",amount);
-//                                    lcd.cls();
-//                                    lcd.printf("   amount %d   ",amount);      
-//                                    dotmatrix.display_pic(eight,green);
-//                                    dotmatrix.display_pic(step1,green);
-//                                    
-//                                } 
-//                                
-//                                else if (amount==8){
-//                                    pc.printf("   amount %d   ",amount);
-//                                    lcd.cls();
-//                                    lcd.printf("   amount %d   ",amount);      
-//                                    dotmatrix.display_pic(nine,green);
-//                                    dotmatrix.display_pic(step1,green);
-//                                    
-//                                } 
-//                                
-//                                else if (amount==9){
-//                                    pc.printf("   amount %d   ",amount);
-//                                    lcd.cls();
-//                                    lcd.printf("   amount %d   ",amount);      
-//                                    dotmatrix.display_pic(ten,green);
-//                                    dotmatrix.display_pic(step1,green);
-//                                    
-//                                }   
-                dotmatrix.display_pic(one,green);
+                }  
+            if(amount==1)
+           {        
+            for (int i = 1; i <= 40; i++){        
+
+              dotmatrix.display_pic(step2,green);
+              dotmatrix.display_pic(one,green);}
+}
+            if(amount==2)
+           {        
+            for (int i = 1; i <= 40; i++){        
+              dotmatrix.display_pic(step2,green);
+              dotmatrix.display_pic(two,green);}}
+
+            if(amount==3)
+           {        
+            for (int i = 1; i <= 40; i++){        
+              dotmatrix.display_pic(step2,green);
+              dotmatrix.display_pic(three,green);}}
+
+
+
+            if(amount==4)
+           {        
+                       for (int i = 1; i <= 40; i++){        
+                dotmatrix.display_pic(step2,green);
+                dotmatrix.display_pic(four,green);}}
+
+            if(amount==5)
+           {      
+                       for (int i = 1; i <= 40; i++){        
+                dotmatrix.display_pic(step2,green);
+                dotmatrix.display_pic(five,green);}     }     
+
+            if(amount==6)
+           {      
+                       for (int i = 1; i <= 40; i++){        
+                dotmatrix.display_pic(step2,green);
+                dotmatrix.display_pic(six,green);}  }
+
+            if(amount==7)
+           {      
+                       for (int i = 1; i <= 40; i++){        
                 dotmatrix.display_pic(step2,green);
+                dotmatrix.display_pic(seven,green);}}
+            if(amount==8)
+           {      
+                       for (int i = 1; i <= 40; i++){        
+                dotmatrix.display_pic(step2,green);
+                dotmatrix.display_pic(eight,green);} }
+            if(amount==9)
+           {      
+                       for (int i = 1; i <= 40; i++){        
+                dotmatrix.display_pic(step2,green);
+                dotmatrix.display_pic(nine,green);} }
+            if(amount==10)
+           {      
+                       for (int i = 1; i <= 40; i++){        
+                dotmatrix.display_pic(step2,green);
+                dotmatrix.display_pic(ten,green);}}
+            if(amount==11)
+           {      
+                       for (int i = 1; i <= 40; i++){        
+                dotmatrix.display_pic(step2,green);
+                dotmatrix.display_pic(eleven,green);}}
+            if(amount==12)
+           {      
+            for (int i = 1; i <= 40; i++){        
+                dotmatrix.display_pic(step2,green);
+                dotmatrix.display_pic(twelve,green);} }
+            if(amount==13)
+           {      
+            for (int i = 1; i <= 40; i++){        
+                dotmatrix.display_pic(step2,green);
+                dotmatrix.display_pic(thirteen,green);} }
+            if(amount==14)
+           {      
+            for (int i = 1; i <= 40; i++){        
+                dotmatrix.display_pic(step2,green);
+                dotmatrix.display_pic(fourteen,green);}}
+            if(amount==15)
+           {      
+            for (int i = 1; i <= 40; i++){        
+                dotmatrix.display_pic(step2,green);
+                dotmatrix.display_pic(fifteen,green);}}
                 x2=1;
-                if((ch <=45 and ch >=31) or x3==1)
+//                state=2;
+                
+//****************************************************************************************************************************    
+            
+                if(((ch <=45 and ch >=31)and(ch2 <=45 and ch2 >=31)and (roll>=0 and roll<=10)) or x3==1)
                     {
                     if (stateprint3 == 0){
                         pc.printf("   pass step3   ");
                         lcd.cls();
                         lcd.printf("   pass step3   ");
-                        stateprint3 =1;
-                        //dotmatrix.display_pic(one,green);
-//                        dotmatrix.display_pic(step3,green);
+                        stateprint3 =1;}
+
+            if(amount==1)
+           {        
+            for (int i = 1; i <= 30; i++){        
+
+              dotmatrix.display_pic(step3,green);
+              dotmatrix.display_pic(one,green);}}
+}
+            if(amount==2)
+           {        
+            for (int i = 1; i <= 30; i++){        
+
+              dotmatrix.display_pic(step3,green);
+              dotmatrix.display_pic(two,green);}}
+
+            if(amount==3)
+           {        
+            for (int i = 1; i <= 30; i++){        
+              dotmatrix.display_pic(step3,green);
+              dotmatrix.display_pic(three,green);}}
+            if(amount==4)
+           {        
+            for (int i = 1; i <= 30; i++){        
+                dotmatrix.display_pic(step3,green);
+                dotmatrix.display_pic(four,green);}}
+
+            if(amount==5)
+           {      
+            for (int i = 1; i <= 30; i++){        
+                dotmatrix.display_pic(step3,green);
+                dotmatrix.display_pic(five,green);}}          
 
-                    }
-                    dotmatrix.display_pic(one,green);
-                    dotmatrix.display_pic(step3,green);
+            if(amount==6)
+           {      
+            for (int i = 1; i <= 30; i++){        
+                dotmatrix.display_pic(step3,green);
+                dotmatrix.display_pic(six,green);}  }
+            if(amount==7)
+           {      
+            for (int i = 1; i <= 30; i++){        
+                dotmatrix.display_pic(step3,green);
+                dotmatrix.display_pic(seven,green);}}
+            if(amount==8)
+           {      
+            for (int i = 1; i <= 30; i++){        
+                dotmatrix.display_pic(step3,green);
+                dotmatrix.display_pic(eight,green);} }
+            if(amount==9)
+           {      
+            for (int i = 1; i <= 30; i++){        
+                dotmatrix.display_pic(step3,green);
+                dotmatrix.display_pic(nine,green);} }
+            if(amount==10)
+           {      
+                for (int i = 1; i <= 30; i++){        
+                dotmatrix.display_pic(step3,green);
+                dotmatrix.display_pic(ten,green);}}
+            if(amount==11)
+           {      
+            for (int i = 1; i <= 30; i++){        
+                dotmatrix.display_pic(step3,green);
+                dotmatrix.display_pic(eleven,green);}}
+            if(amount==12)
+           {      
+            for (int i = 1; i <= 30; i++){        
+                dotmatrix.display_pic(step3,green);
+                dotmatrix.display_pic(twelve,green);} }
+            if(amount==13)
+           {      
+            for (int i = 1; i <= 30; i++){        
+                dotmatrix.display_pic(step3,green);
+                dotmatrix.display_pic(thirteen,green);} }
+            if(amount==14)
+           {      
+            for (int i = 1; i <= 30; i++){        
+                dotmatrix.display_pic(step3,green);
+                dotmatrix.display_pic(fourteen,green);}}
+            if(amount==15)
+           {      
+            for (int i = 1; i <= 30; i++){        
+                dotmatrix.display_pic(step3,green);
+                dotmatrix.display_pic(fifteen,green);}  }            
+
                     x3=1;
-                    if((ch <=60 and ch >=46) or x4==1)
+//                    state=3;
+//***********************************************************************************************************************
+                    
+                    if(((ch <=60 and ch >=46)and(ch2 <=60 and ch2 >=46)and (roll>=0 and roll<=10)) or x4==1)
                         {
                         if (stateprint4 == 0){
                             pc.printf("   pass step4   ");
@@ -345,21 +438,189 @@
                             stateprint4 =1;
                                             
                         }
-                        dotmatrix.display_pic(one,green);
-                        dotmatrix.display_pic(step4,green);
-                        x4=1;
-                        if((ch <=75 and ch >=61) or x5==1){
+
+            if(amount==1)
+           {        
+            for (int i = 1; i <= 30; i++){        
+
+              dotmatrix.display_pic(step4,green);
+              dotmatrix.display_pic(one,green);}
+}
+
+            if(amount==2)
+           {        
+            for (int i = 1; i <= 30; i++){        
+              dotmatrix.display_pic(step4,green);
+              dotmatrix.display_pic(two,green);}}
+
+            if(amount==3)
+           {        
+            for (int i = 1; i <= 30; i++){        
+              dotmatrix.display_pic(step4,green);
+              dotmatrix.display_pic(three,green);}}
+
+            if(amount==4)
+           {        
+            for (int i = 1; i <= 30; i++){        
+                dotmatrix.display_pic(step4,green);
+                dotmatrix.display_pic(four,green);}}
+
+            if(amount==5)
+           {      
+            for (int i = 1; i <= 30; i++){        
+                dotmatrix.display_pic(step4,green);
+                dotmatrix.display_pic(five,green);} }         
+
+            if(amount==6)
+           {      
+            for (int i = 1; i <= 30; i++){        
+                dotmatrix.display_pic(step4,green);
+                dotmatrix.display_pic(six,green);}}  
+            if(amount==7)
+           {      
+            for (int i = 1; i <= 30; i++){        
+                dotmatrix.display_pic(step4,green);
+                dotmatrix.display_pic(seven,green);}}
+            if(amount==8)
+           {      
+            for (int i = 1; i <= 30; i++){        
+                dotmatrix.display_pic(step4,green);
+                dotmatrix.display_pic(eight,green);} }
+            if(amount==9)
+           {      
+            for (int i = 1; i <= 30; i++){        
+                dotmatrix.display_pic(step4,green);
+                dotmatrix.display_pic(nine,green);} }
+            if(amount==10)
+           {      
+            for (int i = 1; i <= 30; i++){        
+                dotmatrix.display_pic(step4,green);
+                dotmatrix.display_pic(ten,green);}}
+            if(amount==11)
+           {      
+            for (int i = 1; i <= 30; i++){        
+                dotmatrix.display_pic(step4,green);
+                dotmatrix.display_pic(eleven,green);}}
+            if(amount==12)
+           {      
+            for (int i = 1; i <= 30; i++){        
+                dotmatrix.display_pic(step4,green);
+                dotmatrix.display_pic(twelve,green);} }
+            if(amount==13)
+           {      
+            for (int i = 1; i <= 30; i++){        
+                dotmatrix.display_pic(step4,green);
+                dotmatrix.display_pic(thirteen,green);} }
+            if(amount==14)
+           {      
+            for (int i = 1; i <= 30; i++){        
+                dotmatrix.display_pic(step4,green);
+                dotmatrix.display_pic(fourteen,green);}}
+            if(amount==15)
+           {      
+            for (int i = 1; i <= 30; i++){        
+                dotmatrix.display_pic(step4,green);
+                dotmatrix.display_pic(fifteen,green);}}
+                                        x4=1;
+//                        state=4;
+                        
+ //********************************************************************************************************************                       
+                        
+                        if(((ch <=75 and ch >=61)and(ch2 <=75 and ch2 >=61)and (roll>=0 and roll<=10)) or x5==1){
                             if (stateprint5 == 0){
                                 pc.printf("   pass step5   ");
                                 lcd.cls();
                                 lcd.printf("   pass step5   ");
                                 stateprint5 =1;
-        
                             }
-                            dotmatrix.display_pic(one,green);
-                            dotmatrix.display_pic(step5,green);
-                            x5=1;
-                        if((ch <=90 and ch >=76) or x6==1){
+                       if(amount==1)
+           {        
+            for (int i = 1; i <= 30; i++){        
+
+              dotmatrix.display_pic(step5,green);
+              dotmatrix.display_pic(one,green);}}
+            if(amount==2)
+           {        
+            for (int i = 1; i <= 30; i++){        
+              dotmatrix.display_pic(step5,green);
+              dotmatrix.display_pic(two,green);}}
+
+            if(amount==3)
+           {        
+            for (int i = 1; i <= 30; i++){        
+              dotmatrix.display_pic(step5,green);
+              dotmatrix.display_pic(three,green);}}
+
+            if(amount==4)
+           {        
+            for (int i = 1; i <= 30; i++){        
+
+                dotmatrix.display_pic(step5,green);
+                dotmatrix.display_pic(four,green);}}
+
+            if(amount==5)
+           {      
+            for (int i = 1; i <= 30; i++){        
+                dotmatrix.display_pic(step5,green);
+                dotmatrix.display_pic(five,green);}}       
+
+            if(amount==6)
+           {      
+            for (int i = 1; i <= 30; i++){        
+                dotmatrix.display_pic(step5,green);
+                dotmatrix.display_pic(six,green);}}
+                            
+            if(amount==7)
+           {      
+            for (int i = 1; i <= 30; i++){        
+                dotmatrix.display_pic(step5,green);
+                dotmatrix.display_pic(seven,green);}}
+            if(amount==8)
+           {      
+            for (int i = 1; i <= 30; i++){        
+                dotmatrix.display_pic(step5,green);
+                dotmatrix.display_pic(eight,green);}}
+            if(amount==9)
+           {      
+            for (int i = 1; i <= 30; i++){        
+                dotmatrix.display_pic(step5,green);
+                dotmatrix.display_pic(nine,green);}}
+            if(amount==10)
+           {      
+            for (int i = 1; i <= 30; i++){        
+                dotmatrix.display_pic(step5,green);
+                dotmatrix.display_pic(ten,green);}}
+            if(amount==11)
+           {     
+            for (int i = 1; i <= 30; i++){        
+
+                dotmatrix.display_pic(step5,green);
+                dotmatrix.display_pic(eleven,green);}}
+            if(amount==12)
+           {      
+            for (int i = 1; i <= 30; i++){        
+                dotmatrix.display_pic(step5,green);
+                dotmatrix.display_pic(twelve,green);}} 
+            if(amount==13)
+           {      
+            for (int i = 1; i <= 30; i++){        
+                dotmatrix.display_pic(step5,green);
+                dotmatrix.display_pic(thirteen,green);}} 
+            if(amount==14)
+           {      
+            for (int i = 1; i <= 30; i++){        
+                dotmatrix.display_pic(step5,green);
+                dotmatrix.display_pic(fourteen,green);}}
+            if(amount==15)
+           {      
+            for (int i = 1; i <= 30; i++){        
+                dotmatrix.display_pic(step5,green);
+                dotmatrix.display_pic(fifteen,green);}}
+                x5=1;
+//                            state=5;
+//***************************************************************************************************************
+                            
+                        if(((ch <=90 and ch >=76)and(ch2 <=90 and ch2 >=76)and (roll>=0 and roll<=10)) or x6==1){
                                 if (stateprint6 == 0){
                                     pc.printf("   pass step6   ");
                                     lcd.cls();
@@ -367,14 +628,91 @@
                                     stateprint6 =1;
             
                                 }
-                                for (int i = 1; i <= 230; i++)
-                                        {        
-                                    
-                                dotmatrix.display_pic(one,green);
-                                dotmatrix.display_pic(step6,green);
-                                
-                                }
+                        if(amount==1)
+           {        
+            for (int i = 1; i <= 30; i++){        
+              dotmatrix.display_pic(step6,green);
+              dotmatrix.display_pic(one,green);}
+}
+
+            if(amount==2)
+           {        
+            for (int i = 1; i <= 30; i++){        
+              dotmatrix.display_pic(step6,green);
+              dotmatrix.display_pic(two,green);}}
+
+            if(amount==3)
+           {        
+            for (int i = 1; i <= 30; i++){        
+              dotmatrix.display_pic(step6,green);
+              dotmatrix.display_pic(three,green);}}
+
+
+
+            if(amount==4)
+           {        
+            for (int i = 1; i <= 30; i++){        
+                dotmatrix.display_pic(step6,green);
+                dotmatrix.display_pic(four,green);}}
+
+            if(amount==5)
+           {      
+            for (int i = 1; i <= 30; i++){        
+                dotmatrix.display_pic(step6,green);
+                dotmatrix.display_pic(five,green);}}         
+
+            if(amount==6)
+           {      
+            for (int i = 1; i <= 30; i++){        
+                dotmatrix.display_pic(step6,green);
+                dotmatrix.display_pic(six,green);}}  
+            if(amount==7)
+           {      
+            for (int i = 1; i <= 30; i++){        
+                dotmatrix.display_pic(step6,green);
+                dotmatrix.display_pic(seven,green);}}
+            if(amount==8)
+           {      
+            for (int i = 1; i <= 30; i++){        
+                dotmatrix.display_pic(step6,green);
+                dotmatrix.display_pic(eight,green);}} 
+            if(amount==9)
+           {      
+            for (int i = 1; i <= 30; i++){        
+                dotmatrix.display_pic(step6,green);
+                dotmatrix.display_pic(nine,green);}}
+            if(amount==10)
+           {      
+            for (int i = 1; i <= 30; i++){        
+                dotmatrix.display_pic(step6,green);
+                dotmatrix.display_pic(ten,green);}}
+            if(amount==11)
+           {      
+            for (int i = 1; i <= 30; i++){        
+                dotmatrix.display_pic(step6,green);
+                dotmatrix.display_pic(eleven,green);}}
+            if(amount==12)
+           {      
+            for (int i = 1; i <= 30; i++){        
+                dotmatrix.display_pic(step6,green);
+                dotmatrix.display_pic(twelve,green);}} 
+            if(amount==13)
+           {      
+            for (int i = 1; i <= 30; i++){        
+                dotmatrix.display_pic(step6,green);
+                dotmatrix.display_pic(thirteen,green);}} 
+            if(amount==14)
+           {      
+            for (int i = 1; i <= 30; i++){        
+                dotmatrix.display_pic(step6,green);
+                dotmatrix.display_pic(fourteen,green);}}
+            if(amount==15)
+           {      
+            for (int i = 1; i <= 30; i++){        
+                dotmatrix.display_pic(step6,green);
+                dotmatrix.display_pic(fifteen,green);}}
                                 x6=1;
+//                                state=6;
                                 amount=amount+1;
                                 pc.printf("   amount %d   ",amount);       
                                 if (amount==1){
@@ -391,7 +729,7 @@
                                     pc.printf("   amount %d   ",amount);
                                     lcd.cls();
                                     lcd.printf("   amount %d   ",amount);      
-                                    for (int i = 1; i <= 500; i++){        
+                                    for (int i = 1; i <= 230; i++){        
                                         dotmatrix.display_pic(two,green);
                                     }
                                 } 
@@ -400,7 +738,7 @@
                                     pc.printf("   amount %d   ",amount);
                                     lcd.cls();
                                     lcd.printf("   amount %d   ",amount);      
-                                    for (int i = 1; i <= 500; i++){        
+                                    for (int i = 1; i <= 230; i++){        
                                         dotmatrix.display_pic(three,green);
                                     }
                                 }
@@ -409,7 +747,7 @@
                                     pc.printf("   amount %d   ",amount);
                                     lcd.cls();
                                     lcd.printf("   amount %d   ",amount);      
-                                    for (int i = 1; i <= 500; i++){        
+                                    for (int i = 1; i <= 230; i++){        
                                         dotmatrix.display_pic(four,green);
                                     }
                                 } 
@@ -418,7 +756,7 @@
                                     pc.printf("   amount %d   ",amount);
                                     lcd.cls();
                                     lcd.printf("   amount %d   ",amount);      
-                                    for (int i = 1; i <= 500; i++){        
+                                    for (int i = 1; i <= 230; i++){        
                                         dotmatrix.display_pic(five,green);
                                     }
                                 } 
@@ -427,7 +765,7 @@
                                     pc.printf("   amount %d   ",amount);
                                     lcd.cls();
                                     lcd.printf("   amount %d   ",amount);      
-                                    for (int i = 1; i <= 500; i++){        
+                                    for (int i = 1; i <= 230; i++){        
                                         dotmatrix.display_pic(six,green);
                                     }
                                 } 
@@ -436,7 +774,7 @@
                                     pc.printf("   amount %d   ",amount);
                                     lcd.cls();
                                     lcd.printf("   amount %d   ",amount);      
-                                    for (int i = 1; i <= 500; i++){        
+                                    for (int i = 1; i <= 230; i++){        
                                         dotmatrix.display_pic(seven,green);
                                     }
                                 } 
@@ -445,7 +783,7 @@
                                     pc.printf("   amount %d   ",amount);
                                     lcd.cls();
                                     lcd.printf("   amount %d   ",amount);      
-                                    for (int i = 1; i <= 500; i++){        
+                                    for (int i = 1; i <= 230; i++){        
                                         dotmatrix.display_pic(eight,green);
                                     }
                                 } 
@@ -454,7 +792,7 @@
                                     pc.printf("   amount %d   ",amount);
                                     lcd.cls();
                                     lcd.printf("   amount %d   ",amount);      
-                                    for (int i = 1; i <= 500; i++){        
+                                    for (int i = 1; i <= 230; i++){        
                                         dotmatrix.display_pic(nine,green);
                                     }
                                 } 
@@ -463,7 +801,7 @@
                                     pc.printf("   amount %d   ",amount);
                                     lcd.cls();
                                     lcd.printf("   amount %d   ",amount);      
-                                    for (int i = 1; i <= 500; i++){        
+                                    for (int i = 1; i <= 230; i++){        
                                         dotmatrix.display_pic(ten,green);
                                     }
                                 } 
@@ -472,10 +810,12 @@
                                     pc.printf("   amount %d   ",amount);
                                     lcd.cls();
                                     lcd.printf("   amount %d   ",amount);      
-                                    for (int i = 1; i <= 500; i++){        
+                                    for (int i = 1; i <= 230; i++){        
                                         dotmatrix.display_pic(two,green);
                                     }
-                                } 
+                                 
+                                
+                                }//6
                                 x=0;
                                 x1=0;
                                 x2=0;
@@ -488,12 +828,15 @@
                                 stateprint3 = 0;
                                 stateprint4 = 0;
                                 stateprint5 = 0;
-                            }
-                        }
-                    }
-                }
-            }
-        }  
-        }while(amount != 10);
+                                state=0;
+                                }//5
+                            }//4
+                        }//3
+                    }//2
+                }//1
+                                
+            }//รับค่า
+          
+        }while(amount != 15);
                         pc.printf("yeahhhhhhh");
-}
\ No newline at end of file
+}//main
\ No newline at end of file