0

Multiple Neopixel neons animating in a continuous sequence
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Multiple Neopixel neons animating in a continuous sequence

by xuan123 on Wed Feb 10, 2021 5:33 am

Hello!

I recently just purchased a few neopixel Neon strips, and am looking to program them in a manner that two(or more in the future) strips form one continuous strand effect. I modified one of the sample codes, hoping to achieve that effect, but instead the two strips animate the same thing simultaneously.

Would including a delay in between 'strip' and 'strip 2' work?

Please let me know if I need to include the circuit, I followed the diagram on the Adafruit site :-)

Code: Select all | TOGGLE FULL SIZE
// A basic everyday NeoPixel strip test program.

// NEOPIXEL BEST PRACTICES for most reliable operation:
// - Add 1000 uF CAPACITOR between NeoPixel strip's + and - connections.
// - MINIMIZE WIRING LENGTH between microcontroller board and first pixel.
// - NeoPixel strip's DATA-IN should pass through a 300-500 OHM RESISTOR.
// - AVOID connecting NeoPixels on a LIVE CIRCUIT. If you must, ALWAYS
//   connect GROUND (-) first, then +, then data.
// - When using a 3.3V microcontroller with a 5V-powered NeoPixel strip,
//   a LOGIC-LEVEL CONVERTER on the data line is STRONGLY RECOMMENDED.
// (Skipping these may work OK on your workbench but can fail in the field)

#include <Adafruit_NeoPixel.h>
#ifdef __AVR__
 #include <avr/power.h> // Required for 16 MHz Adafruit Trinket
#endif

// Which pin on the Arduino is connected to the NeoPixels?
// On a Trinket or Gemma we suggest changing this to 1:
#define LED_PIN    6
#define LED_PIN2    7

// How many NeoPixels are attached to the Arduino?
#define LED_COUNT 60

// Declare our NeoPixel strip object:
Adafruit_NeoPixel strip(LED_COUNT, LED_PIN, NEO_GRB + NEO_KHZ800);
Adafruit_NeoPixel strip2(LED_COUNT, LED_PIN2, NEO_GRB + NEO_KHZ800);
// Argument 1 = Number of pixels in NeoPixel strip
// Argument 2 = Arduino pin number (most are valid)
// Argument 3 = Pixel type flags, add together as needed:
//   NEO_KHZ800  800 KHz bitstream (most NeoPixel products w/WS2812 LEDs)
//   NEO_KHZ400  400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers)
//   NEO_GRB     Pixels are wired for GRB bitstream (most NeoPixel products)
//   NEO_RGB     Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2)
//   NEO_RGBW    Pixels are wired for RGBW bitstream (NeoPixel RGBW products)


// setup() function -- runs once at startup --------------------------------

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.

  strip.begin();           // INITIALIZE NeoPixel strip object (REQUIRED)
  strip.show();            // Turn OFF all pixels ASAP
  strip.setBrightness(50); // Set BRIGHTNESS to about 1/5 (max = 255)

  strip2.begin();           // INITIALIZE NeoPixel strip object (REQUIRED)
  strip2.show();            // Turn OFF all pixels ASAP
  strip2.setBrightness(50); // Set BRIGHTNESS to about 1/5 (max = 255)
}


// loop() function -- runs repeatedly as long as board is on ---------------

void loop() {
  // Fill along the length of the strip in various colors...
  colorWipe(strip.Color(255,   0,   0), 50); // Red
  colorWipe(strip.Color(  0, 255,   0), 50); // Green
  colorWipe(strip.Color(  0,   0, 255), 50); // Blue

  colorWipe(strip2.Color(  0, 255,   0), 50); // Green
  colorWipe(strip2.Color(  0,   0, 255), 50); // Blue
  colorWipe(strip2.Color(255,   0,   0), 50); // Red
}


// Some functions of our own for creating animated effects -----------------

// Fill strip pixels one after another with a color. Strip is NOT cleared
// first; anything there will be covered pixel by pixel. Pass in color
// (as a single 'packed' 32-bit value, which you can get by calling
// strip.Color(red, green, blue) as shown in the loop() function above),
// and a delay time (in milliseconds) between pixels.
void colorWipe(uint32_t color, int wait) {
  for(int i=0; i<strip.numPixels(); i++) { // For each pixel in strip...
    strip.setPixelColor(i, color);         //  Set pixel's color (in RAM)
    strip.show();                          //  Update strip to match
    delay(wait);                           //  Pause for a moment

    strip2.setPixelColor(i, color);         //  Set pixel's color (in RAM)
    strip2.show();                          //  Update strip to match
    delay(wait);                           //  Pause for a moment
  }


}


Thank you!

xuan123
 
Posts: 5
Joined: Wed Feb 10, 2021 5:27 am

Re: Multiple Neopixel neons animating in a continuous sequen

by adafruit_support_bill on Wed Feb 10, 2021 7:21 am

Your color-wipe is writing to both strips in the same 'for' loop. To have them run sequentially, you would need two loops: One for the first strip, then another one for the second strip.

adafruit_support_bill
 
Posts: 80311
Joined: Sat Feb 07, 2009 10:11 am

Re: Multiple Neopixel neons animating in a continuous sequen

by xuan123 on Thu Feb 11, 2021 1:37 am

Thank you Bill! It worked :-)

xuan123
 
Posts: 5
Joined: Wed Feb 10, 2021 5:27 am

Re: Multiple Neopixel neons animating in a continuous sequen

by adafruit_support_bill on Thu Feb 11, 2021 7:12 am

Good to hear that worked. Thanks for the update.

adafruit_support_bill
 
Posts: 80311
Joined: Sat Feb 07, 2009 10:11 am

Re: Multiple Neopixel neons animating in a continuous sequen

by xuan123 on Mon Feb 22, 2021 5:06 am

Hello!

Continuing with my previous aim of achieving a continuous effect between multiple neons, I realized that my strips are delayed in effect, which looks less continuous.
Could you help me check with my code?

Code: Select all | TOGGLE FULL SIZE
// A basic everyday NeoPixel strip test program.

// NEOPIXEL BEST PRACTICES for most reliable operation:
// - Add 1000 uF CAPACITOR between NeoPixel strip's + and - connections.
// - MINIMIZE WIRING LENGTH between microcontroller board and first pixel.
// - NeoPixel strip's DATA-IN should pass through a 300-500 OHM RESISTOR.
// - AVOID connecting NeoPixels on a LIVE CIRCUIT. If you must, ALWAYS
//   connect GROUND (-) first, then +, then data.
// - When using a 3.3V microcontroller with a 5V-powered NeoPixel strip,
//   a LOGIC-LEVEL CONVERTER on the data line is STRONGLY RECOMMENDED.
// (Skipping these may work OK on your workbench but can fail in the field)

#include <Adafruit_NeoPixel.h>
#ifdef __AVR__
#include <avr/power.h> // Required for 16 MHz Adafruit Trinket
#endif

// Which pin on the Arduino is connected to the NeoPixels?
// On a Trinket or Gemma we suggest changing this to 1:
#define LED_PIN    6
#define LED_PIN2    7

// How many NeoPixels are attached to the Arduino?
#define LED_COUNT 60

// Declare our NeoPixel strip object:
Adafruit_NeoPixel strip(LED_COUNT, LED_PIN, NEO_GRB + NEO_KHZ800);
Adafruit_NeoPixel strip2(LED_COUNT, LED_PIN2, NEO_GRB + NEO_KHZ800);
// Argument 1 = Number of pixels in NeoPixel strip
// Argument 2 = Arduino pin number (most are valid)
// Argument 3 = Pixel type flags, add together as needed:
//   NEO_KHZ800  800 KHz bitstream (most NeoPixel products w/WS2812 LEDs)
//   NEO_KHZ400  400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers)
//   NEO_GRB     Pixels are wired for GRB bitstream (most NeoPixel products)
//   NEO_RGB     Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2)
//   NEO_RGBW    Pixels are wired for RGBW bitstream (NeoPixel RGBW products)


// setup() function -- runs once at startup --------------------------------

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.

  strip.begin();           // INITIALIZE NeoPixel strip object (REQUIRED)
  strip.show();            // Turn OFF all pixels ASAP
  strip.setBrightness(50); // Set BRIGHTNESS to about 1/5 (max = 255)

  strip2.begin();           // INITIALIZE NeoPixel strip object (REQUIRED)
  strip2.show();            // Turn OFF all pixels ASAP
  strip2.setBrightness(50); // Set BRIGHTNESS to about 1/5 (max = 255)
}


// loop() function -- runs repeatedly as long as board is on ---------------

void loop() {
  // Fill along the length of the strip in various colors...
  colorWipe(strip.Color(  0, 255,   0), 50); // Green
  colorWipe2(strip2.Color(  0, 255,   0), 50); // Green
  colorWipe(strip.Color(  0,   0, 255), 50); // Blue
  colorWipe2(strip2.Color(  0,   0, 255), 50); // Blue

}

// Some functions of our own for creating animated effects -----------------

// Fill strip pixels one after another with a color. Strip is NOT cleared
// first; anything there will be covered pixel by pixel. Pass in color
// (as a single 'packed' 32-bit value, which you can get by calling
// strip.Color(red, green, blue) as shown in the loop() function above),
// and a delay time (in milliseconds) between pixels.
void colorWipe(uint32_t color, int wait) {
  for (int i = 0; i < strip.numPixels(); i++) { // For each pixel in strip...
    strip.setPixelColor(i, color);         //  Set pixel's color (in RAM)
    strip.show();                          //  Update strip to match
    delay(50);                           //  Pause for a moment
  }
    }

void colorWipe2(uint32_t color, int wait) {
  for (int i = 0; i < strip.numPixels(); i++) { // For each pixel in strip...
     strip2.setPixelColor(i, color);         //  Set pixel's color (in RAM)
     strip2.show();                          //  Update strip to match
     delay(50);                           //  Pause for a moment
    }
  }

 
 


Additionally, if there are alternative ways that can control multiple strips (perhaps even more effectively), it would be great if you could direct me to them!

Cheers!

xuan123
 
Posts: 5
Joined: Wed Feb 10, 2021 5:27 am

Re: Multiple Neopixel neons animating in a continuous sequen

by adafruit_support_bill on Mon Feb 22, 2021 7:15 am

To make it completely seamless, the best way is to connect the output of the first strip to the input of the second strip and treat it as one long strip in your code.

adafruit_support_bill
 
Posts: 80311
Joined: Sat Feb 07, 2009 10:11 am

Re: Multiple Neopixel neons animating in a continuous sequen

by xuan123 on Mon Feb 22, 2021 9:32 pm

Hi Bill,

Thanks for replying! Do you mean something like this? > https://images.app.goo.gl/DjFiXbuFesVzQ6Hv9

If i'm using an Ada Fruit NeoPixel Neon, it does not have an output on the other end. Is there another way to resolve this? Thank you!
Attachments
9EC3248C-B574-4643-B52E-68EDC9B70084.gif
9EC3248C-B574-4643-B52E-68EDC9B70084.gif (13.92 KiB) Viewed 36 times

xuan123
 
Posts: 5
Joined: Wed Feb 10, 2021 5:27 am

Re: Multiple Neopixel neons animating in a continuous sequen

by adafruit_support_bill on Mon Feb 22, 2021 9:44 pm

Your drawing is correct. All Neopixel chips have outputs. Unfortunately, the neon style strips have end-caps covering them. You would need to carefully cut it away to locate the solder pad for the output.

How much of a delay are you seeing between strips? Looking at your code, I'd expect it to be milliseconds at most.

adafruit_support_bill
 
Posts: 80311
Joined: Sat Feb 07, 2009 10:11 am

Re: Multiple Neopixel neons animating in a continuous sequen

by xuan123 on Mon Feb 22, 2021 9:51 pm

Oh i see! I'll probably try and carefully cut the silicone part of the neon then :)

For the code above, i connected it in parallel instead of series, and the delay is about 2 seconds the last time i tried.

xuan123
 
Posts: 5
Joined: Wed Feb 10, 2021 5:27 am

Re: Multiple Neopixel neons animating in a continuous sequen

by adafruit_support_bill on Tue Feb 23, 2021 7:10 am

I see the problem now: The Neon strips have 60 pixels, but they are connected in groups of 3. So, from a software perspective it only looks like 20 pixels.

You have your strips defined as 60 pixels long and you have a 50 millisecond delay in your ColorWipe loop. So it will take about 1 second to fill all 20 'virtual' pixels, but 3 seconds to complete the loop. That is why you are seeing a 2 second delay.

To eliminate the delay, just change your LED_COUNT to 20.

adafruit_support_bill
 
Posts: 80311
Joined: Sat Feb 07, 2009 10:11 am

Please be positive and constructive with your questions and comments.