Created
December 6, 2024 23:53
-
-
Save todbot/6ede5686b9ecdfe25b72648ecc91c025 to your computer and use it in GitHub Desktop.
Show many neopixel strips in use simultaneously using Adafruit_NeoPixel
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Show many neopixel strips in use simultaneously using Adafruit_NeoPixel | |
// | |
// 2024Dec12 - @todbot | |
// compiles, not tested | |
#include <Adafruit_NeoPixel.h> | |
#define NUM_STRIPS 3 | |
const int pin_for_strip[] = {A0, A2, 5}; | |
const int leds_per_strip[] = {20, 30, 10}; | |
const neoPixelType format_per_strip[] = {NEO_GRB + NEO_KHZ800, NEO_BGR + NEO_KHZ800, NEO_BGR + NEO_KHZ800 }; | |
Adafruit_NeoPixel *strips[NUM_STRIPS]; | |
void setup() { | |
// set up my strips like a sucker | |
for(int i=0; i< NUM_STRIPS; i++) { | |
int pin = pin_for_strip[i]; | |
int num_leds = leds_per_strip[i]; | |
int format = format_per_strip[i]; | |
Adafruit_NeoPixel *strip = new Adafruit_NeoPixel(num_leds, pin, format); | |
strips[i] = strip; | |
strips[i]->begin(); | |
} | |
// light up all the strips, RGB, like a sucker | |
for(int i=0; i< NUM_STRIPS; i++) { | |
strips[i]->fill(0xff0000); | |
strips[i]->show(); | |
} | |
delay(100); | |
for(int i=0; i< NUM_STRIPS; i++) { | |
strips[i]->fill(0x00ff00); | |
strips[i]->show(); | |
} | |
delay(100); | |
for(int i=0; i< NUM_STRIPS; i++) { | |
strips[i]->fill(0x0000ff); | |
strips[i]->show(); | |
} | |
} | |
void loop() { | |
// put your main code here, to run repeatedly, like a sucker | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment