How to address all LED's with Adafruit Dotstar

Dear all, im very new to this forum and to Arduino, so sorry for any stupid questions !
I have tried my best solving my problem, and looked through the internet for solutions.

It's a very simple problem, I have a Adafruit Dotstar LED strip, and I would like to address all 144 LEDs in the command -> strip.setPixelColor(n,blue, red, green); <- n is the LED from 0 to 143

Is it possible to address all LED in a single command? If yes, how do I do it?

I have looked into arrays, but could not make it to work.
Thanks on beforehand

Full program:


#include <Adafruit_DotStar.h>
#include <SPI.h>
#define NUMPIXELS 144 // Number of LEDs in strip
#define DATAPIN 4
#define CLOCKPIN 5
Adafruit_DotStar strip = Adafruit_DotStar(NUMPIXELS, DATAPIN, CLOCKPIN);

void setup() {
#if defined(AVR_ATtiny85) && (F_CPU == 16000000L)
clock_prescale_set(clock_div_1); // Enable 16 MHz on Trinket
#endif
strip.begin(); // Initialize pins for output
strip.show(); // Turn all LEDs off ASAP
}

int head = 0, tail = -10; // Index of first 'on' and 'off' pixels
uint32_t color = 0xFF0000; // 'On' color (starts red)
int i = 0;
int red = 0;
int green = 0;
int blue = 0;
int time = 2;
int newtime = 0;
int rednew = 0;
int greennew = 0;
int bluenew = 0;

void loop() {

strip.setBrightness(100);

strip.setPixelColor(0,255, 255, 255);
strip.show();

}

You can go trough all 144 LEDs very fast using a for loop.

for(byte x=0;x<144;x++)
{
strip.setPixelColor(x,255, 255, 255);
}
strip.show();

.

Thank you for your reply LarryD,

But I need to make all LED's turn on instantly. Exactly as if I put in the function several times, with different LEDs. Se below:

strip.setPixelColor(1,255, 255, 255);
strip.setPixelColor(2,255, 255, 255);
strip.setPixelColor(3,255, 255, 255);
strip.setPixelColor(4,255, 255, 255);

Don't they update together at some time after the clock stops?

But I need to make all LED's turn on instantly. E

As far as your eyes can see they will turn on at the same time.

Hildebrando:
Thank you for your reply LarryD,

But I need to make all LED's turn on instantly. Exactly as if I put in the function several times, with different LEDs. Se below:

strip.setPixelColor(1,255, 255, 255);
strip.setPixelColor(2,255, 255, 255);
strip.setPixelColor(3,255, 255, 255);
strip.setPixelColor(4,255, 255, 255);

Looking at the code, each pixel receives its configuration for a new colour first. Only after the command strip.show() is used they'll show their new colour.

Both pieces of code below should have the same result, 4 leds being turned on simultaneous after 2 seconds.

strip.setPixelColor(1,255, 255, 255); 
delay(500);   
strip.setPixelColor(2,255, 255, 255); 
delay(500);      
strip.setPixelColor(3,255, 255, 255);   
delay(500);    
strip.setPixelColor(4,255, 255, 255);   
delay(500);   
strip.show();
strip.setPixelColor(1,255, 255, 255); 
strip.setPixelColor(2,255, 255, 255); 
strip.setPixelColor(3,255, 255, 255);   
strip.setPixelColor(4,255, 255, 255);   
delay(2000);   
strip.show();

LarryD - you are right, it works :slight_smile:

Thanks a lot

LarryD:
As far as your eyes can see they will turn on at the same time.

Hi,

I tried to use this code

  for(uint16_t i=0; i<strip.numPixels(); i++) {
    strip.setPixelColor(i,0,0,255); //blue
    strip.show();

  }

and I can clearly see the LEDs 'running up' one by one, even though it's really fast. Any idea what i'm doing wrong?

Put "strip.show( )" AFTER the for loop -- not inside of it.

Because of the need to send the data to the NeoPixels in one uninterrupted stream, the code uses a buffer array which is set up with the necessary coding in advance by the strip.setPixelColor() function, then streamed out to the NeoPixels when you issue the "strip.show( )" command.

I strongly recommend to use the FastLED library for driving adressable leds.

Fill all leds with one RGB color:

fill_solid( leds, NUM_LEDS, CRGB( red, green, blue) );

Fill all leds with one HSV color:

fill_solid( leds, NUM_LEDS, CHSV( hue, saturation, brightness) );

Allow me a little "nit" which will change nothing.

These "neopixel" things are in no way addressable. You do not send them an address. There is no hardware in them
which interprets anything about the data stream as an address. You can't program LED number 5 with data by using an
address. You might have an array that holds the color information and you get to that via an index, but that is not an LED
address. That "address" is in your micro's physical memory.

Maybe they should be called "indexable LEDs". That would make a little more sense.

"Serial LEDs" describes them pretty well.

If these LEDs are addressable, then a chain of 74164s are addressable shift-registers.

Sorry for the rant.

Sorry for the rant.

Appreciated.

I'm already happy when people don't call them "intelligent" leds...