user51533: I am as new as new can be to the Arduino world and have been playing around with them.  I have a few "Arduino Uno" boards that I purchased and have successfully loaded sketches to them.  However I am having problems figuring out how to write code in a simple manner.
I am  using a LED strip of WS2812 LEDs (similar to this). Here is what I would like to achieve:
I would like to be able to light  "lets say"  LEDs  1, 3, 5, 7.  Then light LEDs 2, 4, 6, 8  or any other combination of "multiple LEDs", by that I mean maybe LEDs 0, 14, 15, 36, 37, 52, 54.  I am sure you get the idea.
Can I write a single line code to light these LEDs or do I have to write out each line.  
Sorry if this is a simplistic question, but I have searched and have not seen anything that may accomplish this, or I just over looked it.
Thanks in advance for your help 

user51538: I have to say that I do not have any experience with the ws2812 led strip but basically it is used with the Adafruit_Neopixel library where you have the function pixel_obj.setPixelColor(pixel_number,pixel_obj.Color(R,G,B)
and the function pixel_obj.show().
Now you basically want to make the code in void loop() clean and there is a wide choice of possibilities and techniques to use. The simplest is not to do it, but if you want you can write a library to do it or write a function that takes the number of the pins and light 'em up (all with the same color), like this
void light_pixel(int pixels[],int Red,int Green,int Blue){
    for(int i=0;i<NUMPIXELS;++i){
        pixel_obj.setPixelColor(pixels[i],pixel_obj.Color(Red,Green,Blue));
    }
    pixel_obj.show();
}
This works assuming you have declared pixel_obj in the outermost scope, and you will call the function like this:
#include <Adafruit_NeoPixel.h>
#define PIN //Whatever you pin is
#define NUMPIXELS //Thenumber of the pixels in your strip
Adafruit_NeoPixel pixel_obj = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);
// You may have to modify the third parameter Rationale: You didn't 
// specified anything about your led strip
void setup(){
pixel_obj.begin();
pinMode(PIN, OUTPUT);
}
void light_pixel(int pixels[],int Red, int Green, int Blue){
for(int i=0;i<NUMPIXELS && pixels[I]!=-1 ;++i){
    pixel_obj.setPixelColor(pixels[i],pixel_obj.Color(Red,Green,Blue));
}
pixel_obj.show();
}
void loop(){
int my_pixels[NUMPIXELS]={1,3,5,7,-1}; // Using -1 as terminator
// Initialize the array . Disclaimer: this is not optimised and you might use
// new opearator or better pass the reference of a vector to the function so
// that you can modify the range of the vector and have a more concise function
light_pixel(my_pixels,255,255,255);
delay(1000);
light_pixel(my_pixels,0,0,0);
}

Then you can change the number of my_pixels with a smile array assignment
This function is just a sample to get the job done but I'd recommend you to study further the C/C++ programming language in general in order to write better code
Good Luck!

51533: <p>I am as new as new can be to the Arduino world and have been playing around with them.  I have a few "Arduino Uno" boards that I purchased and have successfully loaded sketches to them.  However I am having problems figuring out how to write code in a simple manner.</p>

<p>I am  using a LED strip of <a href="https://cdn-shop.adafruit.com/datasheets/WS2812.pdf" rel="nofollow noreferrer">WS2812 LEDs</a> (similar to <a href="https://www.adafruit.com/product/1138?length=1" rel="nofollow noreferrer">this</a>). Here is what I would like to achieve:</p>

<p>I would like to be able to light  "lets say"  LEDs  <code>1, 3, 5, 7</code>.  Then light LEDs <code>2, 4, 6, 8</code>  or any other combination of "multiple LEDs", by that I mean maybe LEDs <code>0, 14, 15, 36, 37, 52, 54</code>.  I am sure you get the idea.</p>

<p>Can I write a single line code to light these LEDs or do I have to write out each line.  </p>

<p>Sorry if this is a simplistic question, but I have searched and have not seen anything that may accomplish this, or I just over looked it.</p>

<p>Thanks in advance for your help </p>
 51538: <p>I have to say that I do not have any experience with the ws2812 led strip but basically it is used with the Adafruit_Neopixel library where you have the function <code>pixel_obj.setPixelColor(pixel_number,pixel_obj.Color(R,G,B)</code>
and the function <code>pixel_obj.show()</code>.
Now you basically want to make the code in <code>void loop()</code> clean and there is a wide choice of possibilities and techniques to use. The simplest is not to do it, but if you want you can write a library to do it or write a function that takes the number of the pins and light 'em up (all with the same color), like this<br>
<code>void light_pixel(int pixels[],int Red,int Green,int Blue){
    for(int i=0;i&lt;NUMPIXELS;++i){
        pixel_obj.setPixelColor(pixels[i],pixel_obj.Color(Red,Green,Blue));
    }
    pixel_obj.show();
}</code><br>
This works assuming you have declared pixel_obj in the outermost scope, and you will call the function like this:<br></p>

<pre><code>#include &lt;Adafruit_NeoPixel.h&gt;
#define PIN //Whatever you pin is
#define NUMPIXELS //Thenumber of the pixels in your strip
Adafruit_NeoPixel pixel_obj = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);
// You may have to modify the third parameter Rationale: You didn't 
// specified anything about your led strip
void setup(){
pixel_obj.begin();
pinMode(PIN, OUTPUT);
}
void light_pixel(int pixels[],int Red, int Green, int Blue){
for(int i=0;i&lt;NUMPIXELS &amp;&amp; pixels[I]!=-1 ;++i){
    pixel_obj.setPixelColor(pixels[i],pixel_obj.Color(Red,Green,Blue));
}
pixel_obj.show();
}
void loop(){
int my_pixels[NUMPIXELS]={1,3,5,7,-1}; // Using -1 as terminator
// Initialize the array . Disclaimer: this is not optimised and you might use
// new opearator or better pass the reference of a vector to the function so
// that you can modify the range of the vector and have a more concise function
light_pixel(my_pixels,255,255,255);
delay(1000);
light_pixel(my_pixels,0,0,0);
}
</code></pre>

<p>Then you can change the number of my_pixels with a smile array assignment
This function is just a sample to get the job done but I'd recommend you to study further the C/C++ programming language in general in order to write better code<br>
Good Luck!</p>
