NUR BAHIRAH MUHAMAD @ ABD RAHMAN / Mbed 2 deprecated ADC_TEST

Dependencies:   TextLCD mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 
00002 #include "mbed.h"
00003 #include "TextLCD.h"
00004 
00005 TextLCD lcd(D8, D9, D4, D5, D6, D7);
00006 Serial pc(USBTX, USBRX);
00007 AnalogIn Ain(PC_3);
00008 DigitalIn pb (PA_12);
00009 float ADCdata;
00010 
00011 int main() {
00012     lcd.cls();
00013     lcd.locate(1,0);
00014     lcd.printf ("Temp Measure");
00015 
00016             while (1) 
00017             {   
00018                 ADCdata=Ain;
00019                 ADCdata=ADCdata*100;
00020                 
00021                 
00022                 if (pb == 0)
00023                 {
00024                     lcd.locate (0,1);
00025                     lcd.printf ("Cel:");
00026             
00027                     lcd.locate (4,1);
00028                     lcd.printf ("%2.2f", ADCdata);
00029                     
00030                 }
00031                 else if (pb == 1)
00032                 {   
00033                 
00034                     lcd.locate (8,1);
00035                     lcd.printf ("Fah:", ADCdata);
00036                     
00037                     lcd.locate (12,1);
00038                     lcd.printf ("%2.2f", ADCdata);
00039                     
00040                 }
00041                 wait (0.5);
00042             }
00043             }