I have an arduino pro mini and I have attached a 16x2 character LCD and an LM35 analog temperature sensor. When I upload a sketch using only the sensor and send the readings to serial monitor, the readings are OK. When I upload a sketch that displays the readings to the LCD the readings are about 130°C in room temperature. Where is the problem and how can I solve it. Thanks in advance
Code with lcd:
#include <LiquidCrystal.h>
byte smiley[8] = {
B00000,
B01110,
B01010,
B01110,
B00000,
B00000,
B00000,
};
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
void setup() {
// set up the LCD's number of columns and rows:
lcd.createChar(0, smiley);
lcd.begin(16, 2);
analogReference(INTERNAL);
// Print a message to the LCD.
lcd.print(analogRead(0)/1024.0 * 500);
lcd.write(byte(0));
lcd.print("C");
lcd.setCursor(0, 2);
lcd.print("21");
lcd.write(byte(0));
lcd.print("C");
}
void loop() {
// Turn off the cursor:
lcd.print((analogRead(0)/1024.0)*500);
lcd.write(byte(0));
lcd.print("C");
lcd.setCursor(0, 2);
delay(5000);
lcd.clear();
}
Only sensor code:
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
Serial.println(analogRead(0)/1024.0*500);
delay(500);
}