Help adding 3rd state

Could someone help me add a 3rd state to this code which controls my aquarium Led's..

I want to add a 'kMorningState' to precede the 'kDayState' however this code is far too dense, like myself I guess.

How about...

code.addState(3rd);

Could you elaborate on that any further for us novice type. I understand different states, however the way this code fades the LED complicates things..

I don't see any code and I suspect neither did @DavidOConnor.

...R

Just injecting a little geek humor. :slight_smile: You forgot to post the code.

ooops my mistake..

Tankcontrol_2Pbutton_5110_B_W_l.ino (8.38 KB)

Looks as though just you need to add another else if in determine_state and call set_state with a different array with the pwm values in it.

Il work through your suggestions and get back to you with some updated code!

I will outline my basic required functions and I am open to suggestions on alternative more efficient code structures. This is for version 2 of my build using a 1307 to orientate to time and IR receiver to allow remote ir hex's to activate states. Any user activated state is over-written by the 1307 when predefined to do so.

What structure should i use? such as a State machine, IF/else, Switch case?

DS1307 equipped
5110 equipped
onewire temp equipped
IR receiver for control

White LED pwm channel 1 -- fades in at 9am and fades out at 5pm to a predefined standby level
Blue LED pwm channel 2 -- fades in at 2pm and fades out at 11pm to a predefined standby level
Pump 1 pwm channel 3 -- alternates over 10 second
Pump 2 pwm channel 4-- as above
pump 4 relay channel 1 -- automatically activates when probe 1 falls low
Probe 1 - Water level magnetic float sensor.

Kind regards