# Hello All, I'm trying to show blood flow in a model I'm making.

Hello All,

I’m trying to show blood flow in a model I’m making.

The below code works well (cobbled together from some example code), but… I would like to have another “pulse” start at a determined distance from pulse one.
For arguments sake lets say 8 LED’s behind the first.

Arduino Uno
WS2812B
Arduino IDE

Sorry if this is dead simple, but I couldn’t find any examples.

## BTW, cross-posted from Arduino Forum.

#include “FastLED.h”

#define NUM_LEDS 144
#define DATA_PIN 3

CRGB leds[NUM_LEDS];
//FastLED.addLeds<WS2812B, DATA_PIN, GRB>(leds, NUM_LEDS);

void setup() {
// put your setup code here, to run once:

}

void fadeall() { for(int i = 0; i < NUM_LEDS; i++) { leds[i].nscale8_video(220); } }

void loop() {
// put your main code here, to run repeatedly:

for(int i = 50; i <= 100; i++) {
leds[i] = CHSV(0, 255, 100);
FastLED.show();
delay (10);
}
}

Conceptually you want to add something like this:

leds[i+8]= CHSV(0, 255, 100);

Just below the other leds[i] line.
If you try this you’ll find that it doesn’t quite work - it will never light up the first few LEDs and will run past your range.

This is because you’re looping from 50 to 100, and if you do what I did you’ll try and loop from 58-108 which isn’t correct.

Assuming you have good reasons for wanting to illuminate only the 50th - 100th LEDs you’re probably better doing the following:

for(int i = 0; i <= 50; i++) {
leds[i+50] = CHSV(0, 255, 100);
leds[(i+8)%50 + 50] = CHSV(0, 255, 100);
//etc as before
}

The trick here is that I loop from 0…50 but I also add 50. And the “(i+8)%50” bit says “whenever i+8 is greater than 50, just start from 0 again” [kinda, lookup “modulo operator” for the maths].

Hope this helps!

Matt,
Great, I’ll try those tomorrow.
I have NO reason for looping from 50-100. just easier to see in the middle of the strip. The actual strip will be some unknown number at this point. Eventually I’ll have two or three separate strips (like Strip1_0-35, Strip2_0-35) or some such configuration of strips, but I’m just getting to “know” the WS2812B and the FastLED lib right now.
Thanks for your help; I really appreciate it. I’m sure I’ll be back with new and different questions!

I dug up a “heart beat” sort of effect from my files and just updated it. Added lots of variables to play with.

@marmil

Marc, this is great! Thank you.
Not exactly what I need, but all the tools to do the job. I’ll pore through the code and try to make sense of it all.
Thanks again, this is terrific!