Hi all, I'm getting into the home stretch on my dog collar project,

Hi all, I’m getting into the home stretch on my dog collar project, and I’m at one final wish-list item, and was wondering if you had any ideas.

As you know, I’m setting up a show collar where the unit will step through several patterns, I’ve got that working well now. The speed of the scrolling for all the patterns that do scroll is defined initially as


What I would like to do is for one of the patterns (the black and white scrolling pattern) to have that be much faster, say 225.

I know I can’t stick another " #define updates per second xxx" statement just above the code because that is the whole purpose of the define-type statements.

Any ideas on how to set a different scroll speed to any particular stepped pattern, and then have it go back to the defalt when moving on to a different pattern?

Make it a variable - outside of any of your functions do:

int updatesPerSecond = 125;

Then when you change to a pattern you want to be faster you can change that value to whatever rate you want for that pattern.

So I added this statement near the top by the counters: (but still keeping the “#define UPDATES_PER_SECOND 125” statement

and in the group by the counters the third line
// some counters to keep state
int paletteCounter = 1;
int brightnessCounter = 99;
int updatesPerSecond = 125;

Then I added one line above the function that I want to be different:

updatesPerSecond = 200;
void SetupBlackAndWhiteStripedPalette()
// ‘black out’ all 16 palette entries…
fill_solid( currentPalette, 16, CRGB::Black);
// and set every fourth one to white.
currentPalette[0] = CRGB::White;
currentPalette[4] = CRGB::White;
currentPalette[8] = CRGB::White;
currentPalette[12] = CRGB::White;


It won’t compile now…

I must have misunderstood you, Daniel.

One thing I tend to do a lot if set a default ‘ticker’ that I then divide for whatever loop I need it, so:

#define INTERVAL 1000

void routine_one() {
update = INTERVAL/100; // 10ms


void routine_two() {
update = INTERVAL/50; // 20ms


void routine_three() {
update = INTERVAL/4; // 250ms


etc., etc.

@Roger_Kolasinski ​ your updatesPerSecond = 200 line needs to go inside your function or somewhere in your main loop. Where ever you’re choosing what function to run in the main loop, try putting something there that specifies your slower or faster updates per second.

Is this another way to look at it using millis() ?

@Giligain_I ​ In this case UPDATES_PER_SECOND is just an alternate way to specify how much delay you want. It’s being used like so:

FastLED.delay(1000 / UPDATES_PER_SECOND);

So thanks all, below is a post of the code I cobbled up from others examples. I’m now constructing the physical prototype and all should fit into a nice enclosure. I’ll post the final product.

One thing though, I never could get the black-and-white stripe function to run at a faster scroll speed than what was originally #defined at the top of the code. If someone could show me by example how to change it so that function would scroll maybe twice as fast, I would really appreciate it.

Thanks again.


As Daniel mentioned, you’ll need to change that define line to a variable. So this line:
becomes this:
int updatesPerSecond = 125;

And then where you have:
FastLED.delay(1000 / UPDATES_PER_SECOND);

Update that to:
if( paletteCounter == 4) { updatesPerSecond = 242; } // custom speed for this one palette
else { updatesPerSecond = 125; }
FastLED.delay(1000 / updatesPerSecond );

This would be a quick way to check which palette is being used and change it for just that one palette choice. To make it more adjustable and be able to tweak each palette I’d probably try setting each one individually down in the ChangePalettePeriodically function like this:
if( paletteCounter == 0) {
fill_solid( currentPalette, 16, CRGB::Black);
currentBlending = NOBLEND;
updatesPerSecond = 142; // tweak this palette’s time here

I’m looking forward to a future dog video. :slight_smile:

Thanks. Our teams next performance is memorial day weekend in the USA, in a couple of weeks. I probably won’t have all of them done for the show but i will have at least one done for one of my dogs and will post that video

By the way, just got home and plugged in the code. Perfect! Thanks all!