How do I Sequence through a string of NeoPixels

EL Wire/Tape/Panels, LEDs, pixels and strips, LCDs and TFTs, etc products from Adafruit

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
seanmc2
 
Posts: 7
Joined: Thu Jan 15, 2015 10:31 pm

How do I Sequence through a string of NeoPixels

Post by seanmc2 »

I seem to be missing something in my understanding on how to turn on and off a sequence of NeoPixels. What I want to do (first part of the code included below) is to turn on several NeoPixels in a strip (code attached), sequentially, and them turn them back off again in sequence.

Code: Select all

#include <Adafruit_NeoPixel.h>
#define PIN 6

// Parameter 1 = number of pixels in strip
// Parameter 2 = Arduino pin number (most are valid)
// Parameter 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)
Adafruit_NeoPixel strip = Adafruit_NeoPixel(1, PIN, NEO_GRB + NEO_KHZ800);

void setup() {
  strip.begin();
  strip.show(); // Initialize all pixels to 'off'
}

void loop(){
  strip.show();
for (int pNum = 0; pNum<60; pNum++){
  strip.setPixelColor(pNum, 0,0, 64);
  strip.show();
  delay(1000);
  
  strip.setPixelColor(0,0,0,64);
  delay(500);
  
  strip.setPixelColor(1,0,0,64);
  delay(500);
  strip.show();
  strip.setPixelColor(2,0,0,64);
  delay(500);
    strip.show();
  strip.setPixelColor(3,0,0,64);
  delay(100);
    strip.show();
  strip.setPixelColor(4,0,0,64);
  delay(500);
    strip.show();
  strip.setPixelColor(5,0,0,64);
  delay(500);
    strip.show();
} // end for loop
}// end loop
Last edited by adafruit_support_bill on Mon Jan 19, 2015 6:28 pm, edited 1 time in total.
Reason: please use the </> button when submitting code. press </>, then paste your code between the [code] [/code] tags.

User avatar
adafruit_support_bill
 
Posts: 88142
Joined: Sat Feb 07, 2009 10:11 am

Re: How do I Sequence through a string of NeoPixels

Post by adafruit_support_bill »

please use the </> button when submitting code. press </>, then paste your code between the

Code: Select all

 
tags.

All of your setPixelColor commands are setting the pixels to the same color blue : R=0, G=0 and B=64. To turn a pixel off, the color should be 0,0,0.

User avatar
seanmc2
 
Posts: 7
Joined: Thu Jan 15, 2015 10:31 pm

Re: How do I Sequence through a string of NeoPixels

Post by seanmc2 »

I understand that setting a color argument to 0 turns the device off. My problem is that they don't get turned on in sequence... only one LED come on.

If I loop through them,

Code: Select all

void loop(){
 strip.setPixelColor(0,0,0,64);
  delay(500);
   strip.show();

 strip.setPixelColor(1,0,0,64);
  delay(500);
   strip.show();

 strip.setPixelColor(2,0,0,64);
  delay(500);
   strip.show();

}
Shouldn't this turn the thee NeoPIxels (0,1, &2 ) in sequence with a 500ms delay between?

User avatar
adafruit_support_bill
 
Posts: 88142
Joined: Sat Feb 07, 2009 10:11 am

Re: How do I Sequence through a string of NeoPixels

Post by adafruit_support_bill »

It should. Have you tested that your strip works with the strandtest example?

User avatar
chemdoc77
 
Posts: 148
Joined: Mon Jan 28, 2013 9:32 am

Re: How do I Sequence through a string of NeoPixels

Post by chemdoc77 »

Hi Seanmc2:

In your code you have:

Code: Select all

Adafruit_NeoPixel strip = Adafruit_NeoPixel(1, PIN, NEO_GRB + NEO_KHZ800);
The number “1” refers to how many NeoPixels you are using. If you are using three NeoPixels as in your last post, you need to have the following:

Code: Select all

Adafruit_NeoPixel strip = Adafruit_NeoPixel(3, PIN, NEO_GRB + NEO_KHZ800);
If the strip is larger and has 60 NeoPixels then change the "3" to "60".

Best Regards,
Chemdoc77

User avatar
seanmc2
 
Posts: 7
Joined: Thu Jan 15, 2015 10:31 pm

Re: How do I Sequence through a string of NeoPixels

Post by seanmc2 »

Chemdoc77,

Thanks!! That did the trick. I'm not surprised that it was something so simple... duh!! LOL... thanks again.

Locked
Please be positive and constructive with your questions and comments.

Return to “Glowy things (LCD, LED, TFT, EL) purchased at Adafruit”