UoD_ME30001_Group_2_08
/
Counting_Machine_V2
V2
Fork of app-board-LCD by
Revision 4:e0b82f12f958, committed 2018-10-09
- Comitter:
- chenniges
- Date:
- Tue Oct 09 10:52:39 2018 +0000
- Parent:
- 3:2db94ee076ee
- Commit message:
- V2
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r 2db94ee076ee -r e0b82f12f958 main.cpp --- a/main.cpp Wed Feb 05 15:32:38 2014 +0000 +++ b/main.cpp Tue Oct 09 10:52:39 2018 +0000 @@ -4,17 +4,69 @@ C12832 lcd(p5, p7, p6, p8, p11); -int main() +/*int main() { int j=0; lcd.cls(); lcd.locate(0,3); lcd.printf("mbed application board!"); - while(true) { // this is the third thread + while(true) + { // this is the third thread lcd.locate(0,15); lcd.printf("Counting : %d",j); j++; wait(1.0); } +}*/ + + +int main() +{ + int n1=0; //number of 1p coins + float a1=0; //amount of 1p coins + //... + float ta=0; //total amount of all coins + int c=0; //counting variable + //float tm; // token money + + /* for(;;) + { + if(LDR1 == 1) + { + a1++; + n1 = a1*0.01; + //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; + } + //... other types of coins + c++; + if (c >= 100)//depands how long the programm per cycle needs + { + break; + } + } */ + lcd.printf("You have %d coins of 1p \nwhich means you have %d$*ps",a1,n1); // 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 + + //ta = n1+n2+n5+n10+n20+n50+n100+n200; + lcd.locate(0,0); + lcd.printf("Your total amount is %d",ta); + wait(5); + lcd.cls(); + + /*if() //press button or something like that + { + lcd.printf("Please enter the mount of money you took:"); + scanf("%f",&tm); + lcd.printf("%f",tm); + wait(2); + ta = ta-tm; + lcd.printf("Now you have only %f \bx156 left", ta); //\b for one step backword and I guess that x156 for £ //I'm not sure + }*/ + + return(0); }