So, I have a project that is over a year in the making. It used to be two Unos talking to each other over serial, and it worked fine for the most part. One was a stand alone thermostat and the other was a web server. Combining both sketches was too big for one Uno. Recently I purchased a mega and combined the sketches. It works pretty well but I'm wondering if there is any way to optimize the code and I'm looking for suggestions. It's a massive sketch so I really don't expect too many responses. Sometimes the web page is laggy and some times the buttons on the LCD are laggy and I think it's because one is busy and blocking the other. Not a huge deal, but I'm always tweaking it to save clock cycles here and there that might help it go a little faster. I looked into ISRs for the ethernet board but didn't find anything worth pursuing. Again, just looking for suggestions. Thanks!
My code can be found here: Thermostat for Mega.