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.
main.cpp
00001 #include "mbed.h" 00002 #include "TextLCD.h" 00003 00004 TextLCD lcd(p24, p26, p27, p28, p29, p30); // rs, e, d4-d7 00005 AnalogIn ain(p15); 00006 DigitalOut myled1(LED1); 00007 DigitalOut myled2(LED2); 00008 DigitalOut myled3(LED3); 00009 DigitalOut myled4(LED4); 00010 int main() { 00011 float abc=0; 00012 00013 while (1){ 00014 abc=ain.read(); 00015 lcd.locate(0,0); 00016 abc*=10; 00017 lcd.printf("%8.3f cm\n", abc); 00018 if((int)(abc)%4==0) myled1=1; 00019 else myled1=0; 00020 if((int)(abc)%4==1) myled2=1; 00021 else myled2=0; 00022 if((int)(abc)%4==2) myled3=1; 00023 else myled3=0; 00024 if((int)(abc)%4==3) myled4=1; 00025 else myled4=0; 00026 wait(0.05); // 20Hz update rate 00027 } 00028 }
Generated on Fri Aug 5 2022 05:35:50 by
1.7.2