Syahir Ammar Sazely / Mbed 2 deprecated ADCexercise

Dependencies:   TextLCD mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 #include "TextLCD.h"
00003 
00004 TextLCD lcd(D8, D9, D4, D5, D6, D7);
00005 Serial pc(USBTX, USBRX);
00006 AnalogIn Ain(PC_3);
00007 float ADCdata;
00008 
00009 int main() {
00010 lcd.printf("LDR =");
00011    while (1)
00012    {    
00013     ADCdata=Ain;
00014     ADCdata=ADCdata*100;
00015     lcd.locate (4,1);
00016     lcd.printf("%f",ADCdata);
00017     pc.printf("%f \n\r",ADCdata);
00018     wait (0.5);
00019    }   
00020 }