Temperature sensing using LM35 sensor and Arduino microcontroller

This project is done by using LM35 sensor , Arduino Nano ,16×2 display

#include <LiquidCrystal.h>

LiquidCrystal lcd(3, 4, 5, 6, 7, 8);//pin connection of LCD

int sensor = A1;//output pin of lm35
float tempc,tempf;
void setup()
{
  lcd.begin(16, 2);
  pinMode(sensor, INPUT);
  lcd.clear();
  lcd.setCursor(0,0);
  lcd.print("temperature");
}

void loop()
{
  float result = 0;
  int i;
  for (i = 1; i <= 3000; i++)
  {
    tempc = analogRead(sensor);
    tempc = (tempc * 500.0) / 1024.0;
    result = (result * (i - 1) + tempc) / i;
  }
  lcd.setCursor(0, 1);
  lcd.print("C=");
  lcd.print(result);
  lcd.print(" F=");
  tempf=(((9*tempc)/5)+32);
  lcd.print(tempf);
  lcd.print("               ");
  delay(1000);
}

Post a Comment

0 Comments