hk1972:
I also still don't quite understand how to combine all three push button phases in a single sketch
You need a finite state machine for that. Each button press (there are libraries that take care of debouncing for you) moves the code in the next state.
This project has not had the attention it deserves from me and although I started researching about two months ago, I work 12+ hrs/day and 5 to 7 days/wk, which hasn't left me enough time to spend on it and his birthday is approaching too rapidly (May 29th).
Gonna be tough... very tough... Do you have the LEDs wired up already?
For the state machine, it'll look a bit like this:
#define S_OFF 0; // Turn off all lighting
#define S_SHIMMER 1; //Turn on water shimmer and invisible lantern carrier effects
#define S_EMERGENCY 2; // Replace invisible lantern carrier effect with red emergency lighting
byte programState = 0;
void loop() {
// Move through states upon button presses.
if (buttonPress()) {
programState++;
allOff();
if (programState > 2) {
programState = 2;
}
}
// Operate lights based on the state we're in.
switch (programState) {
case S_OFF:
break;
case S_SHIMMER:
shimmer();
break;
case S_EMERGENCY:
emergency();
break;
}
}
Adding different patterns becomes trivial this way - just add another state in the switch list, add the function that does the LED handling, and you're done. The LED handling in your loop() becomes one of those functions - it will be called upon every run of loop(), not just when the state changes. Make sure to return quickly from those functions or your button is not responsive.
I put the allOff() function to the button press part, this should switch off everything the moment the button is pressed (and the state changes) so you have a known state to start from. So also when you're in the S_OFF state, just don't do anything.