user63074: I have connected 4 Grove - RGB LED (WS2813 Mini) to D2,D3,D4,D5 on Grove Base Shield V2.0 for Arduino. How can I control the brightness and color of each LED? At the moment I only know to activated one.
Code:
#include "Adafruit_NeoPixel.h"
#define PIN            2
#define NUMPIXELS      1 
Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);
  
void setup() {
  pixels.setBrightness(125);
  pixels.begin();  
}
 
void loop() {
    pixels.setPixelColor(1, pixels.Color(255,255,255));  
    pixels.show();  
}

Thanks

user31668: Here is one of the multiple ways possible to address the problem, Basically, use a for loop and iterate the first parameter setPixelColor function to address all the LEDs. Try experimenting here:
#include "Adafruit_NeoPixel.h"
#define PIN            2
#define NUMPIXELS      4
Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);

void setup() {
  pixels.setBrightness(125);
  pixels.begin();
}

void loop()
{
  pixels.clear(); // Set all pixel colors to 'off'

  // The first NeoPixel in a strand is #0, second is 1, all the way up
  // to the count of pixels minus one.
  for (int i = 0; i < NUMPIXELS; i++) { // For each pixel...

    // pixels.Color() takes RGB values, from 0,0,0 up to 255,255,255
    // Here we're using a moderately bright green color:
    pixels.setPixelColor(i, pixels.Color(0, random(0,255), 0));

    pixels.show();   // Send the updated pixel colors to the hardware.

    delay(100); // Pause before next pass through loop
  }
}

here is quick view:


Since you are using NeoPixels, here is a list of simulated examples. you can play with the code and make your own projects online.


63074: <p>I have connected 4 Grove - RGB LED (WS2813 Mini) to D2,D3,D4,D5 on Grove Base Shield V2.0 for Arduino. How can I control the brightness and color of each LED? At the moment I only know to activated one.</p>
<p>Code:</p>
<pre><code>#include &quot;Adafruit_NeoPixel.h&quot;
#define PIN            2
#define NUMPIXELS      1 
Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);
  
void setup() {
  pixels.setBrightness(125);
  pixels.begin();  
}
 
void loop() {
    pixels.setPixelColor(1, pixels.Color(255,255,255));  
    pixels.show();  
}
</code></pre>
<p>Thanks</p>
 31668: <p>Here is one of the multiple ways possible to address the problem, Basically, use a for loop and iterate the first parameter setPixelColor function to address all the LEDs. Try experimenting <a href="https://wokwi.com/arduino/projects/303848371358007874" rel="nofollow noreferrer">here</a>:</p>
<pre><code>#include &quot;Adafruit_NeoPixel.h&quot;
#define PIN            2
#define NUMPIXELS      4
Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);

void setup() {
  pixels.setBrightness(125);
  pixels.begin();
}

void loop()
{
  pixels.clear(); // Set all pixel colors to 'off'

  // The first NeoPixel in a strand is #0, second is 1, all the way up
  // to the count of pixels minus one.
  for (int i = 0; i &lt; NUMPIXELS; i++) { // For each pixel...

    // pixels.Color() takes RGB values, from 0,0,0 up to 255,255,255
    // Here we're using a moderately bright green color:
    pixels.setPixelColor(i, pixels.Color(0, random(0,255), 0));

    pixels.show();   // Send the updated pixel colors to the hardware.

    delay(100); // Pause before next pass through loop
  }
}
</code></pre>
<p>here is quick view:</p>
<p><a href="https://i.stack.imgur.com/Dkw4b.gif" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Dkw4b.gif" alt="enter image description here" /></a></p>
<blockquote class="spoiler">
<p>Since you are using NeoPixels, <a href="https://wokwi.com/arduino/libraries/Adafruit_NeoPixel" rel="nofollow noreferrer">here</a> is a list of simulated examples. you can play with the code and make your own projects online.</p>
</blockquote>
