My name is Dylon J. and I making an arduino lcd thermostat. It's a basic 16x2 hd44780 hitachi driven lcd. I got it to display 70 or the current tempertaure in Fahrenheit. Also I got it to diplay set to and the temperature it supposed to cool my room doen to. The output when the temp goes goes the set temp it to pin 13 labelled as led as a test. But in the finally product will be a SSR (Solid State Rely). I wanted to control the set temp by 2 tactile switches to pins 7 and 6. swtch one is to go up one degree, and the other is down one degree. But a couple problems. Even if the settemp is at 25 degree C or 77 F, I go to warm it up but the led was light up when I first uploaded the sketch. I new to this arduino ide, and writing code. But can some one help?!?!?!
Here is the code:
/*
lm35 sketch
prints the temperature to LCD
*/
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
const int inPin = 0;
int led = 13;
int swtch1 = 7;
int swtch2 = 6;
float settemp;
void setup()
{
lcd.begin(16, 2);
pinMode (led,OUTPUT);
pinMode (swtch1, INPUT);
pinMode (swtch2, INPUT);
}
void loop()
{
int value = analogRead(inPin);
lcd.setCursor(0, 1);
float millivolts = (value / 1024.0) * 5000;
float celsius = millivolts / 10;
lcd.clear();
lcd.setCursor(0,0);
lcd.print((celsius * 9)/ 5 + 32);
lcd.print(" Fahrenheit");
float settemp = 25;
if
(value > settemp)
{digitalWrite (led,1);}
else
{
digitalWrite (led,0);
}
if
(swtch1,1)
{settemp + 1;}
else
{}
if
(swtch2,1)
{settemp - 1;}
lcd.setCursor (0,1);
lcd.print("set to ");
lcd.print (settemp);
delay(1000);
}
Remember this is the first time I even tried to write code, after some research. I'm still so clueless about somethings. Thanks for your help! If I get any:)
lcd_thermostat_project_2.ino (936 Bytes)