Hello.
I'm new to programming and I can't understand why the DiferentH function can't increase and decrease diferentHi
Thanks in advance.
[#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
byte custom0[] = {
B00000,
B00100,
B00100,
B00100,
B11111,
B01110,
B00100,
B00000
};
byte custom1[] = {
B00000,
B00100,
B00100,
B00100,
B11111,
B01110,
B00100,
B00000
};
byte custom2[] = {
B00000,
B00000,
B00000,
B00000,
B00000,
B00000,
B00000,
B11111
};
byte custom3[] = {
B00000,
B00000,
B00000,
B00000,
B00000,
B00000,
B11111,
B11111
};
byte custom4[] = {
B00000,
B00000,
B00000,
B00000,
B00000,
B11111,
B11111,
B11111
};
byte custom5[] = {
B00000,
B00000,
B00000,
B00000,
B11111,
B11111,
B11111,
B11111
};
byte custom6[] = {
B00000,
B00000,
B00000,
B11111,
B11111,
B11111,
B11111,
B11111
};
byte custom7[] = {
B00000,
B00000,
B11111,
B11111,
B11111,
B11111,
B11111,
B11111
};
byte custom8[] = {
B00000,
B11111,
B11111,
B11111,
B11111,
B11111,
B11111,
B11111
};
byte custom9[] = {
B11111,
B11111,
B11111,
B11111,
B11111,
B11111,
B11111,
B11111
}; byte custom10[] = {
B00000,
B00000,
B00000,
B00000,
B00000,
B00000,
B00000,
B00000
};
byte custom11[] = {
B01110,
B01010,
B01110,
B00000,
B00000,
B00000,
B00000,
B00000
};
float solar = A0;
float boiler = A1;
float bufer = A2;
//const int plus = A4;
//const int menu = A5;
//const int minus = A6;
#define SolarToBoiler 10
#define BuferToBoiler 9
#define SolarToBufer 8
int state1 = 0;
int state2 = 0;
int state3 = 0;
/*LCD RS pin to digital pin 12
LCD Enable pin to digital pin 11
LCD D4 pin to digital pin 5
LCD D5 pin to digital pin 4
LCD D6 pin to digital pin 3
LCD D7 pin to digital pin 2*/
int diferentHi = 4;
int diferentLo = 2;
void setup() {
// put your setup code here, to run once:
lcd.createChar(0, custom0);
lcd.createChar(1, custom1);
lcd.createChar(2, custom2);
lcd.createChar(3, custom3);
lcd.createChar(4, custom4);
lcd.createChar(5, custom5);
lcd.createChar(6, custom6);
lcd.createChar(7, custom7);
lcd.createChar(8, custom8);
lcd.createChar(9, custom9);
lcd.createChar(10, custom10);
lcd.createChar(11, custom11);
pinMode(A4, INPUT);
pinMode(A5, INPUT);
pinMode(A6, INPUT);
pinMode(SolarToBoiler, OUTPUT);
digitalWrite(SolarToBoiler, LOW);
pinMode(BuferToBoiler, OUTPUT);
digitalWrite(BuferToBoiler, LOW);
pinMode(SolarToBufer, OUTPUT);
digitalWrite(SolarToBufer, LOW);
lcd.begin(16, 2);
lcd.clear();
lcd.setCursor(0, 0);
}
void loop() {
delay(10);
//if (state1 == 0){
// lcd.clear();
//SolarBoiler();
//}
if (digitalRead(A5) == LOW && state2 == 0) {
lcd.clear();
delay(50);
state1 = 1;
if (state1 == 1) {
DiferentH();
delay(120);
}
}
if (digitalRead(A5) == LOW && state1 == 1) {
lcd.clear();
delay(50);
state2 = 1;
if (state2 == 1) {
DiferentL();
delay(120);
}
}
if (digitalRead(A5) == LOW && state1 == 1 && state2 == 1) {
lcd.clear();
//delay(50);
state2 = 0;
//delay(50);
state1 = 0;
delay(120);
}
}
void DiferentH() {
lcd.clear();
lcd.setCursor(0, 0);
delay(50);
lcd.print("DIFERENT HI ");
lcd.print(diferentHi);
lcd.write(byte(11));
lcd.setCursor(0, 1);
lcd.print("________________" );
delay(50);
if (digitalRead(A4) == LOW && diferentHi <= 20) {
diferentHi++;
delay(50);
}
}
void DiferentL() {
lcd.clear();
lcd.setCursor(0, 0);
delay(50);
lcd.print("DIFERENT LOW ");
lcd.print(diferentLo);
lcd.write(byte(11));
lcd.setCursor(0, 1);
lcd.print("________________" );
delay(50);
if (digitalRead(A4) == LOW && diferentLo <= diferentHi + 2) {
diferentLo++;
delay(50);
}
}
void SolarBoiler() {
float tempSolar = analogRead(solar);
tempSolar = map(tempSolar, 15, 1021, 0, 260);
lcd.print("Solar ");
lcd.print(tempSolar);
lcd.write(byte(11));
lcd.print("C");
float tempBoiler = analogRead(boiler);
tempBoiler = map(tempBoiler, 15, 1021, 0, 260);
lcd.setCursor(0, 1);
lcd.print("Boiler ");
lcd.print(tempBoiler);
lcd.write(byte(11));
lcd.print("C");
float tempBufer = analogRead(bufer);
delay(100);
if ((tempSolar - tempBoiler) >= diferentHi ) {
digitalWrite(SolarToBoiler, HIGH);
}
else if ((tempSolar - tempBoiler) <= diferentLo) {
delay(1000);
digitalWrite(SolarToBoiler, LOW);
}
if (digitalRead(SolarToBoiler) == HIGH) {
Anime();
}
}
void Anime() {
//lcd.setCursor(15,0);
//lcd.write(byte(0));
delay(50);
//lcd.setCursor(15,0);
//lcd.write(byte(1));
delay(50);
lcd.setCursor(15, 1);
lcd.write(byte(2));
delay(50);
//lcd.setCursor(15,1);
//lcd.write(byte(3));
lcd.setCursor(15, 1);
lcd.write(byte(4));
delay(50);
lcd.setCursor(15, 1);
lcd.write(byte(5));
delay(50);
lcd.setCursor(15, 1);
lcd.write(byte(6));
delay(50);
lcd.setCursor(15, 1);
lcd.write(byte(7));
lcd.setCursor(15, 1);
lcd.write(byte(8));
delay(50);
lcd.setCursor(15, 1);
lcd.write(byte(9));
delay(50);
lcd.setCursor(15, 1);
lcd.write(byte(10));
delay(100);
}
[code]
]

