Hi there. This is my first ever Arduino project, albeit an ambitious one. No coding experience at the outset, but doing my best to learn as I go. My code started simple... just take input from 4 BME280 temp/humidity sensors and display that info on an LCD and use that data to control a humidifier, dehumidifier, heater, and cooler via a relay.
Complicating the issue:
Now as time passes, I'm adding code to allow the user to change max and min temperature and humidity settings while the device is on and if settings are changed, write that to EEPROM in case of power loss. ( I know EEPROM has limited write per bit, so eventually was gonna add a counter for when the user changes settings so that it stores the variables in different bits) I'm also looking to include lighting schedules and clock settings (later on, once I add an external clock).
To accomplish the ability for the user to change settings. I wrote code to include a second LCD (lcd2) to display current max temp and min temp targets. The regular code will loop and bypass this "settings code" until the user selects settings with Button1 (out of 4). Once they select settings, I want the code to loop a different "settings code" altogether, and the LCD2 will display various setting changes.
I'm currently writing the settings code in a "while loop" starting on line 444 ( I know, a lot of code) and testing if different buttons are pressed and if they are, respond accordingly. So, button 1 starts "while loop" (user settings) it holds that button state in another variable so that this code loops until the user exits the settings with button 4. Button 2 confirms this setting as the one to change, button 3 moves to the next setting.
The code is starting to get out of control here... or at least seems to be. If I continue as is, the first while loop is going to grow tremendously until all the settings menus are written out. The code compiles, and may work (haven't tested in the real world yet) But it looks ugly, seems clunky, hard to understand, and I don't think this is the best way to write the code. Please, if you know how to write this in a better way, I'm open to any opinion or advice.
I'd like to add ability for User to change setting on LCD2 with buttons, these need to write to EEPROM when changed and cycle through different EEPROM bits to use them evenly.
I'd like to add a ChronoDot V2.1 High Precision RTC to the code. the user needs to be able to set the time.
I'd like to add settings for lighting control. on-off schedules.
all of these things need to control relays. code is already written for relays. but need to add code for lighting.
two separate lighting relay controls. lighting schedule 1... and lighting schedule 2
15 freelancere byder i gennemsnit $155 timen for dette job
Myself electronics engineer and working in the industry more than 3 years, i have read the entire details you have provided, i can able to solve your issue