#include <Adafruit_NeoPixel.h>
#include <EEPROM.h>
Adafruit_NeoPixel led(12, 9, NEO_GRB + NEO_KHZ800);
uint32_t red = led.Color(255, 0, 0);
uint32_t green = led.Color(0, 255, 0);
uint32_t blue = led.Color(0, 0, 255);
uint32_t white = led.Color(255, 255, 255);
uint32_t myarr[] = {green, red, blue, white};
int offset = 0;
void setup() {
led.begin();
pinMode(2, INPUT_PULLUP);
attachInterrupt(digitalPinToInterrupt(2),myIntr,FALLING);
if (EEPROM.read(1) != 255) {
offset = EEPROM.read(1);
}
}
void loop() {
for(int i = 0; i < 12; i++) {
led.setPixelColor(i, myarr[(i + offset) % 4]);
led.show();
delay(100);
}
EEPROM.update(1, offset);
led.clear();
}
void myIntr() {
offset++;
if (offset > 3) {
offset = 0;
}
}