i have 7 strips of neopixel leds and need i to light them all up at the same time... except with different speeds for each strip.
this is my code as of now.
#include <Adafruit_NeoPixel.h>
#ifdef __AVR__
#include <avr/power.h>
#endif
#define PIN 2
#define PIN2 3
#define PIN3 5
#define PIN4 6
#define PIN5 9
#define PIN6 10
#define PIN7 11
Adafruit_NeoPixel strip1 = Adafruit_NeoPixel(21, PIN, NEO_GRB + NEO_KHZ800);
Adafruit_NeoPixel strip2 = Adafruit_NeoPixel(6, PIN2, NEO_GRB + NEO_KHZ800);
Adafruit_NeoPixel strip3 = Adafruit_NeoPixel(6, PIN3, NEO_GRB + NEO_KHZ800);
Adafruit_NeoPixel strip4 = Adafruit_NeoPixel(12, PIN4, NEO_GRB + NEO_KHZ800);
Adafruit_NeoPixel strip5 = Adafruit_NeoPixel(12, PIN5, NEO_GRB + NEO_KHZ800);
Adafruit_NeoPixel strip6 = Adafruit_NeoPixel(12, PIN6, NEO_GRB + NEO_KHZ800);
Adafruit_NeoPixel strip7 = Adafruit_NeoPixel(21, PIN7, NEO_GRB + NEO_KHZ800);
void setup() {
strip1.begin();
strip1.show();
strip2.begin();
strip2.show();
strip3.begin();
strip3.show();
strip4.begin();
strip4.show();
strip5.begin();
strip5.show();
strip6.begin();
strip6.show();
strip7.begin();
strip7.show();
}
void loop() {
rainbowCycle(20);
}
void rainbowCycle(uint8_t wait) {
uint16_t i, j;
for(j=0; j<256*5; j++) { // 5 cycles of all colors on wheel
for(i=0; i< strip1.numPixels(); i++) {
strip1.setPixelColor(strip1.numPixels()-1-i, Wheel(((i * 256 / strip1.numPixels()) + j) & 255));
}
strip1.show();
delay(wait);
}
}
uint32_t Wheel(byte WheelPos) {
WheelPos = 255 - WheelPos;
if(WheelPos < 85) {
return strip1.Color(WheelPos * 3, (WheelPos*3)/5, 0);
}
if(WheelPos < 170) {
WheelPos -= 85;
return strip1.Color(255-WheelPos*3, (255-WheelPos*3)/4, 0);
}
WheelPos -= 170;
return strip1.Color(0, 0, 0);
}
void rainbowCycle(uint8_t wait) {
uint16_t i, j;
for(j=0; j<256*5; j++) { // 5 cycles of all colors on wheel
for(i=0; i< strip2.numPixels(); i++) {
strip2.setPixelColor(strip2.numPixels()-1-i, Wheel(((i * 256 / strip2.numPixels()) + j) & 255));
}
strip2.show();
delay(wait);
}
}
uint32_t Wheel(byte WheelPos) {
WheelPos = 255 - WheelPos;
if(WheelPos < 85) {
return strip2.Color(WheelPos * 3, (WheelPos*3)/5, 0);
}
if(WheelPos < 170) {
WheelPos -= 85;
return strip2.Color(255-WheelPos*3, (255-WheelPos*3)/4, 0);
}
WheelPos -= 170;
return strip2.Color(0, 0, 0);
}
void rainbowCycle(uint8_t wait) {
uint16_t i, j;
for(j=0; j<256*5; j++) { // 5 cycles of all colors on wheel
for(i=0; i< strip3.numPixels(); i++) {
strip1.setPixelColor(strip3.numPixels()-1-i, Wheel(((i * 256 / strip3.numPixels()) + j) & 255));
}
strip3.show();
delay(wait);
}
}
uint32_t Wheel(byte WheelPos) {
WheelPos = 255 - WheelPos;
if(WheelPos < 85) {
return strip3.Color(WheelPos * 3, (WheelPos*3)/5, 0);
}
if(WheelPos < 170) {
WheelPos -= 85;
return strip3.Color(255-WheelPos*3, (255-WheelPos*3)/4, 0);
}
WheelPos -= 170;
return strip3.Color(0, 0, 0);
}
void rainbowCycle(uint8_t wait) {
uint16_t i, j;
for(j=0; j<256*5; j++) { // 5 cycles of all colors on wheel
for(i=0; i< strip4.numPixels(); i++) {
strip4.setPixelColor(strip4.numPixels()-1-i, Wheel(((i * 256 / strip4.numPixels()) + j) & 255));
}
strip4.show();
delay(wait);
}
}
uint32_t Wheel(byte WheelPos) {
WheelPos = 255 - WheelPos;
if(WheelPos < 85) {
return strip4.Color(WheelPos * 3, (WheelPos*3)/5, 0);
}
if(WheelPos < 170) {
WheelPos -= 85;
return strip4.Color(255-WheelPos*3, (255-WheelPos*3)/4, 0);
}
WheelPos -= 170;
return strip4.Color(0, 0, 0);
}
void rainbowCycle(uint8_t wait) {
uint16_t i, j;
for(j=0; j<256*5; j++) { // 5 cycles of all colors on wheel
for(i=0; i< strip5.numPixels(); i++) {
strip5.setPixelColor(strip5.numPixels()-1-i, Wheel(((i * 256 / strip5.numPixels()) + j) & 255));
}
strip5.show();
delay(wait);
}
}
uint32_t Wheel(byte WheelPos) {
WheelPos = 255 - WheelPos;
if(WheelPos < 85) {
return strip5.Color(WheelPos * 3, (WheelPos*3)/5, 0);
}
if(WheelPos < 170) {
WheelPos -= 85;
return strip5.Color(255-WheelPos*3, (255-WheelPos*3)/4, 0);
}
WheelPos -= 170;
return strip5.Color(0, 0, 0);
}
void rainbowCycle(uint8_t wait) {
uint16_t i, j;
for(j=0; j<256*5; j++) { // 5 cycles of all colors on wheel
for(i=0; i< strip6.numPixels(); i++) {
strip6.setPixelColor(strip6.numPixels()-1-i, Wheel(((i * 256 / strip6.numPixels()) + j) & 255));
}
strip6.show();
delay(wait);
}
}
uint32_t Wheel(byte WheelPos) {
WheelPos = 255 - WheelPos;
if(WheelPos < 85) {
return strip6.Color(WheelPos * 3, (WheelPos*3)/5, 0);
}
if(WheelPos < 170) {
WheelPos -= 85;
return strip6.Color(255-WheelPos*3, (255-WheelPos*3)/4, 0);
}
WheelPos -= 170;
return strip6.Color(0, 0, 0);
}
void rainbowCycle(uint8_t wait) {
uint16_t i, j;
for(j=0; j<256*5; j++) { // 5 cycles of all colors on wheel
for(i=0; i< strip7.numPixels(); i++) {
strip7.setPixelColor(strip7.numPixels()-1-i, Wheel(((i * 256 / strip7.numPixels()) + j) & 255));
}
strip7.show();
delay(wait);
}
}
uint32_t Wheel(byte WheelPos) {
WheelPos = 255 - WheelPos;
if(WheelPos < 85) {
return strip7.Color(WheelPos * 3, (WheelPos*3)/5, 0);
}
if(WheelPos < 170) {
WheelPos -= 85;
return strip7.Color(255-WheelPos*3, (255-WheelPos*3)/4, 0);
}
WheelPos -= 170;
return strip7.Color(0, 0, 0);
}
}
i'm pretty sure what i need to change is the void loop part since it has the speed for the rainbow cycle. question is: how do i set the speed for each individual strip and get them all on at the same time?
EDIT:
i noticed some mistakes in my codes, here's the revised one.
void rainbowCycle(uint8_t wait) {
uint16_t i, j;
for(j=0; j<256*5; j++) { // 5 cycles of all colors on wheel
for(i=0; i< strip1.numPixels(); i++) {
strip1.setPixelColor(strip1.numPixels()-1-i, Wheel(((i * 256 / strip1.numPixels()) + j) & 255));
}
strip1.show();
delay(wait);
}
for(j=0; j<256*5; j++) { // 5 cycles of all colors on wheel
for(i=0; i< strip2.numPixels(); i++) {
strip2.setPixelColor(strip2.numPixels()-1-i, Wheel(((i * 256 / strip2.numPixels()) + j) & 255));
}
strip2.show();
delay(wait);
}
for(j=0; j<256*5; j++) { // 5 cycles of all colors on wheel
for(i=0; i< strip3.numPixels(); i++) {
strip3.setPixelColor(strip3.numPixels()-1-i, Wheel(((i * 256 / strip3.numPixels()) + j) & 255));
}
strip3.show();
delay(wait);
}
for(j=0; j<256*5; j++) { // 5 cycles of all colors on wheel
for(i=0; i< strip4.numPixels(); i++) {
strip4.setPixelColor(strip4.numPixels()-1-i, Wheel(((i * 256 / strip4.numPixels()) + j) & 255));
}
strip4.show();
delay(wait);
}
for(j=0; j<256*5; j++) { // 5 cycles of all colors on wheel
for(i=0; i< strip5.numPixels(); i++) {
strip5.setPixelColor(strip5.numPixels()-1-i, Wheel(((i * 256 / strip5.numPixels()) + j) & 255));
}
strip5.show();
delay(wait);
}
for(j=0; j<256*5; j++) { // 5 cycles of all colors on wheel
for(i=0; i< strip1.numPixels(); i++) {
strip6.setPixelColor(strip6.numPixels()-1-i, Wheel(((i * 256 / strip6.numPixels()) + j) & 255));
}
strip6.show();
delay(wait);
}
for(j=0; j<256*5; j++) { // 5 cycles of all colors on wheel
for(i=0; i< strip7.numPixels(); i++) {
strip7.setPixelColor(strip7.numPixels()-1-i, Wheel(((i * 256 / strip7.numPixels()) + j) & 255));
}
strip7.show();
delay(wait);
}
}
uint32_t Wheel(byte WheelPos) {
WheelPos = 255 - WheelPos;
if(WheelPos < 85) {
return strip1.Color(WheelPos * 3, (WheelPos*3)/5, 0);
return strip2.Color(WheelPos * 3, (WheelPos*3)/5, 0);
return strip3.Color(WheelPos * 3, (WheelPos*3)/5, 0);
return strip4.Color(WheelPos * 3, (WheelPos*3)/5, 0);
return strip5.Color(WheelPos * 3, (WheelPos*3)/5, 0);
return strip6.Color(WheelPos * 3, (WheelPos*3)/5, 0);
return strip7.Color(WheelPos * 3, (WheelPos*3)/5, 0);
}
if(WheelPos < 170) {
WheelPos -= 85;
return strip1.Color(255-WheelPos*3, (255-WheelPos*3)/4, 0);
return strip2.Color(255-WheelPos*3, (255-WheelPos*3)/4, 0);
return strip3.Color(255-WheelPos*3, (255-WheelPos*3)/4, 0);
return strip4.Color(255-WheelPos*3, (255-WheelPos*3)/4, 0);
return strip5.Color(255-WheelPos*3, (255-WheelPos*3)/4, 0);
return strip6.Color(255-WheelPos*3, (255-WheelPos*3)/4, 0);
return strip7.Color(255-WheelPos*3, (255-WheelPos*3)/4, 0);
}
WheelPos -= 170;
return strip1.Color(0, 0, 0);
return strip2.Color(0, 0, 0);
return strip3.Color(0, 0, 0);
return strip4.Color(0, 0, 0);
return strip5.Color(0, 0, 0);
return strip6.Color(0, 0, 0);
return strip7.Color(0, 0, 0);
}
after turning on, it seems that the strips aren't all on at the same time.