Temperature display on LCD 16X2 using LM35

Dependencies:   TextLCD mbed

Fork of 1_On_board_LED_with_lib by Harish Mekali

Files at this revision

API Documentation at this revision

Comitter:
Lakshmikumar
Date:
Wed Nov 12 12:35:12 2014 +0000
Parent:
0:58d7f2487d66
Commit message:
Temperature Display on LCD using LM35

Changed in this revision

TextLCD.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r 58d7f2487d66 -r bc0c3c69d797 TextLCD.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TextLCD.lib	Wed Nov 12 12:35:12 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/simon/code/TextLCD/#308d188a2d3a
diff -r 58d7f2487d66 -r bc0c3c69d797 main.cpp
--- 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