-
-
Save marmilicious/033dbe5d7bc2943af86fe22ca9df7cbd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
boolean locked = false; | |
void loop() | |
{ | |
if (locked == false) { | |
gPatterns[gCurrentPatternNumber](); | |
} | |
readbutton(); | |
FastLED.show(); // send the 'leds' array out to the actual LED strip | |
// do some periodic updates | |
EVERY_N_MILLISECONDS( 15 ) { gHue++; } // slowly cycle the "base color" through the rainbow | |
if (locked == false) { | |
EVERY_N_SECONDS( 15 ) { nextPattern();} // change patterns every N seconds | |
} | |
} //loop() | |
void nextPattern() | |
{ | |
// add one to the current pattern number, and wrap around at the end | |
gCurrentPatternNumber = (gCurrentPatternNumber + 1) % ARRAY_SIZE( gPatterns); | |
Serial.println(gCurrentPatternNumber); | |
}//nextPattern() | |
void readbutton() { // Read the button and increase the mode. | |
myBtn.read(); | |
if(myBtn.pressedFor(1000)) { | |
longpress = 1; | |
locked = !locked; // toggle variable whenever button pressed for 1 second. | |
return; | |
} | |
if(myBtn.wasReleased()) { | |
if (longpress==1) { | |
EEPROM.write(eepaddress, gCurrentPatternNumber); | |
Serial.print("Writing: "); | |
} else { | |
gCurrentPatternNumber = gCurrentPatternNumber > maxMode-1 ? 0 : gCurrentPatternNumber+1; // Reset to 0 only during a mode change. | |
} | |
longpress = 0; | |
Serial.println(gCurrentPatternNumber); | |
} | |
}//readbutton() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment