V2

Dependencies:   C12832 mbed

Fork of app-board-LCD by Chris Styles

Committer:
chenniges
Date:
Tue Oct 09 10:52:39 2018 +0000
Revision:
4:e0b82f12f958
Parent:
3:2db94ee076ee
V2

Who changed what in which revision?

UserRevisionLine numberNew contents of line
dreschpe 0:f6a57b843f79 1 #include "mbed.h"
chris 3:2db94ee076ee 2 #include "C12832.h"
dreschpe 0:f6a57b843f79 3
chris 3:2db94ee076ee 4
chris 3:2db94ee076ee 5 C12832 lcd(p5, p7, p6, p8, p11);
dreschpe 1:1c6a9eaf55b5 6
chenniges 4:e0b82f12f958 7 /*int main()
dreschpe 0:f6a57b843f79 8 {
chris 2:a87e255a8f3a 9 int j=0;
chris 2:a87e255a8f3a 10 lcd.cls();
chris 2:a87e255a8f3a 11 lcd.locate(0,3);
chris 2:a87e255a8f3a 12 lcd.printf("mbed application board!");
dreschpe 0:f6a57b843f79 13
chenniges 4:e0b82f12f958 14 while(true)
chenniges 4:e0b82f12f958 15 { // this is the third thread
chris 2:a87e255a8f3a 16 lcd.locate(0,15);
chris 2:a87e255a8f3a 17 lcd.printf("Counting : %d",j);
chris 2:a87e255a8f3a 18 j++;
chris 2:a87e255a8f3a 19 wait(1.0);
dreschpe 0:f6a57b843f79 20 }
chenniges 4:e0b82f12f958 21 }*/
chenniges 4:e0b82f12f958 22
chenniges 4:e0b82f12f958 23
chenniges 4:e0b82f12f958 24 int main()
chenniges 4:e0b82f12f958 25 {
chenniges 4:e0b82f12f958 26 int n1=0; //number of 1p coins
chenniges 4:e0b82f12f958 27 float a1=0; //amount of 1p coins
chenniges 4:e0b82f12f958 28 //...
chenniges 4:e0b82f12f958 29 float ta=0; //total amount of all coins
chenniges 4:e0b82f12f958 30 int c=0; //counting variable
chenniges 4:e0b82f12f958 31 //float tm; // token money
chenniges 4:e0b82f12f958 32
chenniges 4:e0b82f12f958 33 /* for(;;)
chenniges 4:e0b82f12f958 34 {
chenniges 4:e0b82f12f958 35 if(LDR1 == 1)
chenniges 4:e0b82f12f958 36 {
chenniges 4:e0b82f12f958 37 a1++;
chenniges 4:e0b82f12f958 38 n1 = a1*0.01;
chenniges 4:e0b82f12f958 39 //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
chenniges 4:e0b82f12f958 40 //why is LED1 = 0; a failure?
chenniges 4:e0b82f12f958 41 c = 0;
chenniges 4:e0b82f12f958 42 }
chenniges 4:e0b82f12f958 43 //... other types of coins
chenniges 4:e0b82f12f958 44 c++;
chenniges 4:e0b82f12f958 45 if (c >= 100)//depands how long the programm per cycle needs
chenniges 4:e0b82f12f958 46 {
chenniges 4:e0b82f12f958 47 break;
chenniges 4:e0b82f12f958 48 }
chenniges 4:e0b82f12f958 49 } */
chenniges 4:e0b82f12f958 50 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
chenniges 4:e0b82f12f958 51 wait(5);
chenniges 4:e0b82f12f958 52 lcd.cls();
chenniges 4:e0b82f12f958 53 //doing these things for the other coins as well
chenniges 4:e0b82f12f958 54
chenniges 4:e0b82f12f958 55 //ta = n1+n2+n5+n10+n20+n50+n100+n200;
chenniges 4:e0b82f12f958 56 lcd.locate(0,0);
chenniges 4:e0b82f12f958 57 lcd.printf("Your total amount is %d",ta);
chenniges 4:e0b82f12f958 58 wait(5);
chenniges 4:e0b82f12f958 59 lcd.cls();
chenniges 4:e0b82f12f958 60
chenniges 4:e0b82f12f958 61 /*if() //press button or something like that
chenniges 4:e0b82f12f958 62 {
chenniges 4:e0b82f12f958 63 lcd.printf("Please enter the mount of money you took:");
chenniges 4:e0b82f12f958 64 scanf("%f",&tm);
chenniges 4:e0b82f12f958 65 lcd.printf("%f",tm);
chenniges 4:e0b82f12f958 66 wait(2);
chenniges 4:e0b82f12f958 67 ta = ta-tm;
chenniges 4:e0b82f12f958 68 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
chenniges 4:e0b82f12f958 69 }*/
chenniges 4:e0b82f12f958 70
chenniges 4:e0b82f12f958 71 return(0);
dreschpe 0:f6a57b843f79 72 }