Background:
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).
The Dream:
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.
Current Code:
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 Problem:
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.
if you do code and this seems like waaay too much work to take on for free, maybe we can come to another arrangement? I'm getting to the point of bidding this job on freelancer or something.
new_code_experiment.ino (24 KB)