Need help with segmental color coding on a 144led strip

Hi, I am very new to all of these and wanted to start off with something relatively simple and toward my final project.

I would like to start with the strip on off mode, then first 40leds turn on one by one in yellow color and then the next 40leds turn on one by one in red color, then the last 64leds turn one by one in Green color. Then after 5 seconds, the Yellow leds turn off one by one, then red leds turn off one by one, and finally the green leds turn off one by one, until all of the leds on the strip are off.

I would very much appreciate if you could start me in the right direction. Thank you

Equipment:
1 Meter WS2812B 144 LED strip
Arduino Uno
5v 10A 50W power supply
1000 uf Capacitor on the - and + power leads
147 Ohm on the data input to pin 6 of Arduino Uno

I would very much appreciate if you could start me in the right direction.

No problem. Just fill in the blanks

// Blank section where global variables go

void setup()
{
   // Blank where one-time-only code goes
}

void loop()
{
   // Blank where do-it-more-than-once code goes
}

Adafruit has lots of examples on their site for playing with LED strips.

Welcome to the form.
take a look at this:

.

Thank you Paul for the template program. Also, thank you Larry for the site. My biggest question is that, can you program the arduino to turn on specific leds on a strip(say 40-80) to be certain color and then led 80-144 another color. The coloring have to be exactly at those leds and not any other. Not at random, nor in sequence, but in a specific target leds(for example led 40-80)? Thank you

Note: arrays start at location zero.
For each pixel you need 3 bytes in your array.
144 pixels means you will have 432 (0-431) bytes.
A pixel can be 0,0,0 all the way to 255,255,255 i.e. R,G,B

Pixel 1 is elements 0,1,2 pixel 2 is 3,4,5 . . . pixel 144 is 429,430,431

Example:
If you want to turn on the 80th Pixel to 'bright red' this would be elements 237, 238 and 239
For pixel 80 to be bright red, make 237 (803-3) = 255, 238 (803-2) = 0, 239 (80*3-1) = 0
Therefore location 237 will be 255 and 238 will be 0 and 239 will be 0.

If you wanted bright white on the 80th pixel you need 237=255, 238=255 and 239=255.

.

My biggest question is that, can you program the arduino to turn on specific leds on a strip(say 40-80) to be certain color and then led 80-144 another color. The coloring have to be exactly at those leds and not any other. Not at random, nor in sequence, but in a specific target leds(for example led 40-80)

The answer is simply yes of course you can.

All you need to do is to write the code. Write the code to fill a section of LEDs with a fixed colour, I posted such a function just two weeks ago in the LED section. It is just a for loop and a colour set call.

On the Adafruit site I linked, find this text:

There are two ways to set the color of a pixel. The first is:
Copy Code
strip.setPixelColor(n, red, green, blue);
or, if you're using RGBW strips:
Copy Code
strip.setPixelColor(n, red, green, blue, white);
The first argument — n in this example — is the pixel number along the strip, starting from 0 closest to the Arduino. If you have a strip of 30 pixels, they’re numbered 0 through 29. It’s a computer thing. You’ll see various places in the code using a for loop, passing the loop counter variable as the pixel number to this function, to set the values of multiple pixels.

The next three arguments are the pixel color, expressed as red, green and blue brightness levels, where 0 is dimmest (off) and 255 is maximum brightness. The last optional argument is for white, which will only be used if the strip was defined during creation as an RGBW type and the strip actually is RGBW type.

Look at the function I wrote here in reply #8
http://forum.arduino.cc/index.php?topic=430703.0;nowap

Note you could change it so you also passed a colour to use to set the LEDs.

Thank you, Grumpy & Larry. I came up with this little piece so far:

#define DATA_PIN 6

#define LED_TYPE WS2812
#define COLOR_ORDER GRB
#define NUM_LEDS 144
CRGBArray<NUM_LEDS> leds;

#define BRIGHTNESS 50

void setup() {

// the LED strip configuration
FastLED.addLeds<LED_TYPE,DATA_PIN,COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);

// set master brightness control
FastLED.setBrightness(BRIGHTNESS);
}
void loop() {
// put your main code here, to run repeatedly:
leds(0,143) = CRGB::Black;
FastLED.show();
delay(30);
//leds(0,39) = CRGB::Pink;
leds(40,79) = CRGB::Yellow;
FastLED.show();
delay(3000);
}

The problem is that all 40leds turn on at one time. I want them to turn on one at a time, until all 40leds are on. Any suggestions? Thank you

I forgot to include the first line of the code:

#include <FastLED.h>

You are telling them to turn on all at the same time.

Create a loop where a variable starts at 40 and ends at 79.
The first time through the loop you turn on one pixel, then wait some time.
The second time through the loop turn on two pixels . . . etc.
So what you are doing is adding one to the pixel maximum.

https://www.arduino.cc/en/Reference/For

.

Thank you Larry. I modified the void loop to:

void loop() {
// put your main code here, to run repeatedly:
leds(0,143) = CRGB::Black;
FastLED.show();
delay(30);
for (int i=0; i <= 39; i++){
leds(i) = CRGB::Red;
FastLED.show();

}

But, I am getting error message: no match for call to '(CRGBArray<144>)(int&)'

I appreciate any suggestion for this problem.

Give us a link to where you downloaded the library from.

.

Here is the link:

Not tested

#include <FastLED.h>

#define DATA_PIN    6

#define LED_TYPE    WS2812
#define COLOR_ORDER GRB
#define NUM_LEDS    144
CRGBArray<NUM_LEDS> leds;


#define BRIGHTNESS          50



void setup()
{

  // the LED strip configuration
  FastLED.addLeds<LED_TYPE, DATA_PIN, COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);


  // set master brightness control
  FastLED.setBrightness(BRIGHTNESS);
}
void loop()
{
  // put your main code here, to run repeatedly:
  //  leds(0,143) = CRGB::Black;
  leds(0, 143) = CRGB::Black;

  FastLED.show();
  delay(30);
  //leds(0,39) = CRGB::Pink;
  //leds(40,79) = CRGB::Yellow;
  for (int i = 40; i <= 79; i++)
  {
    leds(40, i) = CRGB::Yellow;
    //leds(i) = CRGB::Red;
    delay(100);
    FastLED.show();

  }
  delay(3000);
}

Thank you Larry, it worked like a charm. Now, after the 40th led turns on, I want the next set of 40 leds to turn on one at a time in violet. I am going to give it a try at coding and post the results. Again, thank you for all your help.

Well it worked. I have this code:

#include <FastLED.h>

#define DATA_PIN 6

#define LED_TYPE WS2812
#define COLOR_ORDER GRB
#define NUM_LEDS 144
CRGBArray<NUM_LEDS> leds;

#define BRIGHTNESS 50

void setup() {

// the LED strip configuration
FastLED.addLeds<LED_TYPE,DATA_PIN,COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);

// set master brightness control
FastLED.setBrightness(BRIGHTNESS);
leds(0,143) = CRGB::Black;
FastLED.show();
delay(30);
}
void loop() {
// put your main code here, to run repeatedly:

for (int i=0; i <= 39; i++){
leds(0,i) = CRGB::Red;
delay(100);
FastLED.show();
}

for (int i=40; i <= 79; i++){
leds(40,i) = CRGB::Violet;
delay(100);
FastLED.show();
}

for (int i=80; i <= 119; i++){
leds(80,i) = CRGB::Red;
delay(100);
FastLED.show();
}
for (int i=120; i <= 144; i++){
leds(120,i) = CRGB::Violet;
delay(100);
FastLED.show();
}
delay(3000);
leds(0,143) = CRGB::Black;
FastLED.show();
delay(30);

}

Now, I want to randomize the timing of the lighting. Is it possible to get the light to come on at a random intervals(the entire set of 144led segment of the two colors). To set the timing to be a minimum of 20 minutes and up to 40 minutes apart. Thank you

Look at the random function.
https://www.arduino.cc/en/Reference/Random
https://www.arduino.cc/en/Reference/RandomSeed

However it is my guess you need to stop and learn some basic programming skills.
These should all be mastered:

Study how to use BWD BlinkWithoutDelay, there is an example in the IDE.
http://playground.arduino.cc/Code/AvoidDelay

Study State Machine programming:
http://www.thebox.myzen.co.uk/Tutorial/State_Machine.html

Also forgot to ask: Is it possible for the light show to go only once and then repeat itself at randomness of minimum of 25min up to 45min max?

Nothing is impossible. :wink:

If you want different light shows you can create each in a separate function.
Then you 'call' these functions when you need them.

.