I could really use your help. I am working on a project which has two 12 pixel neopixel rings which I have wired in sequence, and 14 individual neopixels, wired in sequence. I have wired two separate buttons. They are wired to a flora board.
My goal is to be able to program the rings to do a simple chase animation (one green pixel going in a circle, similar to color wipe but unending) which on button press would go to solid green or solid white. I can drop this if its adding too much complication and would honestly be super happy to just have it animating in that circle animation. The goal of the pixels would be to have them change color on click from green to white and that's it.
My dilemma is that I am unfamiliar with programming multiple things at once, and am having a heck of a time finding information regarding this. In the libraries I've found, all I can see is how to do a single action (say only rings, or only neopixels) but I am unsure of how to structure my code to do both things. Do you just find the code for both, and stack them, and it will work?
I know you are all very busy and the obvious answer here is "figure it out" but if you'd be willing to help, I'd sure be grateful. I would be happy to pay one of you to help me and teach me a bit about how to do this if any of you would be willing to go that route.
Here's the current button code that I have set up (and I understand that the animation here is rainbow, I just haven't yet found the right code for the chase animation yet), just for the ring, and only for the one action. Thanks in advance for any help you might have.
Code: Select all
// This is a demonstration on how to use an input device to trigger changes on your neo pixels.
// You should wire a momentary push button to connect from ground to a digital IO pin. When you
// press the button it will change to a new pixel animation. Note that you need to press the
// button once to start the first animation!
#include <Adafruit_NeoPixel.h>
#define BUTTON_PIN 6 // Digital IO pin connected to the button. This will be
// driven with a pull-up resistor so the switch should
// pull the pin to ground momentarily. On a high -> low
// transition the button press logic will execute.
#define PIXEL_PIN 3 // Digital IO pin connected to the NeoPixels.
#define PIXEL_COUNT 12
// Parameter 1 = number of pixels in strip, neopixel stick has 8
// Parameter 2 = pin number (most are valid)
// Parameter 3 = pixel type flags, add together as needed:
// NEO_RGB Pixels are wired for RGB bitstream
// NEO_GRB Pixels are wired for GRB bitstream, correct for neopixel stick
// NEO_KHZ400 400 KHz bitstream (e.g. FLORA pixels)
// NEO_KHZ800 800 KHz bitstream (e.g. High Density LED strip), correct for neopixel stick
Adafruit_NeoPixel strip = Adafruit_NeoPixel(PIXEL_COUNT, PIXEL_PIN, NEO_GRB + NEO_KHZ800);
bool oldState = HIGH;
int showType = 0;
void setup() {
pinMode(BUTTON_PIN, INPUT_PULLUP);
strip.begin();
strip.show(); // Initialize all pixels to 'off'
}
void loop() {
// Get current button state.
bool newState = digitalRead(BUTTON_PIN);
// Check if state changed from high to low (button press).
if (newState == LOW && oldState == HIGH) {
// Short delay to debounce button.
delay(20);
// Check if button is still low after debounce.
newState = digitalRead(BUTTON_PIN);
if (newState == LOW) {
showType++;
if (showType > 9)
showType=0;
startShow(showType);
}
}
// Set the last button state to the old state.
oldState = newState;
}
void startShow(int i) {
switch(i){
case 0: colorWipe(strip.Color(0, 0, 0), 1); // Black/off
break;
case 1: colorWipe(strip.Color(0, 0, 255), 1); // BLUE
break;
case 2:
for (int x = 0; x < 50; x++) {
rainbow(2);
}