Page 1 of 1

Welcome to the Tweaking4All community forums!
When participating, please keep the Forum Rules in mind!

Topics for particular software or systems: Start your topic link with the name of the application or system.
For example “MacOS X – Your question“, or “MS Word – Your Tip or Trick“.

Please note that switching to another language when reading a post will not bring you to the same post, in Dutch, as there is most likely no translated for the post!

LED Effects: Runnin...
Clear all

LED Effects: Running lights with 3 colors (Red, White and Blue!)  


Prominent Member Admin
Joined: 7 years ago
Posts: 870
June 4, 2020 9:55 AM  

While tinkering on something similar, I was able to change my code easily to support 3 colors, showing red, white and blue.
You can select you own colors of course and the speed.

This sketch relies on FastLed.
Set the proper NUM_LEDS and the proper PIN used on your Arduino.

#include "FastLED.h"
#define NUM_LEDS 60
#define PIN 6

void setup()
FastLED.addLeds<WS2811, PIN, GRB>(leds, NUM_LEDS).setCorrection( TypicalLEDStrip );

void loop() {
RunningLights(0x00, 0x00, 0xff, // blue
0xff, 0xff, 0xff, // white
0xff, 0x00, 0x00, // red

void RunningLights(byte red1, byte green1, byte blue1,
byte red2, byte green2, byte blue2,
byte red3, byte green3, byte blue3, int WaveDelay) {

float b1 = 0.05; // brightness LEDs 1 and 5
float b2 = 0.2; // brightness LEDs 2 and 4

int Col1Pos = 0;

for(int start=0; start<15; start++) /// "strip" is 10 leds: 2x5 leds
for (int i=-15; i < NUM_LEDS+15; i=i+15) {
Col1Pos = i+start;

setMyPixel(Col1Pos, b1*red1, b1*green1, b1*blue1); //turn every third pixel on
setMyPixel(Col1Pos+1, b2*red1, b2*green1, b2*blue1);
setMyPixel(Col1Pos+2, red1, green1, blue1);
setMyPixel(Col1Pos+3, b2*red1, b2*green1, b2*blue1);
setMyPixel(Col1Pos+4, b1*red1, b1*green1, b1*blue1);

setMyPixel(Col1Pos+5, b1*red2, b1*green2, b1*blue2); //turn every third pixel on
setMyPixel(Col1Pos+6, b2*red2, b2*green2, b2*blue2);
setMyPixel(Col1Pos+7, red2, green2, blue2);
setMyPixel(Col1Pos+8, b2*red2, b2*green2, b2*blue2);
setMyPixel(Col1Pos+9, b1*red2, b1*green2, b1*blue2);

setMyPixel(Col1Pos+10, b1*red3, b1*green3, b1*blue3); //turn every third pixel on
setMyPixel(Col1Pos+11, b2*red3, b2*green3, b2*blue3);
setMyPixel(Col1Pos+12, red3, green3, blue3);
setMyPixel(Col1Pos+13, b2*red3, b2*green3, b2*blue3);
setMyPixel(Col1Pos+14, b1*red3, b1*green3, b1*blue3);


void setMyPixel(int Pixel, byte red, byte green, byte blue) {
if( (Pixel>=0) && (Pixel<=NUM_LEDS) )
leds[Pixel] = CRGB( red, green, blue);