Hi all,
I am using aruino uno.
I am using a code i found online which is used to make an LCD display read the temperature which the temperature sensor detects. The LED's display too, how hot or cold it is by using three levels of below X degrees C, above Y degrees C and in between. The piezo beeps if it is at one of these levels (i think above Y).
However, the Problem:
The LCD screen does not display text or the temperature read, rather, it just lights up.
Here is the code and circuit:
Any Help would be really appreciated!!
Ps. i need to get this done today, thank you.
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
int sensorPin = 0;
float tempC;
void setup() {
pinMode(7, OUTPUT);
pinMode(8, OUTPUT);
pinMode(13, OUTPUT);
pinMode(9, INPUT);
lcd.begin(16, 2);
}
void loop() {
tempC = get_temperature(sensorPin);
lcd.setCursor(0,0);
lcd.print("Temperature: ");
lcd.setCursor(0,1);
lcd.print (tempC, 1); lcd.print(" "); lcd.print("C");
delay(200);
if (tempC <= 16){
digitalWrite(8, HIGH);
digitalWrite(7, LOW);
digitalWrite(13, LOW);
noTone(9);
}
else if (tempC > 36){
digitalWrite(7, LOW);
digitalWrite(8, LOW);
digitalWrite(13, HIGH);
tone(9, 700, 250);
delay(2000);
}
else {
digitalWrite(7, HIGH);
digitalWrite(8, LOW);
digitalWrite(13, LOW);
noTone(9);
}
}
float get_temperature(int pin) {
float temperature = analogRead(pin);
float voltage = temperature * 5.0;
voltage = voltage / 1024.0;
return ((voltage - 0.5) * 100);
}
Thanks.