I have two led strips. One has a stationary (for now) color and the other has different colors set every 1000ms. I have a method that should take in the color I would like the strip and which Adafruit_NeoPixel strip it is. When the program runs, I get WHITE on strip and YELLOW on the other. Those are the correct first two colors, but the “rear_strip” never changes off yellow. Am I calling the function incorrectly? Code is below.
#include <Adafruit_NeoPixel.h>
// Dropping this, changes the color of later LED's
#ifdef __AVR__
#include <avr/power.h> // Required for 16 MHz Adafruit Trinket
#endif
// Which pin on the Arduino is connected to the NeoPixels?
#define REAR_LED_PIN 12
#define CRYSTAL_LED_PIN 13
// How many NeoPixels are attached to the Arduino?
#define REAR_LED_COUNT 24
#define CRYSTAL_LED_COUNT 10
//How Bright you want these strips? Set BRIGHTNESS to about 1/5 (max = 255)
#define REAR_BRIGHT 255
#define CRYSTAL_BRIGHT 255
// Colors
const auto RED = Adafruit_NeoPixel::Color(255,0,0);
const auto BLUE = Adafruit_NeoPixel::Color(0,0,255);
const auto PURPLE = Adafruit_NeoPixel::Color(128,0,128);
const auto BLACK = Adafruit_NeoPixel::Color(0,0,0);
const auto WHITE = Adafruit_NeoPixel::Color(255,255,255);
const auto GREEN = Adafruit_NeoPixel::Color(0,128,0);
const auto YELLOW = Adafruit_NeoPixel::Color(255,255,0);
// Declare our NeoPixel strip objects:
Adafruit_NeoPixel rear_strip(REAR_LED_COUNT, REAR_LED_PIN, NEO_GRB + NEO_KHZ800);
Adafruit_NeoPixel crystal_strip(CRYSTAL_LED_COUNT, CRYSTAL_LED_PIN, NEO_GRB + NEO_KHZ800);
void setup() {
// These lines are specifically to support the Adafruit Trinket 5V 16 MHz.
// Any other board, you can remove this part (but no harm leaving it):
#if defined(__AVR_ATtiny85__) && (F_CPU == 16000000)
clock_prescale_set(clock_div_1);
#endif
// END of Trinket-specific code.
rear_strip.begin(); // INITIALIZE NeoPixel rear_strip object (REQUIRED)
crystal_strip.begin();
rear_strip.show(); // Turn OFF all pixels ASAP
crystal_strip.show();
rear_strip.setBrightness(REAR_BRIGHT);
crystal_strip.setBrightness(CRYSTAL_BRIGHT);
}
void loop() {
setColor(YELLOW, rear_strip);
setColor(WHITE, crystal_strip);
delay(1000);
setColor(RED, rear_strip);
delay(1000);
setColor(BLUE, rear_strip);
delay(1000);
setColor(PURPLE, rear_strip);
delay(1000);
setColor(BLACK, rear_strip);
delay(1000);
setColor(WHITE, rear_strip);
delay(1000);
setColor(GREEN, rear_strip);
delay(1000);
}
void setColor(uint32_t color, Adafruit_NeoPixel strip) {
for(int i = 0; i < strip.numPixels(); i++) { // For each pixel in the passed strip...
strip.setPixelColor(i, color); // Set pixel's color (in RAM)
strip.show(); // Update strip to match
}
}