/*
*/
// include the library code:
#include <LiquidCrystal.h>
// initialize the library by associating any needed LCD interface pin
// with the arduino pin number it is connected to
const int rs = 8, en = 9, d4 = 4, d5 = 5, d6 = 6, d7 = 7;
const int bojlersz = 10, kazansz = 11, alsosz = 12, felsosz = 13; // felso sz, also sz, kazan sz, kazan termosztat
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
int keyinputb,lastkeyinputb;
int keyinputf,lastkeyinputf;
int keyinputa,lastkeyinputa;
String key,lastkey;
char serinput;
String inputString = ""; // a String to hold incoming data
String outputString = "";
bool stringComplete = false; // whether the string is complete
void setup() {
key = "None ";
pinMode(A0, INPUT_PULLUP);
pinMode(A1, INPUT_PULLUP);
pinMode(A2, INPUT_PULLUP);
pinMode(13, OUTPUT);
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
Serial.begin(9600);
// reserve 64 bytes for the inputString:
inputString.reserve(64);
lcd.print("init...");
delay(1000);
}
void loop() {
// print the string when a newline arrives:
if (stringComplete) {
lcd.setCursor(0,0);
lcd.print(outputString);
lcd.print(" ");
// clear the string:
inputString = "";
stringComplete = false;
}
keyinputf=digitalRead(A1);
if (keyinputf != lastkeyinputf) { //felso kor termosztat
lcd.setCursor(1,0);
lastkeyinputf = keyinputf;
if (keyinputf == true) {
lcd.print("H");
digitalWrite(felsosz, LOW);
} else {
lcd.print("L");
digitalWrite(felsosz, HIGH);
}
}
keyinputa=digitalRead(A2);
if (keyinputa != lastkeyinputa) { //also kor termosztat
lcd.setCursor(2,0);
lastkeyinputa = keyinputa;
if (keyinputa == true) {
lcd.print("H");
digitalWrite(alsosz, LOW);
} else {
lcd.print("L");
digitalWrite(alsosz, HIGH);
}
}
keyinputb=digitalRead(A0);
if (keyinputb != lastkeyinputb) { //bojler termosztat
lastkeyinputb = keyinputb;
}
if (keyinputb == false) {
lcd.setCursor(0,0);
lcd.print("H");
digitalWrite(bojlersz, HIGH);
digitalWrite(kazansz, HIGH);
digitalWrite(felsosz, LOW);
digitalWrite(alsosz, LOW);
} else {
lcd.print("H");
digitalWrite(bojlersz, LOW);
digitalWrite(kazansz, LOW);
}
}
void serialEvent() {
while (Serial.available()) {
// get the new byte:
char inChar = (char)Serial.read();
// add it to the inputString:
inputString += inChar;
// if the incoming character is a newline, set a flag so the main loop can
// do something about it:
if (inChar == '\n') {
stringComplete = true;
}
}
}