
V1
Diff: main.cpp
- Revision:
- 0:d9d4f644fecc
- Child:
- 1:bf8737118d3d
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Tue Oct 09 09:34:04 2018 +0000 @@ -0,0 +1,60 @@ +#include "mbed.h" +#include "C12832.h" + +DigitalIn LDR1(p8); //1p +DigitalIn LDR2(p9); //2p +DigitalIn LDR3(p10); //5p +DigitalIn LDR4(p11); //10p +DigitalIn LDR5(p12); //20p +DigitalIn LDR6(p13); //50p +DigitalIn LDR7(p14); //1GBP +DigitalIn LDR8(p15); //2GBP //I don't know the mistake + +C12832 lcd(p5,p6,p7,p8) + +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); +} \ No newline at end of file