Hello I really need help and input on some code I am making.
I have a Arduino Uno v3, I am using for controlling some heating elements, true some solidstate relay, the teknik part is working fin, but I need/ or wont to program a hysteresis of 1 degrade celcius in my code.
CODE:
#include <DallasTemperature.h>
#include <LiquidCrystal.h>
#include <OneWire.h>
#include <EEPROM.h>
#include <math.h>
#define ONE_WIRE_BUS A0//DS18B20 connectet to A0
const int rs = 12, en =11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);// lcd displayet is runing on this pins.
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
int potpin = A5;// 10 k ohm pot connetet to A5
int potmeter;
float TempAct;
void setup(){
sensors.begin();
lcd.begin(16,2);
analogWrite(3, 0);
Serial.begin(9600);
pinMode(potpin,INPUT);//pot
pinMode(7,OUTPUT);//relaypin 500W heat element
pinMode(9,OUTPUT);//relaypin 2000W heat element
lcd.print("YES MASTER");
delay(2500);
lcd.clear();// YES MASTER is on screen for 2,5 ss, then the screen clears.
}
void loop(){
float Potmeter;
sensors.requestTemperatures();//arduino is asking for temp
TempAct = sensors.getTempCByIndex(0);// the temp is read digital.
Serial.println(TempAct);// the data is send serial.
lcd.setCursor(0,0);
lcd.print("C ");
lcd.print(TempAct);// what is shoe on the lcd
lcd.setCursor (0,1);//position on the lcd
lcd.print("SET TO:");
Potmeter = 0;
int x;
for (x = 0; x < 100; x++)
Potmeter += analogRead(potpin);
Potmeter = (((Potmeter/100) * (5.0 / 1023.0)) * 16) + 20;
lcd.print(round(Potmeter*2)/2);
lcd.print(" ");
Serial.println(Potmeter);
if (Potmeter > TempAct){
digitalWrite (7, LOW);
digitalWrite (9, LOW);
}
if (TempAct > Potmeter){
digitalWrite (7, HIGH);
digitalWrite (9, HIGH);
}
delay(250);
}
I need help / input to have I get it to reat with 1 degrede celcius on the screen and in the program, so that the relays don,t goes on/off all the time
thank in advars for the help