UoD_ME30001_Group_2_08
/
Counting_Machine_V1
V1
main.cpp
- Committer:
- chenniges
- Date:
- 2018-10-09
- Revision:
- 2:370f188e2590
- Parent:
- 1:bf8737118d3d
File content as of revision 2:370f188e2590:
#include "mbed.h" #include "C12832.h" DigitalIn LDR1(p9); //1p DigitalIn LDR2(p10); //2p DigitalIn LDR3(p12); //5p DigitalIn LDR4(p13); //10p DigitalIn LDR5(p14); //20p DigitalIn LDR6(p15); //50p DigitalIn LDR7(p16); //1GBP DigitalIn LDR8(p17); //2GBP //I don't know the mistake C12832 lcd(p5,p6,p7,p8,p11); int main() { int n1; //number of 1p coins float a1; //amount of 1p coins //... float ta; //total amount of all coins int c; //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 which means you have %d",a1,n1); // it looks like we have to use only printf and not lcd.printf wait(3); lcd.cls(); //doing these things for the other coins as well //ta = n1+n2+n5+n10+n20+n50+n100+n200; lcd.printf("Your total amount is %d",ta); wait(3); 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); }