I am new to this and I am wanting to move three sets of

I am new to this and I am wanting to move three sets of leds down the strip and I can not for the life of me figure it out. here is the code I am playing with but it wants to run these in a sequence instead of all three colors moving at the same time and speed any help would be greatly appreciated
I am using an arduino uno
here is the code
#include “FastLED.h”
#define NUM_LEDS 60

#define DATA_PIN 3
#define CLOCK_PIN 13

CRGB leds[NUM_LEDS];
void setup() {
FastLED.addLeds<APA102, DATA_PIN, CLOCK_PIN, GBR>(leds, NUM_LEDS);
FastLED.setBrightness(255);
FastLED.delay (50);
}
void loop() {
// Move a single white led
for(int whiteLed = 5; whiteLed< 10; whiteLed = whiteLed + 1)
for(int RedLed = 0; RedLed < 4; RedLed = RedLed + 1)
for(int BlueLed = 20; BlueLed < 30; BlueLed = BlueLed + 1)
{
// Turn our current led on to white, then show the leds
leds[whiteLed] = CRGB::White;
leds[RedLed] = CRGB::Red;
leds[BlueLed] = CRGB::Blue;
// Show the leds (only one of which is set to white, from above)
FastLED.show();
// Wait a little bit
FastLED.delay (50);

  // Turn our current led back to black for the next loop around
  leds[whiteLed] = CRGB::Black; 
  leds[RedLed] = CRGB::Black;
  leds[BlueLed] = CRGB::Black;

}
}

Not sure what you mean by ‘move 3 sets of LED’s down the strip’, however you might want to look into the ColorPalette demo that comes with FastLED. It allows you to set a Palette of colours and then cycle them down the strip. It’s certainly a lot cleaner than nested for loops.

Ok. . . here’s one:

http://pastebin.com/UzXYpfe6

Just change the pins and colour order to match your hardware.

The cool thing is that it’s easy to change colours, speed, distance between LED colours just by changing one or two variables.

Hey, Donnie Beede

This is very crude but just try this…

void loop() {
// Move a single white led
for(int whiteLed = 0; whiteLed< 5; whiteLed = whiteLed + 1)
{
int RedLed = whiteLed+5;
int BlueLed = whiteLed+10;

// Turn our current led on to white, then show the leds
  leds[whiteLed] = CRGB::White;
  leds[RedLed] = CRGB::Red;
  leds[BlueLed] = CRGB::Blue;
  // Show the leds (only one of which is set to white, from above)
  FastLED.show();
  // Wait a little bit

FastLED.delay (500);

  // Turn our current led back to black for the next loop around
  leds[whiteLed] = CRGB::Black;
  leds[RedLed] = CRGB::Black;
  leds[BlueLed] = CRGB::Black;

}
}

JP

That is really close but I need to control the # of spaces each groups moves it would be great if it were possible to repeat this code
(int whiteLed = 10; whiteLed< 19; whiteLed = whiteLed + 1)
with each one having the start and stop led so it would be easy to control how far each group moves. If that makes since.
I am going to have three rows of leds (two made up of 7 leds and one made up of 9 leds they will be part of the same aray . So the first light in the nine string will blink and as the second led in that row blinks the first light in the other two (7 strand leds ) will start and all three will move together from there

@Donnie_Beede

I knew that this would not be what you wanted ultimately but I hoped it would give you some hints on how to proceed by yourself.

If the apparent LED movement has the same speed on all 3 strips then the instructions in the main loop should be very easy and it is mainly a question of simple arithmetic (+ and -) on the variables that you use.

It is not totally clear to me what you are trying to do and specially for what purpose !

Keep hacking away at that sketch until you get it to do exactly what you want.

If you do get stuck, come back here with details and I will help you more !

Good luck !

If you have three horizontal rows of 7, 9, and 7 pixels, the pixel numbers would be:
00 01 02 03 04 05 06
07 08 09 10 11 12 13 14 15
16 17 18 19 20 21 22

I think I would try something like this (assuming pixel 06 Data/Clock Out wires back into pixel 07 Data/Clock In on left, and 15 wires back to 16):

for (i=7; i<16; i++){ //range of pixel numbers of middle row
leds[i] = CRGB::Red; //middle row
if (i>7 && i<15) {
leds[i-8] = CRGB::White; //starts at leds[0], top row
leds[i+8] = CRGB::Blue; //starts at leds[16], bottom row
}
FastLED.delay (50);
leds[i] = CRGB::Black;
leds[i-8] = CRGB::Black;
leds[i+8] = CRGB::Black;
}

I didn’t actually try running this, but hopefully it will give you an idea of something to try.
Btw, seems like NUM_LEDS should only be 23, not 60, if your rows are 7,9, and 7.

Marc Miller
You nailed exactly how it will be wired the numbers will be a little different but you got the idea perfect.
The reason there are 60 leds is because the strip is going to be a set of trailer lights. On both sides there will be two short runs of 7 with a run of 9 in the middle and the remaining leds are going to be a center or third break light.
When you turn on the clearance light all leds will light up at 50% brightness. When you apply the breaks all will light at 90%. When you turn on either turn signal all three rows on that side will flash sequential from the inside to the outside and the third break light will move from the middle to the side you are turning. And lastly when you back up they will all be white. Hope this makes more since now.
The biggest problem is I have never written a single line of code before in my life.
I have figured out how to do most of what I need to do but as for getting all three strips to move together was frustrating me. I had the code written to move the lights one at a time but it sure made for a very long string lol.
once I get the lights to do the patterns I need I get to start using triggers to activate them and start playing with if else statements. So I have quite a challenge ahead. I will try running the code you suggested tomorrow. And thanks for your help.
One last question where is the best place to look for understanding the code for fastled. I mean the very basics I can look at some of it and figure it out but I am one of those people that wants to know why it works.

Donnie, I have been following this with interest as i only started looking at code since last September. I am using FastLED to improve my understanding of C programming for a college course i am doing (even though i am in my 50’s). Try getting the ‘Sams’ Teach yourself C++ in 24hrs.
All the best.

I was wondering if it was for a turn signal setup. Excellent. Sounds like a great project! You will learn lots. Just break it down in to many smaller parts and get each of those working, and then slowly combine things together.

If you haven’t already, browse through the FastLED pages here:

Check out the FastLED example files to see how a variety of things can be put together:

(After installing the FastLED library in Arduino, these examples can also be found through the File menu > Examples > FastLED)
Then feel free to come ask those “but why does this work” questions.

As for learning C code, it will take a bit of time. http://arduino.cc/en/Reference is always good for basics and helping remember things, and Google will for sure be your friend.
I’ll give a recommendation to check out @Andrew_Tuline 's FastLED examples also as he has good organization and comments in his files. GitHub - atuline/FastLED-Demos: Here's my updated FastLED demos from January, 2017.

Marc I tried to run the code but I can not get it to work I know it has to be something simple but I have been beating my head against the wall for two hours now reading every thing I can find and comparing to cod I have working but just can not see it. here is the code as I have it written now
#include “FastLED.h”
#define NUM_LEDS 60

#define DATA_PIN 3
#define CLOCK_PIN 13

CRGB leds[NUM_LEDS];
void setup() {
FastLED.addLeds<APA102, DATA_PIN, CLOCK_PIN, GBR>(leds, NUM_LEDS);
FastLED.setBrightness(255);
}
for (i=7; i<16; i++){ //range of pixel numbers of middle row
leds[i] = CRGB::Red; //middle row
if (i>7 && i<15) {
leds[i-8] = CRGB::White; //starts at leds[0], top row
leds[i+8] = CRGB::Blue; //starts at leds[16], bottom row
}
FastLED.delay (50);
leds[i] = CRGB::Black;
leds[i-8] = CRGB::Black;
leds[i+8] = CRGB::Black;
}

If you see what is throwing it off please try to explain it to me. this is slowly starting to make since but the placement of () and {} are just rattling my brain for some reason. I went to Arduino Reference - Arduino Reference and that is helping a lot. But still a lot to sink in. Some of it makes total sense but the structure is the hard part to grasp.

My code might not be complete as I didn’t actually run it.
First off, can you make a single dot move down the middle strip (from 7 to 15)? Remove/comment out the “if (i>7 && i<15)” section and get the middle strip working first. Small steps. :slight_smile:
Once you have that then add the top row, and then the bottom row one at a time.

Btw, have you actually already cut up your 60 pixel strip into the shorter 7,9,7 strips and wired them back together in that “Z” wiring layout?

no I have not cut them I did not want to trough more variables into the mix yrt just wanted to get it all working first… quest you do not have a Fastled show in the code does it not need that?

FastLED.delay() calls FastLED.show() under the hood so you shouldn’t need both as consecutive lines.

It’s fine if you haven’t cut your strip up yet. Good idea to eliminate a possible problem point for now, and you should still be able to totally test out this part of your system/code.

Did you remove the “if (i>7…” check section for now? Maybe also remove leds[i-8] = CRGB::Black; and leds[i+8] = CRGB::Black; lines for now also. Might need to make it as simple as possible to start out with until you know you can at least move a single dot.

Yes I have tried both and I still can not get the code to compile

Marc I got it to work I have no hair left but it is working lol thank you for the help

How about a pastebin of your working code?

Sure here is the code that works

#include “FastLED.h”
#define NUM_LEDS 60

#define DATA_PIN 3
#define CLOCK_PIN 13

CRGB leds[NUM_LEDS];
void setup() {
FastLED.addLeds<APA102, DATA_PIN, CLOCK_PIN, GBR>(leds, NUM_LEDS);
FastLED.setBrightness(255);
}
void loop() {
for (int i = 7; i < 16; i++){ //range of pixel numbers of middle row
leds[i] = CRGB::Red; //middle row
if (i>7 && i<15) {
leds[i-8] = CRGB::Red; //starts at leds[0], top row
leds[i+8] = CRGB::Red; //starts at leds[16], bottom row
}
FastLED.delay (65);
leds[i] = CRGB::Black;
leds[i-8] = CRGB::Black;
leds[i+8] = CRGB::Black;
}
}