Skip to content

Instantly share code, notes, and snippets.

@buildcircuit
Created March 13, 2013 18:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save buildcircuit/5154711 to your computer and use it in GitHub Desktop.
Save buildcircuit/5154711 to your computer and use it in GitHub Desktop.
LM35 temperature sensor
/*
LM35 Thermometer
*
*LM35 simpy connected to: 5+
* 0V
* Analog Pin 5
www.circuit-blog.com
*/
#include <LiquidCrystal.h>
int potPin = 5; //input read pin for LM35 is Analog Pin 5
int temperature = 0; //variable which will be calculated in process
long val=0; //variable to store the value coming from the sensor
LiquidCrystal lcd(7, 6, 5, 4, 3, 2);
void setup()
{
lcd.begin(16, 2);
Serial.begin(9600);
Serial.println("LM35 Thermometer ");
lcd.print("Thermometer ");
}
void loop () //loop below process
{
val = analogRead(potPin); //read the value of sensor
temperature = (5*val*100/1024); //convert voltage to temperature
Serial.println ((float)temperature);
//print temperature value on serial screen
lcd.setCursor(0,1);
lcd.print((float)temperature);
lcd.setCursor(3,1);
lcd.print("D.Centigrade");
Serial.println("D.Centigrade");
delay(2000); //wait for 2seconds
} //End of process, go back to start of loop - ie check temp...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment