Go Down

Topic: How to program LED Pixel WS 2811 with strobe, delay and rgb color (Read 539 times) previous topic - next topic

Susannella_Stracciatella

Jan 17, 2019, 09:44 am Last Edit: Jan 17, 2019, 10:32 am by Susannella_Stracciatella
Hello community,

I have a project with 5 LED stripes (each has 216 LEDs). The LEDs are powered with an power supply adapter. So i just connected the ground and the Data with my Arduino uno. It works. Next step...

I have different RGB colors and I want them to wipe in and then to strobe for 30 sec.
These are my RGB Colors.

uint32_t pluto = strip.Color (0 , 153, 153);
uint32_t neptun = strip.Color (255 , 0, 165);
uint32_t uranus = strip.Color (255 , 0, 165);
uint32_t saturn = strip.Color (0, 153, 255);
uint32_t jupiter = strip.Color (255, 0, 0);
uint32_t mars = strip.Color (0, 153, 255);
uint32_t erde = strip.Color (0, 153, 153);
uint32_t seele = strip.Color (204, 0, 255);
uint32_t synMond = strip.Color (255, 153, 0);
uint32_t sonne = strip.Color (153, 204, 0);
uint32_t jahreston = strip.Color (0, 153, 153);
uint32_t merkur = strip.Color (0, 153, 153);
uint32_t venus = strip.Color (204, 0, 255);
uint32_t platJahreston = strip.Color (204, 0, 102);
uint32_t Tageslicht = strip.Color (127, 127, 127);

So now I can put them on LEDS with colorwipe, like this: colorWipe(pluto, 50); // Pluto
but how to strobe them for 30 sec each, one after another? I know that Arduino works in Microsec...can someone help me please. I canĀ“t find a sketch like this. I also have problems to create the color orange. Someone had the same problem?

After the last strobe of "platJahreston" I want it to switch to "tageslicht" (white) without wipe and strobe and this has to slowly fade out. Any ideas?

Thank you very much for your help.

sterretje

And the rest of your code?

Please use code tags when posting code; see How to use this forum - please read, specifically point 7.
If you understand an example, use it.
If you don't understand an example, don't use it.

Electronics engineer by trade, software engineer by profession. Trying to get back into electronics after 15 years absence.

Susannella_Stracciatella

This is my code for now. I`m a beginner and just trying to see other codes, understand them and to work with them. But i couldn't find a solution for my topic. I don't know where to add the strobe and the delay. Is it possible to time them for 30 sec?

Code: [Select]

#include <Adafruit_NeoPixel.h>
#ifdef AVR
  #include <avr/power.h>
#endif

#define PIN 7

#define BRIGHTNESS 50

// 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)
//   NEO_RGBW    Pixels are wired for RGBW bitstream (NeoPixel RGBW products)
Adafruit_NeoPixel strip = Adafruit_NeoPixel(216, PIN, NEO_GRB + NEO_KHZ800);

// IMPORTANT: To reduce NeoPixel burnout risk, add 1000 uF capacitor across
// pixel power leads, add 300 - 500 Ohm resistor on first pixel's data input
// and minimize distance between Arduino and first pixel.  Avoid connecting
// on a live circuit...if you must, connect GND first.

  strip.setBrightness(BRIGHTNESS);
 
  strip.begin();
  strip.show(); // Initialize all pixels to 'off'
}

uint32_t pluto = strip.Color(0 , 153, 153);
uint32_t neptun = strip.Color(255 , 0, 165);
uint32_t uranus = strip.Color(255 , 0, 165);
uint32_t saturn = strip.Color(0, 153, 255);
uint32_t jupiter = strip.Color(255, 0, 0);
uint32_t mars = strip.Color(0, 153, 255);
uint32_t erde = strip.Color(0, 153, 153);
uint32_t seele = strip.Color( 204, 0, 255);
uint32_t synMond = strip.Color(255, 153, 0);
uint32_t sonne = strip.Color(153, 204, 0);
uint32_t jahreston = strip.Color(0, 153, 153);
uint32_t merkur = strip.Color(0, 153, 153);
uint32_t venus = strip.Color(204, 0, 255);
uint32_t platJahreston = strip.Color(204, 0, 102);
uint32_t Tageslicht = strip.Color(127, 127, 127);

void loop() {
  colorWipe(pluto, 50); // Pluto
  colorWipe(neptun, 50); // Neptun
  colorWipe(uranus, 50); // Uranus
  colorWipe (saturn, 50); // Saturn
  colorWipe (jupiter, 50); // Jupiter
  colorWipe (mars, 50); // Mars
  colorWipe (erde, 50); // Erde
  colorWipe (seele, 50); // Seele
  colorWipe (synMond, 50); // synodischer Mond
  colorWipe (sonne, 50); // Sonne
  colorWipe (jahreston, 50); // Jahreston
  colorWipe (merkur, 50); // Merkur
  colorWipe (venus, 50); // Venus
  colorWipe (platJahreston, 50); // platonischer Jahreston
  //colorWipe (Tageslicht, 50); // Tageslicht

// Fill the dots one after the other with a color
void colorWipe(uint32_t c, uint8_t wait) {
  for(uint16_t i=0; i<strip.numPixels(); i++) {
    strip.setPixelColor(i, c);
    strip.show();
    delay(wait);
  }
}

}

Grumpy_Mike

Quote
I also have problems to create the color orange. Someone had the same problem?
Yes everyone has, it is a difficult colour and colour perception depends on a lot of things like background.

To strobe first write a function that turns all the led at once to the colour you pass to it. Then pass black delay, and then pass the colour.Do this for 30 seconds by using a while structure round it. The condition would be while millis() is less that a variable. That variable should be set up to be the current value of millis plus 30 seconds. You put the call to this function as the last thing in your colour wipe function.

Ultimately this technique is useless while it will do what you want, the use of delays of any type in anamation code is bad.

Also when you find yourself writing the same thing over, it is time to learn how to use arrays.

Go Up