LCD Temperatuur
Embed:
(wiki syntax)
Show/hide line numbers
main.cpp
00001 #include "mbed.h" 00002 #include "TextLCD.h" 00003 00004 AnalogIn LM35(p20); 00005 00006 TextLCD lcd(p21,p22,p23,p24,p25,p26); 00007 00008 int main() 00009 { 00010 float tempC,tempF,a[10],avg; 00011 int i; 00012 00013 while(1) 00014 { 00015 00016 avg=0; 00017 for(i=0;i<10;i++) 00018 { 00019 a[i]=LM35.read(); 00020 wait(.02); 00021 } 00022 for(i=0;i<10;i++) 00023 { 00024 avg=avg+(a[i]/10); 00025 } 00026 00027 00028 tempC=(avg*3.685503686*100); 00029 tempF=(9.0*tempC)/5.0 + 32.0; 00030 lcd.locate(0,0); 00031 lcd.printf(" Temperature "); 00032 lcd.locate(0,1); 00033 lcd.printf("%.2f C %.2f F",tempC,tempF); 00034 00035 wait(.5); 00036 } 00037 }
Generated on Tue Jul 26 2022 15:05:57 by
1.7.2