Good evening everyone, I have a problem, I need help to correct the program I made, I have two problems left that I can't solve, the first is that every now and then I see the old temperature, the second is that I need to stabilize better the temperature.
Please can you help me?
void loop()
{
int blocca = digitalRead(finecorsa);
int blocca1 = digitalRead(finecorsa1);
int blocca2 = digitalRead(finecorsa2);
sensore.requestTemperatures(); // richiesta lettura temperatura
float celsius = sensore.getTempCByIndex(0);
celsius = int(celsius * 10) / 10;
{
if ((celsius-temp) > (2))
{
v1 = ((celsius- temp));
}
else
v1 = ((celsius-temp)/6);
if ((temp-celsius) == (1) or (celsius-temp) == (1))
v1 = ((celsius-temp)/5);
//fa entrare l'acqua fredda
if (temp < (celsius) && (digitalRead(15) == HIGH))
{
sensore.requestTemperatures();
celsius = sensore.getTempCByIndex(0);
digitalWrite(pinEnable, enable);
stepper1.move(1); // 200/second = 1 rps
stepper1.currentPosition() != 0;
stepper1.setSpeed(v1);
stepper1.runSpeed();
Serial.println(v1);
TFTlcd.SetNumberValue(1, 13, celsius);
}
if ((temp-celsius) > (2))
{
v1 = ((temp-celsius));
}
else
v1 = ((temp-celsius)/6);
if ((temp-celsius) == (1) or (celsius-temp) == (1))
v1 = ((temp-celsius)/5);
//fa entrare l'acqua calda
if (temp > (celsius) && (digitalRead(14) == HIGH))
{
sensore.requestTemperatures();
celsius = sensore.getTempCByIndex(0);
digitalWrite(pinEnable, enable);
stepper1.move(-1); // 200/second = 1 rps
stepper1.currentPosition() != -0;
stepper1.setSpeed(-v1);
stepper1.runSpeed();
Serial.println(-v1);
TFTlcd.SetNumberValue(1, 13, celsius);
}
}
if (temp == celsius)
digitalWrite(pinEnable, !enable);
//Serial.println(-v1);
TFTlcd.SetNumberValue(1, 13, celsius);