NUR BAHIRAH MUHAMAD @ ABD RAHMAN / Mbed 2 deprecated ADC_TEST

Dependencies:   TextLCD mbed

main.cpp

Committer:
Bahirah
Date:
2018-05-24
Revision:
0:a00fb5d3f693

File content as of revision 0:a00fb5d3f693:


#include "mbed.h"
#include "TextLCD.h"

TextLCD lcd(D8, D9, D4, D5, D6, D7);
Serial pc(USBTX, USBRX);
AnalogIn Ain(PC_3);
DigitalIn pb (PA_12);
float ADCdata;

int main() {
    lcd.cls();
    lcd.locate(1,0);
    lcd.printf ("Temp Measure");

            while (1) 
            {   
                ADCdata=Ain;
                ADCdata=ADCdata*100;
                
                
                if (pb == 0)
                {
                    lcd.locate (0,1);
                    lcd.printf ("Cel:");
            
                    lcd.locate (4,1);
                    lcd.printf ("%2.2f", ADCdata);
                    
                }
                else if (pb == 1)
                {   
                
                    lcd.locate (8,1);
                    lcd.printf ("Fah:", ADCdata);
                    
                    lcd.locate (12,1);
                    lcd.printf ("%2.2f", ADCdata);
                    
                }
                wait (0.5);
            }
            }