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 AnalogIn in(p20); 00005 AnalogOut out(p18) ; 00006 TextLCD lcd(p24, p26, p27, p28, p29, p30) ; 00007 Ticker input; 00008 float now, old = 0.0 ; 00009 00010 void run(void); 00011 int main() { 00012 input.attach(&run,0.5); 00013 while(1) { 00014 00015 } 00016 } 00017 00018 void run(void) 00019 { 00020 float data; 00021 old = now ; 00022 now = in ; 00023 00024 data = (now +old)/2.0 ; 00025 lcd.locate(0,0) ; 00026 if (0.121 <= data && data <= 0.970){ 00027 float range = 25.33 * pow((data*3.3),-1.21); 00028 lcd.printf("Range: %4.1f[cm]",range) ; 00029 out = 0.5; 00030 }else{ 00031 lcd.printf("Range: ----[cm]"); 00032 out = 1.0; 00033 } 00034 }
Generated on Tue Jul 12 2022 18:46:25 by
1.7.2