Neopixel WS2812B need find code int

I’ve been working with neopixel WS2812B strips on a Uno. something only just sample code, I would like to make one line like this " pixels.setPixelColor(PXL1[0], pixels.Color(0,0,139)); " not want many line for one pixel each, example 10 pixels together same time all on in one line, and other separate 10 pixels.

#include <Adafruit_NeoPixel.h>

const int PXL1[] = {0,1,2,3,4,5,6,7,8,9};
const int PXL2[] = {10,11,12,13,14,15,16,17,18,19};

#define PIN 3
#define NUMPIXELS 20

Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);

void setup() {

pixels.begin(); // This initializes the NeoPixel library.

}

void loop() {

pixels.setPixelColor(PXL1[0], pixels.Color(0,0,139));
pixels.show();
delay(200);

pixels.setPixelColor(PXL1[0], pixels.Color(0,0,0));
pixels.show();
delay(200);

pixels.setPixelColor(PXL2[0], pixels.Color(0,0,139));
pixels.show();
delay(200);

pixels.setPixelColor(PXL2[0], pixels.Color(0,0,0));
pixels.show();
delay(200);
}

something different with [0] for count add from 0,.....,9 only for Arrow, not together all on, how only one line is easy for example 10 pixels all on.

Your post was MOVED to its current location as it is more suitable.

Could you also take a few moments to Learn How To Use The Forum.

Other general help and troubleshooting advice can be found here.
It will help you get the best out of the forum in the future.

@andydt Why do users choose to ignore the advice on posting code ?

The easier you make it to read and copy your code the more likely it is that you will get help

Please follow the advice given in the link below when posting code , use code tags and post the code here

As to your question, it sounds like you need to use a for loop to run basically the same code line a number of times.

If the code line needs different parameters each time it is run in the for loop then consider putting the values in an array and accessing that using the for loop variable

You have to use of for() loop to iterate over all the pixels in either PXL1 or PXL2..

#include <Adafruit_NeoPixel.h>

const int PXL1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
const int PXL2[] = {10, 11, 12, 13, 14, 15, 16, 17, 18, 19};
const int numPXL1 = sizeof(PXL1) / sizeof(PXL1[0]);
const int numPXL2 = sizeof(PXL2) / sizeof(PXL2[0]);

#define PIN 3
#define NUMPIXELS 20

Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);

void setup() {

  pixels.begin(); // This initializes the NeoPixel library.

}

void loop() {

  for ( int i = 0; i < numPXL1; ++i ) {
    pixels.setPixelColor(PXL1[i], pixels.Color(0, 0, 139));
  }
  pixels.show();
  delay(200);

Hi UKHeliBob,

I'm sorry, yeah I read follow the rules about forum and use code tags, I understand easy to Ctrl + E and put paste code, now I realized clear, long time ago last time I was a login, thanks.

It's perfect working, thank you very much for your help.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.