So I have a aquarium(oh yes another one), and I’m using an Arduino Mega to turn on the lights and other functions however this software just does the lights as the program is halting and is no longer responding as expected.
What I want the code to do and what works at least for a 24 hours period turn the lights on and off based off the sun positions IE sunrise twilight, sunrise, sunset and sunset twilight. I did this with suncalc() and is my code. The other thing it does is Ramp UP/Down based on a curve, this part was not programmed by myself I asked a friend that has programming experience for help. I tied a potentiometer to the ramp up/down to control intensity. You can fry corals by turning the LEDS on full blast!
What happens If I turn the arduino on in the morning it runs fine though out the day turns on ramps up ramps down all turns off. All Good. However over night things go downhill. Suncalc() runs but at some point in time after that the ramp up/down crashes it turns on one maybe two channels and that all she wrote. Adjusting the pot does nothing only thing that works is hitting reset which is hard to get to or unplugging the arduino and pluggging it back in. For the moment to solve this issue I have the arduino on an Aquarium timer that turns it on and off at night.
Am I asking too much of the mega or do I need to try and clean this up?
I attached my code.
Reef_Main_V4.ino (10 KB)