sai charan sriram / Mbed 2 deprecated mbed355

Dependencies:   mbed TextLCD

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers temp.cpp Source File

temp.cpp

00001 #include "mbed.h"
00002 #include"TextLCD.h"
00003 
00004 AnalogIn LM35(p15);
00005 TextLCD lcd(p21,p22,p23,p24,p25,p26);
00006 
00007 int main()
00008  {
00009     float tempC, tempF, a[10],avg;
00010     int i;
00011     while(1)
00012      {
00013         avg=0;
00014         for(i=0;i<10;i++)
00015         {
00016             a[i] = LM35.read();
00017             wait(0.2);
00018             {
00019             avg=(avg+a[i]/10);
00020             }
00021             
00022             tempC = ((LM35*3.3)-0.600)*100.0;
00023              tempF = (9.0*tempC)/(5.0 + 32.0);
00024              lcd.locate(0,0);
00025              lcd.printf("temperature");
00026              lcd.locate(0,1);
00027              lcd.printf("%.2fC%.2fF",tempC,tempF);
00028              wait(0.5);
00029              }
00030              }
00031              }
00032