#include <Arduino.h>
// Simple demonstration on using an input device to trigger changes on your
// NeoPixels. Wire a momentary push button to connect from ground to a
// digital IO pin. When the button is pressed it will change to a new pixel
// animation. Initial state has all pixels off -- press the button once to
// start the first animation. As written, the button does not interrupt an
// animation in-progress, it works only when idle.
#include "PixelRing.hpp"
#include <HC4067.h>
const byte nbPixel {12};
const pin_size_t pinButton {2};
const pin_size_t pinPixel {3};
const pin_size_t pinAddress[] {6,7,8,9};
const pin_size_t pinSignal {10};
PixelRing strip(nbPixel, pinPixel);
// HC4067 mux(pinAddress[0], pinAddress[1], pinAddress[2], pinAddress[3]);
// MuxedRing rng0(pinSignal, 0, mux);
// MuxedRing rng1(pinSignal, 1, mux);
PinStatus oldState {HIGH};
int mode {0};
void setup()
{
Serial1.begin(115200);
Serial1.println("Setup");
pinMode(pinButton, INPUT_PULLUP);
strip.init();
// rng0.init();
// rng1.init();
}
void loop()
{
// Get current button state.
PinStatus newState = digitalRead(pinButton);
// Check if state changed from high to low (button press).
if ( (newState == LOW) && (oldState == HIGH) )
{
// Short delay to debounce button.
delay(20);
newState = digitalRead(pinButton);
if ( newState == LOW )
{
if ( ++mode > 8 ) mode = 0;
switch ( mode )
{
case 0:
strip.colorWipe(strip.Color( 0, 0, 0), 50); // Black/off
break;
case 1:
strip.colorWipe(strip.Color(255, 0, 0), 50); // Red
break;
case 2:
strip.colorWipe(strip.Color( 0, 255, 0), 50); // Green
break;
case 3:
strip.colorWipe(strip.Color( 0, 0, 255), 50); // Blue
break;
case 4:
strip.theaterChase(strip.Color(127, 127, 127), 50); // White
break;
case 5:
strip.theaterChase(strip.Color(127, 0, 0), 50); // Red
break;
case 6:
strip.theaterChase(strip.Color( 0, 0, 127), 50); // Blue
break;
case 7:
strip.rainbow(10);
break;
case 8:
strip.theaterChaseRainbow(50);
break;
}
}
}
// Set the last-read button state to the old state.
oldState = newState;
}