#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27,16,2);
#include <Adafruit_NeoPixel.h>
#ifdef __AVR__
#include <avr/power.h>
#endif
#define DEBUG true
#define Serial if(DEBUG)Serial
#define LED_PIN 6
const int buttonPin = 2;
int buttonState = 0;
#define LED_COUNT 96
Adafruit_NeoPixel strip(LED_COUNT, LED_PIN, NEO_GRB + NEO_KHZ800);
const int rainbowColors[][3] = {
{255, 0, 0}, // Red
{255, 32, 0}, //
{255, 64, 0}, //
{255, 96, 0}, //
{255, 128, 0}, //
{255, 160, 0}, //
{255, 192, 0}, //
{255, 224, 0}, //
{255, 255, 0}, // yellow
{224, 255, 0}, //
{192, 255, 0}, //
{160, 255, 0}, //
{128, 255, 0}, //
{96, 255, 0}, //
{64, 255, 0}, //
{32, 255, 0}, //
{0, 255, 0}, // green
{0, 255, 32}, //
{0, 255, 64}, //
{0, 255, 96}, //
{0, 255, 128}, //
{0, 255, 160}, //
{0, 255, 192}, //
{0, 255, 224}, //
{0, 255, 255}, // cyan
{0, 224, 255}, //
{0, 192, 255}, //
{0, 160, 255}, //
{0, 128, 255}, //
{0, 96, 255}, //
{0, 64, 255}, //
{0, 32, 255}, //
{0, 0, 255}, // blue
{32, 0, 255}, //
{64, 0, 255}, //
{96, 0, 255}, //
{128, 0, 255}, //
{160, 0, 255}, //
{192, 0, 255}, //
{224, 0, 255}, //
{255, 0, 255}, // magenta
{255, 0, 224}, //
{255, 0, 192}, //
{255, 0, 160}, //
{255, 0, 128}, //
{255, 0, 96}, //
{255, 0, 64}, //
{255, 0, 32}, //
};
const int numColors = sizeof(rainbowColors)/sizeof(rainbowColors[0]);
int mixedColors[numColors][3] = {};
int patternCount = 12;
int patternInterval = 10000;
unsigned long patternPrevious = 0;
int pixelCycle = 0;
uint16_t pixelNumber = LED_COUNT;
unsigned long past = 0;
void setup() {
#if defined(__AVR_ATtiny85__) && (F_CPU == 16000000)
clock_prescale_set(clock_div_1);
#endif
pinMode(buttonPin, INPUT);
lcd.init();
lcd.backlight ();
lcd.setCursor(7,0);
lcd.print("DHEL22");
strip.begin(); // INITIALIZE NeoPixel strip object (REQUIRED)
strip.show(); // Turn OFF all pixels ASAP
strip.setBrightness(50); // Set BRIGHTNESS to about 1/5 (max = 255)
Serial.begin(9600);
for(int i = 0; i < numColors-1; i++){
int rand = random(numColors-1);
mixedColors[i][0] = rainbowColors[rand][0];
mixedColors[i][1] = rainbowColors[rand][1];
mixedColors[i][2] = rainbowColors[rand][2];
}
}
unsigned int counter = 0;
void loop() {
buttonState = digitalRead(buttonPin);
if (counter == 10000) {
counter = 0;
}
delay(320);
if (buttonState == HIGH) {
counter++;
}
Serial.println(counter);
lcd.setCursor(0,1);
lcd.print(counter);
}