Hi all, I’m new to use Arduino’s so go easy on me
I am trying to make two neopixel 16 pixel rings flash like police sirens for a costume.
I have found some code online which works perfectly for what I want to achieve.
The problem I have is trying to get the other neopixel ring to mirror the first neopixel ring.
I have tried defining a extra Pin hoping that it would pump the same code to both pins.
I also tried connecting the D-Out to the D-In on the neopixels hoping the signal would pass though.
But only one side will flash. I have swapped the cables over and both neopixels work fine but only one will flash so it points to the code and not the wiring.
Here is the code I’m trying to figure out:
#include <Adafruit_NeoPixel.h>
#define PIN 6
int Pixels = 16;
Adafruit_NeoPixel strip = Adafruit_NeoPixel(Pixels, PIN, NEO_GRB + NEO_KHZ800);
void setup()
{
strip.begin();
strip.show(); //Initilize strip to all off
}
void loop()
{
delay(50);
redFlash(); //call redFlash funtion
delay(50);
blueFlash(); //Call blueFlash function
}
void redFlash()
{
for (int x=0; x<=3; x++){
red(strip.Color(255, 0, 0), 10); //call Red funtion - pass it color and dleay values
red(strip.Color(0, 0, 0), 0); //Turn off all pixels
delay(75);
}
} //end redFlash
void blueFlash()
{
for (int x=0; x<=3; x++){
blue(strip.Color(0, 0, 255), 10); //call blue funtion - pass it color and dleay values
blue(strip.Color(0, 0, 0), 0); //Turn off all pixels
delay(75);
}
} //end blueFlash
void red(uint32_t c, uint8_t wait) //passed color (c) and delay (wait) values
{
int i = 0; //start at pixel 0
while (i < Pixels/2) //loop until you reach half the pixels
{
strip.setPixelColor(i, c); //sets the pixel and color
i++;
}
strip.show(); //turns on the pixels
delay(wait); //wait designated time (wait)
} //end red
void blue(uint32_t c, uint8_t wait) //passed color (c) and delay (wait) values
{
int i = Pixels+1; //start at the last pixel
while (i > Pixels/2-1) //loop until you reach half the pixels
{
strip.setPixelColor(i, c); //sets pixel and color
i--;
}
strip.show(); //turns on pixels
delay(wait); //wait designated time (wait)
} //end blue
I’m hoping this is something simple to correct?
Many Thanks in advance guys!