Temperature display on LCD 16X2 using LM35

Dependencies:   TextLCD mbed

Fork of 1_On_board_LED_with_lib by Harish Mekali

Revision:
1:bc0c3c69d797
Parent:
0:58d7f2487d66
--- a/main.cpp	Fri Oct 04 18:26:09 2013 +0000
+++ b/main.cpp	Wed Nov 12 12:35:12 2014 +0000
@@ -1,12 +1,32 @@
 #include "mbed.h"
+#include "TextLCD.h"
+
 
-DigitalOut myled(LED1); //Only onboard LED has name as LED1/2/3/4
+int i;
+
+AnalogIn LM35(p15);///////////LM35
+TextLCD lcd(p26,p25,p24,p23,p22,p21);//rs,e,d0-d3
 
-int main() {
-    while(1) {
-        myled = 1;
-        wait(0.2);
-        myled = 0;
-        wait(0.2);
+int main()
+{       while(1)
+       {
+        float tempC,a[11],avg;
+        avg=0;
+        for(i=10; i!=0; i--) 
+        {
+            a[i]=LM35.read();
+        }
+        for(i=10; i!=0; i--) 
+        {
+            avg=avg+(a[i]/10);
+        }
+        
+        tempC=(avg*3.18155037*100);//////equation for calculating temp in °C
+        lcd.cls();
+        lcd.locate(0,0);
+        lcd.printf("Temp %.2f'C",tempC);
+        wait(1);
+
+       
     }
-}
+}
\ No newline at end of file