Shunsaku Kume
/
spectrasymbol
kadai2
Embed:
(wiki syntax)
Show/hide line numbers
main.cpp
00001 #include "mbed.h" 00002 #include "TextLCD.h" 00003 00004 00005 TextLCD lcd(p24, p26, p27, p28, p29, p30); // rs, e, d4-d7 00006 AnalogIn ain(p15); 00007 00008 int main() { 00009 float adc, volts, mm; 00010 00011 while (1){ 00012 lcd.locate(0,0); 00013 adc = ain.read(); // read analog as a float 00014 volts = 1-adc ; // convert to volts 00015 mm = volts *100 ; 00016 lcd.printf("%8.3f mm\n", mm); 00017 00018 wait(0.05); // 20Hz update rate 00019 } 00020 }
Generated on Wed Aug 3 2022 15:25:36 by 1.7.2