#include <runningAvg.h>
#include <mapper.h>

runningAvg  smoother(10);
mapper      analogToV(0,1023,0,5.0);  // From Arduinoland..
mapper      voltToTempC(0,1.5,0,150); // From the LM35 datasheet.

void setup() {

  Serial.begin(9600);
}


void loop() {
  
  int   rawVal;
  float smoothed;
  float volts;
  float tempC;

  rawVal = analogRead(A0);              // Read the ananlog pin.
  smoothed = smoother.addData(rawVal);  // Pop the reading into the running average object.
  volts = analogToV.map(smoothed);      // Convert the smoothed result into a Voltage.
  tempC = voltToTempC.map(volts);       // Convert the Voltage reading into a temp.
  Serial.print(tempC);                  // And show it to Mrs user.
  Serial.println("\tDeg C");
}