final form

Dependencies:   mbed C12832

Revision:
3:c9057d642843
Parent:
2:c95f08525bea
Child:
4:67766287a6a0
diff -r c95f08525bea -r c9057d642843 main.cpp
--- a/main.cpp	Tue Oct 23 09:49:35 2018 +0000
+++ b/main.cpp	Tue Oct 23 12:00:45 2018 +0000
@@ -9,8 +9,8 @@
 DigitalIn LDR6(p15);  //50p
 DigitalIn LDR7(p16);  //1GBP
 DigitalIn LDR8(p17);  //2GBP //I don't know the mistake 
-AnalogIn button1(p18);
-AnalogIn button2(p19);
+DigitalIn switch1(p18);
+//AnalogIn button2(p19);
 
 C12832 lcd(p5, p7, p6, p8, p11);
 
@@ -49,7 +49,7 @@
     
     for(;;)
     {
-       if(t > 8)
+       if(t > 1)
        {
            break;
        }
@@ -139,7 +139,7 @@
        
        ta = a[0]+a[1]+a[2]+a[3]+a[4]+a[5]+a[6]+a[7];
        lcd.locate(0,0);
-       lcd.printf("Your total amount is %d %c",ta,char(163));
+       lcd.printf("Your total value is %d %c.",ta,char(163));
        wait(5);
        lcd.cls();
        
@@ -148,7 +148,7 @@
        lcd.cls();
        lcd.printf("Confirm your choice by using the switch.");
        wait(3);
-       
+       lcd.cls();
        /*switch (buttons)
        {
            case button1:    an = an+1;
@@ -158,12 +158,13 @@
                             }
                             lcd.cls();
                             lcd.printf("Do you want to see the number of %d coins?",v[an]);
+                            break;
            case button2:    lcd.printf("You have %d of this type of coins. \nThat means you have %f£ of this type of coin.",n[an],a[an]); //it doesn't know button1 and button2 yet
                             break;
        }*/
-       while(1)
+       do
        {
-           if (button1 == 1)
+           if (switch1 == 1)
            {
                an++;
                if (an > 8)
@@ -175,16 +176,33 @@
                wait(3);
                //button1 = 0;
            }
-           if (button2 == 1)
+           else
            {
                lcd.printf("You have %d of this type of coins. \nThat means you have %f %c of this type of coin.",n[an],a[an],char(163)); //it doesn't know button1 and button2 yet
-               break;
+               wait(5);
+               lcd.cls();
+               lcd.printf("If you would like to see other \ntypes of coins as well, please \nuse switch again.");
+               wait(5);
+               lcd.cls();
            }
        }
-       wait(5);
-       lcd.cls();
-       lcd.printf("Thank you for using 'Coounting Machine'. \nGood Bye. :-)");
-       wait(5);
+       while(switch1 == 1);
+       //wait(5);
+       //lcd.cls();
+       
+       
+       lcd.printf("Please use the switch for finishing process.");
+       wait(4);
+       do
+       {
+           if(switch1 == 1)
+           {
+               lcd.cls();
+               lcd.printf("Thank you for using 'Coounting Machine'. \nGood Bye. :-)");
+               wait(5);
+               lcd.cls();
+           }
+       }while (switch1 == 0);
        /*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.
        {
            lcd.printf("Please enter the mount of money you took:");
@@ -197,3 +215,4 @@
        
     return(0);
 }
+//change all 1 to 0 at LDR1,2,...
\ No newline at end of file