mijimy_group / Mbed 2 deprecated exercise5_7

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 TextLCD lcd ( p26, p25, p24, p23, p22, p21 ) ; // rs, e, d4 d5, d6, d7
00004 AnalogIn Ain ( p17 ) ; 
00005 int percentage ; 
00006 float voltage;
00007 int main( ) 
00008 {   while(1) 
00009     {   percentage = Ain * 100 ; 
00010         lcd.locate ( 1 , 0 ); 
00011         lcd.printf("percentage:");
00012         lcd.printf ("%i" , percentage) ; 
00013         voltage= Ain*3.30-0.3;
00014         lcd.locate ( 1 , 1 ); 
00015         lcd.printf("Voltage: ");
00016         lcd.printf ("%.1f" , voltage) ; 
00017         lcd.printf(" V");
00018         wait(0.02) ; 
00019         lcd.cls( ) ; 
00020         } 
00021 }