Hello friends
The following code works, but I would like to define two or more of these strips as a single strip in order to make for example a colorwipe through multiple strips with one function call, so actually group multiple strips as being one. I have a 3D object with many strips of 24 diodes, connected to 5 different outputs on a Teensy 3.6, and would therefore like to group them when making effects.
I appreciate your help, cheers.
#include <Adafruit_NeoPixel.h>
#ifdef __AVR__
#include <avr/power.h>
#endif
#define A_PIN 6
#define B_PIN 20
#define C_PIN 21
#define D_PIN 2
#define E_PIN 5
#define NUM_LEDS 24
#define BRIGHTNESS 255
Adafruit_NeoPixel strip_1 = Adafruit_NeoPixel(NUM_LEDS, A_PIN, NEO_GRBW + NEO_KHZ800);
Adafruit_NeoPixel strip_2 = Adafruit_NeoPixel(NUM_LEDS, B_PIN, NEO_GRBW + NEO_KHZ800);
Adafruit_NeoPixel strip_3 = Adafruit_NeoPixel(NUM_LEDS, C_PIN, NEO_GRBW + NEO_KHZ800);
Adafruit_NeoPixel strip_4 = Adafruit_NeoPixel(NUM_LEDS, D_PIN, NEO_GRBW + NEO_KHZ800);
Adafruit_NeoPixel strip_5 = Adafruit_NeoPixel(NUM_LEDS, E_PIN, NEO_GRBW + NEO_KHZ800);
byte neopix_gamma[] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2,
2, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5,
5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 9, 9, 9, 10,
10, 10, 11, 11, 11, 12, 12, 13, 13, 13, 14, 14, 15, 15, 16, 16,
17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 24, 24, 25,
25, 26, 27, 27, 28, 29, 29, 30, 31, 32, 32, 33, 34, 35, 35, 36,
37, 38, 39, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 50,
51, 52, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 66, 67, 68,
69, 70, 72, 73, 74, 75, 77, 78, 79, 81, 82, 83, 85, 86, 87, 89,
90, 92, 93, 95, 96, 98, 99,101,102,104,105,107,109,110,112,114,
115,117,119,120,122,124,126,127,129,131,133,135,137,138,140,142,
144,146,148,150,152,154,156,158,160,162,164,167,169,171,173,175,
177,180,182,184,186,189,191,193,196,198,200,203,205,208,210,213,
215,218,220,223,225,228,231,233,236,239,241,244,247,249,252,255 };
void setup() {
// This is for Trinket 5V 16MHz, you can remove these three lines if you are not using a Trinket
#if defined (__AVR_ATtiny85__)
if (F_CPU == 16000000) clock_prescale_set(clock_div_1);
#endif
// End of trinket special code
strip_1.setBrightness(BRIGHTNESS);
strip_1.begin();
strip_1.show(); // Initialize all pixels to 'off'
strip_2.setBrightness(BRIGHTNESS);
strip_2.begin();
strip_2.show(); // Initialize all pixels to 'off'
strip_3.setBrightness(BRIGHTNESS);
strip_3.begin();
strip_3.show(); // Initialize all pixels to 'off'
strip_4.setBrightness(BRIGHTNESS);
strip_4.begin();
strip_4.show(); // Initialize all pixels to 'off'
strip_5.setBrightness(BRIGHTNESS);
strip_5.begin();
strip_5.show(); // Initialize all pixels to 'off'
}
void loop() {
colorWipe_1(strip_1.Color(255, 0, 0, 0), 25);
colorWipe_4(strip_1.Color(0, 255, 0, 0), 25);
colorWipe_2(strip_1.Color(0, 0, 255, 0), 25);
colorWipe_5(strip_1.Color(0, 0, 0, 255), 25);
colorWipe_3(strip_1.Color(255, 255, 0, 0), 25);
}
// Fill the dots one after the other with a color
void colorWipe_1(uint32_t c, uint8_t wait) {
for(uint16_t i=0; i<strip_1.numPixels(); i++) {
strip_1.setPixelColor(i, c);
strip_1.show();
delay(wait);
}
}
void colorWipe_2(uint32_t c, uint8_t wait) {
for(uint16_t i=0; i<strip_2.numPixels(); i++) {
strip_2.setPixelColor(i, c);
strip_2.show();
delay(wait);
}
}
void colorWipe_3(uint32_t c, uint8_t wait) {
for(uint16_t i=0; i<strip_3.numPixels(); i++) {
strip_3.setPixelColor(i, c);
strip_3.show();
delay(wait);
}
}
void colorWipe_4(uint32_t c, uint8_t wait) {
for(uint16_t i=0; i<strip_4.numPixels(); i++) {
strip_4.setPixelColor(i, c);
strip_4.show();
delay(wait);
}
}
void colorWipe_5(uint32_t c, uint8_t wait) {
for(uint16_t i=0; i<strip_5.numPixels(); i++) {
strip_5.setPixelColor(i, c);
strip_5.show();
delay(wait);
}
}