final form

Dependencies:   mbed C12832

Revision:
2:c95f08525bea
Parent:
1:fa25df63b18f
Child:
3:c9057d642843
--- a/main.cpp	Tue Oct 16 10:24:05 2018 +0000
+++ b/main.cpp	Tue Oct 23 09:49:35 2018 +0000
@@ -42,68 +42,89 @@
     //float tm; // token money 
     //int buttons; //one for selection of coins, one for confirming and programm ending
     int an = 0;//number in which of the arrays we are
-    
-            time_t start, end;      //time counting
+    Timer t;
+            /*time_t start, end;      //time counting
             double elapsed;  // seconds
-            start = time(NULL);
+            start = time(NULL);*/
     
     for(;;)
     {
+       if(t > 8)
+       {
+           break;
+       }
+       
        if(LDR1 == 1)//we could also use switch-case here for every diode
        {
         n[0]++;
         a[0] = n[0]*v[0];
+        t.reset();
+        t.start();
         //wait(0.2); //I don't know if the programm would count a coin twice when we reset the LED immediately because the programm runs faster than the coins fall 
         //why is LED1 = 0; a failure?
         //c = 0;
-        time(0);
+        //time(0);
        }
             
-            
-   
+           
+   /*
      end = time(NULL);
      elapsed = difftime(end, start);
-     if (elapsed >= 8.0 /* seconds */)
+     if (elapsed >= 8.0)//seconds
        {
            break;
        }
-       
+     */  
        
-       /*if(LDR2 == 1)
+       if(LDR2 == 1)
        {
         n[1]++;
         a[1] = n[1]*v[1];
+        t.reset();
+        t.start();
        }
        if(LDR3 == 1)
        {
         n[2]++;
         a[2] = n[2]*v[2];
+        t.reset();
+        t.start();
        }
        if(LDR4 == 1)
        {
         n[3]++;
         a[3] = n[3]*v[3];
+        t.reset();
+        t.start();
        }
        if(LDR5 == 1)
        {
         n[4]++;
         a[4] = n[4]*v[4];
+        t.reset();
+        t.start();
        }
        if(LDR6 == 1)
        {
         n[5]++;
         a[5] = n[5]*v[5];
+        t.reset();
+        t.start();
        }
        if(LDR7 == 1)
        {
         n[6]++;
         a[6] = n[6]*v[6];
+        t.reset();
+        t.start();
        }
        if(LDR8 == 1)
        {
         n[7]++;
         a[7] = n[7]*v[7];
-       }*/
+        t.reset();
+        t.start();
+       }
        //... other types of coins
        /*c++;
        if (c >= 100)//depands how long the programm per cycle needs
@@ -111,10 +132,10 @@
            break;
        }*/ 
     } 
-       lcd.printf("You have %d coins of 1p \nwhich means you have %f$*ps",n[0],a[0]); // it looks like we have to use only printf and not lcd.printf
+       /*lcd.printf("You have %d coins of 1p \nwhich means you have %f$*ps",n[0],a[0]); // it looks like we have to use only printf and not lcd.printf
        wait(5);
        lcd.cls();
-       //doing these things for the other coins as well
+       //doing these things for the other coins as well*/
        
        ta = a[0]+a[1]+a[2]+a[3]+a[4]+a[5]+a[6]+a[7];
        lcd.locate(0,0);
@@ -122,10 +143,11 @@
        wait(5);
        lcd.cls();
        
-       lcd.printf("Please select witch number \nof coins you would like to see \nby pressing the button.");
+       lcd.printf("Please select witch number \nof coins you would like to see.");
        wait(5);
        lcd.cls();
-       lcd.printf("Please finish process than \nby using the Start-Stop button.");
+       lcd.printf("Confirm your choice by using the switch.");
+       wait(3);
        
        /*switch (buttons)
        {
@@ -150,6 +172,7 @@
                }
                lcd.cls();
                lcd.printf("Do you want to see the number of %d %c coins?",v[an],char(163));
+               wait(3);
                //button1 = 0;
            }
            if (button2 == 1)
@@ -160,7 +183,7 @@
        }
        wait(5);
        lcd.cls();
-       lcd.printf("Thank you for using 'Coounting Machine'. \nGood Bye.");
+       lcd.printf("Thank you for using 'Coounting Machine'. \nGood Bye. :-)");
        wait(5);
        /*if() //press button or something like that         //total amount which is left when the user took money and entered the amount of it in the machine.
        {