Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of TextLCD_HelloWorld by
main.cpp
00001 // Hello World! for the TextLCD 00002 00003 #include "mbed.h" 00004 #include "TextLCD.h" 00005 00006 TextLCD lcd(p9, p10, p11, p12, p13, p14); // rs, e, d4-d7 00007 AnalogIn voltage(p15); 00008 DigitalOut A(LED1); 00009 DigitalOut B(LED2); 00010 DigitalOut C(LED3); 00011 DigitalOut D(LED4); 00012 int main() 00013 { 00014 float x; 00015 while (1){ 00016 x=voltage.read(); 00017 lcd.printf(" voltage in real: %3.4f\n", voltage.read()); 00018 wait(1); 00019 lcd.printf("voltage in integer: %5d\n", voltage.read_u16()); 00020 wait(1); 00021 if(x<=0.2) 00022 { 00023 A=0; 00024 B=0; 00025 C=0; 00026 D=0; 00027 } 00028 else if(x>0.2 && x<=0.4) 00029 { 00030 A=1; 00031 B=0; 00032 C=0; 00033 D=0; 00034 } 00035 else if(x>0.4 && x<=0.6) 00036 { 00037 A=1; 00038 B=1; 00039 C=0; 00040 D=0; 00041 } 00042 else if(x>0.6 && x<=0.8) 00043 { 00044 A=1; 00045 B=1; 00046 C=1; 00047 D=0; 00048 } 00049 else if(x>0.8 && x<=1.0) 00050 { 00051 A=1; 00052 B=1; 00053 C=1; 00054 D=1; 00055 } 00056 } 00057 }
Generated on Sun Aug 21 2022 15:38:55 by
1.7.2
