Go Down

Topic: LCD temp display with smoothing (Read 590 times) previous topic - next topic


This is my first real project. Its a 16X2 lcd that displays the temperature in F and C. I used the TMP36 sensor and code from the Vilros Ultimate Starter kit and added code from the LCD tutorial. Just for fun I added the smoothing code from Simon Monk's "Programming Arduino Next Steps" in chapter 13. Took about 5 hrs total but it was time well spent. I will try to add the code and a picture.
Code: [Select]
//The circuit:
//* LCD RS pin to digital pin 12
//* LCD Enable pin to digital pin 11
//* LCD D4 pin to digital pin 5
//* LCD D5 pin to digital pin 4
//* LCD D6 pin to digital pin 3
//* LCD D7 pin to digital pin 2
//* LCD R/W pin to ground
//* 10K resistor:
//* ends to +5V and ground
//* wiper to LCD VO pin (pin 3)

// http://www.arduino.cc/en/Tutorial/LiquidCrystal
//Thanks to Simon Monk, read both beginner books several times to get this far.
// And Vilros Ultimate Starter Kit, money well spent.

#include <LiquidCrystal.h>// include the library code:

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
const int temperaturePin = 0;
const float alpha = 0.99;
float smoothedValue = .72;//number selected to bias temp to avg room temp

void setup() {

  lcd.begin(16, 2);  // set up the LCD's number of columns and rows:


void loop() {
  float degreesC, degreesF; 

  float newReading = analogRead(temperaturePin) *(0.004882814);
  smoothedValue = (alpha * smoothedValue) + ((1 - alpha) * newReading);
  degreesC = (smoothedValue - 0.5) * 100.0;
  degreesF = degreesC * (9.0/5.0) + 32.0;
  lcd.print("Current Temp:");// Print the top line title
  lcd.setCursor(0, 1);
  lcd.print("F ");
  lcd.print (" C ");



Take care all.

Go Up

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131