g

Dependencies:   TextLCD mbed

Committer:
HisyamSulaiman
Date:
Thu May 24 04:17:28 2018 +0000
Revision:
0:9988b63235b3
huhu

Who changed what in which revision?

UserRevisionLine numberNew contents of line
HisyamSulaiman 0:9988b63235b3 1 #include "mbed.h"
HisyamSulaiman 0:9988b63235b3 2 #include "TextLCD.h"
HisyamSulaiman 0:9988b63235b3 3
HisyamSulaiman 0:9988b63235b3 4 TextLCD lcd(D8, D9, D4, D5, D6, D7);
HisyamSulaiman 0:9988b63235b3 5 DigitalIn button(PA_12);
HisyamSulaiman 0:9988b63235b3 6 Serial pc(USBTX, USBRX);
HisyamSulaiman 0:9988b63235b3 7 AnalogIn Ain(PC_3);
HisyamSulaiman 0:9988b63235b3 8 float ADCdata;
HisyamSulaiman 0:9988b63235b3 9
HisyamSulaiman 0:9988b63235b3 10 int main() {
HisyamSulaiman 0:9988b63235b3 11
HisyamSulaiman 0:9988b63235b3 12 lcd.locate (1,0);
HisyamSulaiman 0:9988b63235b3 13 lcd.printf("Celsius");
HisyamSulaiman 0:9988b63235b3 14
HisyamSulaiman 0:9988b63235b3 15
HisyamSulaiman 0:9988b63235b3 16 while(1) {
HisyamSulaiman 0:9988b63235b3 17 if (button==0){
HisyamSulaiman 0:9988b63235b3 18 ADCdata=Ain;
HisyamSulaiman 0:9988b63235b3 19 ADCdata=ADCdata*100;
HisyamSulaiman 0:9988b63235b3 20 lcd.locate (4,1);
HisyamSulaiman 0:9988b63235b3 21 lcd.printf("%f",ADCdata);
HisyamSulaiman 0:9988b63235b3 22 pc.printf("%f\n\r",ADCdata);
HisyamSulaiman 0:9988b63235b3 23 wait(0.5);}
HisyamSulaiman 0:9988b63235b3 24 else (button==1){
HisyamSulaiman 0:9988b63235b3 25 ADCdata=Ain;
HisyamSulaiman 0:9988b63235b3 26 ADCdata=ADCdata*100;
HisyamSulaiman 0:9988b63235b3 27 lcd.locate (12,1);
HisyamSulaiman 0:9988b63235b3 28 lcd.printf("%f",ADCdata);
HisyamSulaiman 0:9988b63235b3 29 pc.printf("%f\n\r",ADCdata);
HisyamSulaiman 0:9988b63235b3 30 wait(0.5);}
HisyamSulaiman 0:9988b63235b3 31 }
HisyamSulaiman 0:9988b63235b3 32 }