bdw am bad
#include <LiquidCrystal.h>
LiquidCrystal lcd(11, 12, 2, 3, 4, 5);
int multy = A0; // potentiometer output.
int heat = 0; // i set up a int to compared desired temperature.
int sensorPin = A1; // termostat output.
void setup() {
pinMode(8, INPUT);
pinMode(9, INPUT);
pinMode(7, OUTPUT);
lcd.begin(16, 2); // set up cld.
Serial.begin(2400);
lcd.print("Hello world"); // make sure cld is working.
delay(1000);
lcd.clear();
// rust is good.
}
void loop() {
int button1 = (digitalRead(9)); // set up push buttons.
int button2 = (digitalRead(8));
int multyrn = digitalRead(multy);
int sensorVal = analogRead(sensorPin);
float volt = (sensorVal / 1024.0) * 5.0; // i turn voltage into Celsius from termostat.
float temp1 = (volt - .5) * 100; // I want to average out temp1 / time.
int temp2 = (temp1 + multyrn); // I want to calibrate output with a potentiometer because my Voltage is to high for my temp sensor.
if ( button1 >= 1) { // I check if I want to increase heat.
heat = heat + 1;
}
if (button2 >= 1) { // I check if I want to decreases heat.
heat = heat - 1;
}
if (heat < temp1) {
analogWrite(7, HIGH); // Check the desired temperature + room temp to check if I need to turn on heat.
}
lcd.print("temp rn:"); // I start to print att values to a lcd.
lcd.setCursor(8, 0);
lcd.print(temp1);
lcd.setCursor(0, 1);
lcd.print("heat to:");
lcd.setCursor(8, 1);
lcd.print(heat);
lcd.setCursor(0, 0); // i stop.
Serial.print(",pin 9:"); // Serial print in stuf for diagnosis.
Serial.print(button1);
Serial.print(",pin 8:");
Serial.print(button2);
Serial.print(",heat to:");
Serial.print(heat);
Serial.print(",volt:");
Serial.print(volt);
Serial.print(",temp:");
Serial.println(temp2);
delay(1000);
}