parth shah / Mbed 2 deprecated mbed_eclm35

Dependencies:   TextLCD mbed

main.cpp

Committer:
parth1100
Date:
2015-06-15
Revision:
0:1e4bca77e18e

File content as of revision 0:1e4bca77e18e:

#include "mbed.h"
#include "TextLCD.h"
#include "stdio.h"
AnalogIn ain(PTC2);
TextLCD lcd(PTA1,PTA2,PTD4,PTA12,PTA4,PTA5,TextLCD::LCD16x2); 
DigitalOut ground(PTC9);
char buff[15]={'\0'};

int main()
{
    ground=0;
    lcd.cls();
    while(1)
    {
       float temp[70]={0},volt[100]={0};//arrey for temp & vltg
       int i=0, j=0;

        for(i=0;i<100;i++)
        {
            volt[i]=ain*3.3; 
        }
         for(i=0;i<70;i++)
         {
            float avg = 0.0; //initialise avg
            
            for(j=i;j<(i+20);j++) //taking first  20 reading
            {
                avg = avg +volt[j];
            }       
            avg = avg/20.0; //taking avg of 20 readings 
        temp[i] = avg*100.0; // calibrating temp with 10mV / degree C
         }  
         //initialization of lcd
     lcd.cls();
     for(i=0;i<70;i++)
     {
         lcd.locate(0,0);
         lcd.printf("Vtg:");
         lcd.locate(7,0);
         sprintf(buff,"%.2f",volt[i]);
         lcd.printf(buff);
         lcd.locate(0,1);
         lcd.printf("Temp:");
         sprintf(buff,"%.2f",temp[i]);
         lcd.printf(buff);
         wait(0.5);
    }
    }
}