#include <Wire.h>
#include <LCD.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE); // Addr, En, Rw, Rs, d4, d5, d6, d7, backlighpin, polarity AnalogReadSerial
/*
Reads an analog input on pin 0, prints the result to the Serial Monitor.
Graphical representation is available using Serial Plotter (Tools > Serial Plotter menu).
Attach the center pin of a potentiometer to pin A0, and the outside pins to +5V and ground.
This example code is in the public domain.
http://www.arduino.cc/en/Tutorial/AnalogReadSerial
*/
// the setup routine runs once when you press reset:
void setup() {
// initialize serial communication at 9600 bits per second:
Serial.begin(9600);
lcd.begin(16,2);
lcd.backlight();
lcd.setCursor(0, 0);
// lcd.print("Hello world!");
lcd.setCursor(0, 1);
// lcd.print("Row number: ");
lcd.setCursor(12, 1);
// lcd.print("2");
}
// the loop routine runs over and over again forever:
void loop() {
// read the input on analog pin 0:
int sensorValue = analogRead(A0);
int sensorValue1 = analogRead(A1);
int sensorValue2 = analogRead(A2);
float temp1 = sensorValue * (62.0/1023.0);
float temp2 = sensorValue1 * (62.0/1023.0);
float temp3 = sensorValue2 * (62.0/1023.0);
float average= (temp1+temp2+temp3);
float temp =(average/3);
// print out the value you read:
Serial.print("sensor =");
Serial.println(sensorValue);
Serial.print("temp =");
Serial.println(temp);
Serial.println( );
lcd.clear();
lcd.print("Temp = ");
lcd.print(temp);
lcd.print(" 0C");
delay(1000); // delay in between reads for stability
}
Comments