temp

Dependencies:   TextLCD mbed

Fork of LM35 by Gautam Gare

Committer:
keerthivasan
Date:
Thu Aug 20 09:24:17 2015 +0000
Revision:
1:eb9898cde584
Parent:
0:aed747a24dcd
temp sen

Who changed what in which revision?

UserRevisionLine numberNew contents of line
GRG 0:aed747a24dcd 1 #include "mbed.h"
GRG 0:aed747a24dcd 2 #include "TextLCD.h"
GRG 0:aed747a24dcd 3
GRG 0:aed747a24dcd 4 AnalogIn LM35(p15);
GRG 0:aed747a24dcd 5
keerthivasan 1:eb9898cde584 6 TextLCD lcd(p15,p16,p17,p18,p19,p20);
GRG 0:aed747a24dcd 7
GRG 0:aed747a24dcd 8 int main()
GRG 0:aed747a24dcd 9 {
GRG 0:aed747a24dcd 10 float tempC,tempF,a[10],avg;
GRG 0:aed747a24dcd 11 int i;
GRG 0:aed747a24dcd 12
GRG 0:aed747a24dcd 13 while(1)
GRG 0:aed747a24dcd 14 {
GRG 0:aed747a24dcd 15
GRG 0:aed747a24dcd 16 avg=0;
GRG 0:aed747a24dcd 17 for(i=0;i<10;i++)
GRG 0:aed747a24dcd 18 {
GRG 0:aed747a24dcd 19 a[i]=LM35.read();
GRG 0:aed747a24dcd 20 wait(.02);
GRG 0:aed747a24dcd 21 }
GRG 0:aed747a24dcd 22 for(i=0;i<10;i++)
GRG 0:aed747a24dcd 23 {
GRG 0:aed747a24dcd 24 avg=avg+(a[i]/10);
GRG 0:aed747a24dcd 25 }
GRG 0:aed747a24dcd 26
GRG 0:aed747a24dcd 27
GRG 0:aed747a24dcd 28 tempC=(avg*3.685503686*100);
GRG 0:aed747a24dcd 29 tempF=(9.0*tempC)/5.0 + 32.0;
GRG 0:aed747a24dcd 30 lcd.locate(0,0);
GRG 0:aed747a24dcd 31 lcd.printf(" Temperature ");
GRG 0:aed747a24dcd 32 lcd.locate(0,1);
GRG 0:aed747a24dcd 33 lcd.printf("%.2f C %.2f F",tempC,tempF);
GRG 0:aed747a24dcd 34
GRG 0:aed747a24dcd 35 wait(.5);
GRG 0:aed747a24dcd 36 }
GRG 0:aed747a24dcd 37 }