Hi. Have very little and very basic coding experience but my boiler controlls failed so i need to make my own. I am trying to stich multiple codes for my need. Found this code for boiler but the guy uses buttons connected to analog input and i have 16x2 lcd shield i would like to use. Here is my code:
#include <OneWire.h>
#include <DallasTemperature.h>
#include<EEPROM.h>
#include <LiquidCrystal.h>
//LCD pin to Arduino
const int pin_RS = 8;
const int pin_EN = 9;
const int pin_d4 = 4;
const int pin_d5 = 5;
const int pin_d6 = 6;
const int pin_d7 = 7;
const int pin_BL = 10;
LiquidCrystal lcd( pin_RS, pin_EN, pin_d4, pin_d5, pin_d6, pin_d7);
int add_chk = 0;
int check_val = 10;
int c_temp = 0;
int c_temp_add = 1;
// define some values used by the panel and buttons
int lcd_key = 0;
int adc_key_in = 0;
#define set 0
#define inc 1
#define dec 2
#define stsp 3
#define btnSELECT 4
#define btnNONE 5
// read the buttons
int read_LCD_buttons()
{
adc_key_in = analogRead(0); // read the value from the sensor
if (adc_key_in < 60) return set;
if (adc_key_in < 200) return inc;
if (adc_key_in < 400) return dec;
if (adc_key_in < 600) return stsp;
if (adc_key_in < 800) return btnSELECT;
return btnNONE; // when all others fail, return this...
}
int numberOfDevices;
int relay = 8;
int val_tol = 0;
bool exit_stsp = false;
bool exit_set = false;
bool re_heat = false;
#define ONE_WIRE_BUS 10 // Pin no
#define TEMPERATURE_PRECISION 12 // 12-bit resolution
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
DeviceAddress tempDeviceAddress;
//------- Temperature tolerance -------//
const int tol = 3; // in degree Celsius
//-----------------------------------//
void setup(void)
{
lcd.begin(16, 2);
sensors.begin();
pinMode(stsp, INPUT_PULLUP);
pinMode(inc, INPUT_PULLUP);
pinMode(dec, INPUT_PULLUP);
pinMode(set, INPUT_PULLUP);
pinMode(relay, OUTPUT);
digitalWrite(relay, LOW);
lcd.clear();
lcd.setCursor(0, 0);
lcd.print(" Water Heater");
lcd.setCursor(0, 1);
lcd.print(" Controller");
numberOfDevices = sensors.getDeviceCount();
if (EEPROM.read(add_chk) != check_val)
{
EEPROM.write(add_chk, check_val);
EEPROM.write(c_temp_add, 50);
c_temp = EEPROM.read(c_temp_add);
}
else
{
c_temp = EEPROM.read(c_temp_add);
}
delay(1500);
}
void loop(void)
{
lcd.setCursor(0, 0);
lcd.print("PRESS START/SET");
lcd.setCursor(0, 1);
lcd.print("TEMP: ");
lcd.print(EEPROM.read(c_temp_add));
lcd.print("C/");
if (read_LCD_buttons(set) == LOW && exit_set == false)
{
exit_set = true;
c_temp = EEPROM.read(c_temp_add);
while (exit_set)
{
if (read_LCD_buttons(inc) == LOW)
{
c_temp += 1;
if (c_temp > 110) c_temp = 0;
delay(50);
}
if (read_LCD_buttons(dec) == LOW)
{
c_temp -= 1;
if (c_temp < 0) c_temp = 110;
delay(50);
}
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("SET TEMPERATURE:");
lcd.setCursor(0, 1);
lcd.print(" ");
lcd.print(c_temp);
lcd.print("C/");
delay(150);
if (read_LCD_buttons(set) == LOW)
{
delay(500);
if (read_LCD_buttons(set) == LOW)
{
exit_set = false;
if (EEPROM.read(c_temp_add) == c_temp)
{
lcd.clear();
lcd.print("VALUE UNCHANGED!");
delay(1500);
}
else
{
EEPROM.write(c_temp_add, c_temp);
lcd.clear();
lcd.print(" VALUE SAVED!");
lcd.setCursor(0, 1);
lcd.print("****************");
delay(1500);
lcd.clear();
}
}
}
}
}
if (read_LCD_buttons(stsp) == LOW && exit_stsp == false)
{
exit_stsp = true;
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("SET: ");
lcd.print(EEPROM.read(c_temp_add));
lcd.print("C/");
digitalWrite(relay, HIGH);
while (exit_stsp)
{
sensors.requestTemperatures();
for (int i = 0; i < numberOfDevices; i++)
{
if (sensors.getAddress(tempDeviceAddress, i))
{
printTemperature(tempDeviceAddress);
}
}
lcd.setCursor(0, 1);
lcd.print("WATER: ");
lcd.print(c_temp);
lcd.print("C/");
if (c_temp >= EEPROM.read(c_temp_add))
{
delay(5000);
if (c_temp >= EEPROM.read(c_temp_add))
{
digitalWrite(relay, LOW);
re_heat = true;
}
}
val_tol = EEPROM.read(c_temp_add) - tol;
if (c_temp <= val_tol && re_heat == true)
{
re_heat = false;
digitalWrite(relay, HIGH);
}
if (read_LCD_buttons(stsp) == LOW && exit_stsp == true)
{
delay(1500);
if (read_LCD_buttons(stsp) == LOW);
{
digitalWrite(relay, LOW);
exit_stsp = false;
lcd.clear();
lcd.print("PROCESS STOPPED!");
lcd.setCursor(0, 1);
lcd.print("****************");
delay(500);
lcd.clear();
break;
}
}
}
}
}
void printTemperature(DeviceAddress deviceAddress)
{
c_temp = sensors.getTempC(deviceAddress);
}
I get this error:
C:\Users\A.Mikutavicius\Desktop\New folder\boiler\boiler.ino: In function 'void loop()':
boiler:95:27: error: too many arguments to function 'int read_LCD_buttons()'
if (read_LCD_buttons(set) == LOW && exit_set == false)
^
C:\Users\A.Mikutavicius\Desktop\New folder\boiler\boiler.ino:30:5: note: declared here
int read_LCD_buttons()
^~~~~~~~~~~~~~~~
boiler:101:31: error: too many arguments to function 'int read_LCD_buttons()'
if (read_LCD_buttons(inc) == LOW)
^
C:\Users\A.Mikutavicius\Desktop\New folder\boiler\boiler.ino:30:5: note: declared here
int read_LCD_buttons()
^~~~~~~~~~~~~~~~
boiler:107:31: error: too many arguments to function 'int read_LCD_buttons()'
if (read_LCD_buttons(dec) == LOW)
^
C:\Users\A.Mikutavicius\Desktop\New folder\boiler\boiler.ino:30:5: note: declared here
int read_LCD_buttons()
^~~~~~~~~~~~~~~~
boiler:121:31: error: too many arguments to function 'int read_LCD_buttons()'
if (read_LCD_buttons(set) == LOW)
^
C:\Users\A.Mikutavicius\Desktop\New folder\boiler\boiler.ino:30:5: note: declared here
int read_LCD_buttons()
^~~~~~~~~~~~~~~~
boiler:124:33: error: too many arguments to function 'int read_LCD_buttons()'
if (read_LCD_buttons(set) == LOW)
^
C:\Users\A.Mikutavicius\Desktop\New folder\boiler\boiler.ino:30:5: note: declared here
int read_LCD_buttons()
^~~~~~~~~~~~~~~~
boiler:148:28: error: too many arguments to function 'int read_LCD_buttons()'
if (read_LCD_buttons(stsp) == LOW && exit_stsp == false)
^
C:\Users\A.Mikutavicius\Desktop\New folder\boiler\boiler.ino:30:5: note: declared here
int read_LCD_buttons()
^~~~~~~~~~~~~~~~
boiler:187:32: error: too many arguments to function 'int read_LCD_buttons()'
if (read_LCD_buttons(stsp) == LOW && exit_stsp == true)
^
C:\Users\A.Mikutavicius\Desktop\New folder\boiler\boiler.ino:30:5: note: declared here
int read_LCD_buttons()
^~~~~~~~~~~~~~~~
boiler:190:34: error: too many arguments to function 'int read_LCD_buttons()'
if (read_LCD_buttons(stsp) == LOW);
^
C:\Users\A.Mikutavicius\Desktop\New folder\boiler\boiler.ino:30:5: note: declared here
int read_LCD_buttons()
^~~~~~~~~~~~~~~~
exit status 1
too many arguments to function 'int read_LCD_buttons()'
Any help appreciated, thanks