I work on project with NeoPixel strips + Arduino Uno + FastLED librairy.
Code: [Select]
void loop() {
for(int dot = 0; dot < NUM_LEDS; dot++) {
leds[dot] = CRGB::Blue;
FastLED.show();
// clear this led for the next time around the loop
leds[dot] = CRGB::Black;
delay(30);
}
}
In this part of code, a led/pixel move around and light on/off for entire number of led in strips.
delay(30); make looping every 30 millisecond.
My goal is to find a way to set different millisecond for each led/pixel movement
different speed in millisecond for each pixel move on each stripe.
Example :
pixel0 to pixel1 =40.4567ms; pixel1 to pixel2=2000ms; pixel2 to pixel2 = 600ms; etc…etc
Thanks if you could help me
Make a separate array with the values you want for the individual delay.
dot_delay[ ] = { 100,200,300,600,1000 };
void loop() {
for(int dot = 0; dot < NUM_LEDS; dot++) {
leds[dot] = CRGB::Blue;
FastLED.show();
leds[dot] = CRGB::Black;
delay( dot_delay[ dot ] );
}
}
The dot_delay array needs to be as long as your NUM_LEDS array FYI.
Thnaks Thanks Thanks
i try my best…i feel like iam close to finaly control times between each pixel/led
here my code :
#include “FastLED.h”
#define NUM_LEDS1 10
#define DATA_PIN1 5
CRGB leds1[NUM_LEDS1];
int dot_delay0[] = { 10 };
int dot_delay1[] = { 20 };
int dot_delay2[] = { 30 };
int dot_delay3[] = { 40 };
int dot_delay4[] = { 50 };
int dot_delay5[] = { 60 };
int dot_delay6[] = { 70 };
int dot_delay7[] = { 80 };
int dot_delay8[] = { 90 };
int dot_delay9[] = { 100 };
void setup() {
FastLED.addLeds<NEOPIXEL, DATA_PIN1>(leds1, NUM_LEDS1);
}
void loop() {
for(int dot = 0; dot < NUM_LEDS1; dot++)
{
leds1[dot] = CRGB::Blue;
leds1[dot] = CRGB::Red;
FastLED.show();
leds1[dot] = CRGB::Black;
leds1[dot] = CRGB::Black;
delay( dot_delay0[ dot ] );
delay( dot_delay1[ dot ] );
delay( dot_delay2[ dot ] );
delay( dot_delay3[ dot ] );
delay( dot_delay4[ dot ] );
delay( dot_delay5[ dot ] );
delay( dot_delay6[ dot ] );
delay( dot_delay7[ dot ] );
delay( dot_delay8[ dot ] );
delay( dot_delay9[ dot ] );
}
}
It looks like you need to do some reading on how arrays work. In your new code, you are creating a separate array for each led, which is not the same as my example.
here is my new code iam french sorry :
#include <FastLED.h>
#define NUM_LEDS 10
#define DATA_PIN 6
CRGB leds[NUM_LEDS];
void setup() {
FastLED.addLeds<NEOPIXEL, DATA_PIN>(leds, NUM_LEDS);
}
int dot_delay[ ] = { 1 };
void loop() {
for(int dot = 0; dot < NUM_LEDS; dot++) {
leds[dot] = CRGB::Blue;
FastLED.show();
leds[dot] = CRGB::Black;
delay( dot_delay[ dot ] );
}
}
You are still going to get an error. The size of your dot_delay array is only 1, and in that single space you have stored the number 1.
Now, your for loop goes thru the total size of the NUM_LEDS array. So if you have 30 leds, then you are going to need 30 separate numbers in the dot_delay[ ].
The code, as you have it now, will only give the first LED a delay of 1, everything else will get a 0 or error out because the difference in array size.
Ha thanks Jon all work perfectly now for 1 strip…
i try with 2 strip here my code and just need to figure out how i put multi delay dot but on each 2 stripe :
#include <FastLED.h>
#define NUM_LEDS1 10
#define NUM_LEDS2 6
#define DATA_PIN1 6
#define DATA_PIN2 7
CRGB leds1[NUM_LEDS1];
CRGB leds2[NUM_LEDS2];
void setup() {
FastLED.addLeds<NEOPIXEL, DATA_PIN1>(leds1, NUM_LEDS1);
FastLED.addLeds<NEOPIXEL, DATA_PIN2>(leds2, NUM_LEDS2);
}
int dot_delay1[ ] = { 100,200,300,400,500,600,700,800,900,1000 };
int dot_delay2[ ] = { 100,200,300,400,500,600 };
void loop() {
for(int dot = 0; dot < NUM_LEDS1; dot++)
for(int dot = 0; dot < NUM_LEDS2; dot++)
{
leds1[dot] = CRGB::Blue;
leds2[dot] = CRGB::Blue;
FastLED.show();
leds1[dot] = CRGB::Black;
leds2[dot] = CRGB::Black;
delay( dot_delay1[ dot ] );
}
}
For two strips, you are going to need to use a different tactic, you need to NOT use the delay() function. There is a great example in the Arudino Examples called Debounce without Delay. Look into how that works, because the delay() function stops everything while it is waiting. Therefore, you can’t run two different delay() at a time.
here is my new code :
#include "FastLED.h"
#define NUM_LEDS1 10
#define NUM_LEDS2 10
#define NUM_LEDS3 10
CRGB strip1[NUM_LEDS1];
CRGB strip2[NUM_LEDS2];
CRGB strip3[NUM_LEDS3];
// 1 sec. frequency
unsigned long interval=1000; // the time we need to wait
unsigned long previousMillis=0; // millis() returns an unsigned long.
// 5 sec. frequency
unsigned long interval1=5000; // the time we need to wait
unsigned long previousMillis1=0; // millis() returns an unsigned long.
void setup() {
FastLED.addLeds<NEOPIXEL, 5>(strip1, NUM_LEDS1);
FastLED.addLeds<NEOPIXEL, 6>(strip2, NUM_LEDS2);
FastLED.addLeds<NEOPIXEL, 7>(strip3, NUM_LEDS3);
}
void loop() {
for(int i = 0; i < NUM_LEDS1; i++)
for(int i = 0; i < NUM_LEDS2; i++)
for(int i = 0; i < NUM_LEDS3; i++)
// other CMD's...
strip1[0] = CRGB::Red;
strip2[0] = CRGB::Green;
strip3[0] = CRGB::Blue;
FastLED.show();
strip1[0].fadeToBlackBy(255);
strip2[0].fadeToBlackBy(255);
strip3[0].fadeToBlackBy(255);
FastLED.show();
// replace delay(1000)
if ((unsigned long)(millis() - previousMillis) >= interval) {
previousMillis = millis();
// every first second
}
// other CMD's...
strip1[1] = CRGB::Red;
strip2[1] = CRGB::Green;
strip3[1] = CRGB::Blue;
FastLED.show();
strip1[1].fadeToBlackBy(255);
strip2[1].fadeToBlackBy(255);
strip3[1].fadeToBlackBy(255);
FastLED.show();
// replace delay(5000)
if ((unsigned long)(millis() - previousMillis1) >= interval1) {
previousMillis1 = millis();
// every fifth second
// ...
}
// other CMD's...
strip1[2] = CRGB::Red;
strip2[2] = CRGB::Green;
strip3[2] = CRGB::Blue;
FastLED.show();
strip1[2].fadeToBlackBy(255);
strip2[2].fadeToBlackBy(255);
strip3[2].fadeToBlackBy(255);
FastLED.show();
}
but something still wrong 
Go to http://pastebin.com and do this. We can edit and share more easily there than here.
@Jon_Burroughs here is a better pastebin where i commented with my best english i can to tell exactly what is purpose of the sketch http://pastebin.com/d9SW62du and with a try on millis integration
It looks like you are getting closer. However, there are still some issues with the new code.
I don’t have time today to help out much, so @Andrew_Tuline or @Ashley_M_Kirchner_No do you have a moment to lend a helping hand?
I’ll have a look. Am thinking of something without delays or ‘for’ loops.
I would be more inclined to do this:
http://pastebin.com/51tZn2rq
Thanks @Andrew_Tuline ! i miss to tell delay is not always greater then the last one in array. I put some increment value for better easy understand of sketch. Here i put you code but with mixing delay value instead cause Each element in the array is not greater than the one previous. i need to run 16 stripes on mega and each stripe have mixing value for delay array. http://pastebin.com/Zf83kKh2 read the comment i add in you comment part and BTW, you rock! But code make fleakering and do not make the result need it allready with greater value)
Not sure if this will work as expected if those array values aren’t increasing. Anyways, it’s a start.
Oh, and I’m not really a programmer. Am more of a hack than anything else.
Yes exactly like me Andrew. iam more hack then coder for shure. when i try your code like you made…is not work and make some fleakering and not every led light up in some looping. i try my best for tweak this from your code and forshure wait for more support cause the reliability of this sketch is exactly what WS28XX and Fastled is ultimately promise will to do…one pixel…few value…all adressable…indepandant then the others 