Programming or editing ws2812 led strip sketch

I have some ws2812 led strips and I’m new to programming but I know how to change brightness, led count, pin number, speed etc…. as that’s easy.
I have downloaded a template from the library WS2812FX if you call it a library but anyway it’s called “auto_mode_cycle” which has some cool effects but I was wondering if I can edit some of the effects? It scrolls through about 30 effects but some don’t suite my project.

There must be some behind the scenes code imbedded somewhere that I haven’t seen yet??? I’m still learning :open_mouth:
Any suggestions would be greatly appreciated, Cheers :slight_smile:

Where did you get WS2812FX ?

Please post the code that you are using and remember to use code tags when you do

Maybe have a look at the documentary, then pick an example that comes close to what you want, and try to change that.

Or start from scratch without a full effects library (maybe just the basics of the Adafruit or FastLED Library), then you can learn and gradually move towards what you want.

Thanks guys :slight_smile:
Oh WOW thankyou Gerdski I’ll check that document out!!
I installed the WS2812FX from the libray manager.
Here’s the code, I hope I’ve copied it correctly haha I’m still new at this.

#include <Adafruit_NeoPixel.h>

#include <WS2812FX.h>

#define LED_COUNT 595
#define LED_PIN 10

#define TIMER_MS 3000

// Parameter 1 = number of pixels in strip
// Parameter 2 = Arduino pin number (most are valid)
// Parameter 3 = pixel type flags, add together as needed:
//   NEO_KHZ800  800 KHz bitstream (most NeoPixel products w/WS2812 LEDs)
//   NEO_KHZ400  400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers)
//   NEO_GRB     Pixels are wired for GRB bitstream (most NeoPixel products)
//   NEO_RGB     Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2)
//   NEO_RGBW    Pixels are wired for RGBW bitstream (NeoPixel RGBW products)
WS2812FX ws2812fx = WS2812FX(LED_COUNT, LED_PIN, NEO_RGB + NEO_KHZ800);

unsigned long last_change = 0;
unsigned long now = 0;

void setup() {

void loop() {
  now = millis();


  if(now - last_change > TIMER_MS) {
    ws2812fx.setMode((ws2812fx.getMode() + 1) % ws2812fx.getModeCount());
    last_change = now;


i am also new to this.

You send me that code…but why?
What should I do with it?
Does it work when you upload it?
Is there an error?

Gerdski Because UKHeliBob asked me to post the code :slight_smile:
Yes, the code works great!!! Some really good patterns. But there’s about 2 or 3 patterns that do not suite my project that I want to edit or delete somehow.
Also, I would love to create a night rider type pattern too.

So the code obviously does some demo stuff, one after the other, right?
I cannot help you with the code, sorry. All it seems to do is start something with the parameter "FX_MODE_STATIC". which seems to cycle through all the options that you can see in the documentary.

Maybe this library is too much for you as a beginner.

So now that I know your project (Night Rider), I can imagine what you need to do.

You would need a few LEDs in a row, either one of these 1x8 LED sticks or a 1m/2m/5m LED strip or whatever. I'll refer to the 1x8 now for simplicity.

Then you need to write an Arduino Sketch which does the following:

-Start with Pixel 1.
-Wait for a few millliseconds, maybe 50.
-Switch off Pixel 1, switch on Pixel 2, wait again 50 ms.
-carry on until the end of the stick, find out if you are at Pixel 8. If you are, move backwards now.
-If you arrive at Pixel 1 you have completet a cycle, this is called "the loop".

The loop is repeated all the time until you switch the power off.

Is that what you want? (This is a basic nightrider thing, but good for a beginner)

What is your LED hardware?

Since almost everything in Arduino-land is Open Source, you can view the code yourself. It’s in the files WS2812FX.h and WS2812FX.cpp. It looks like the setMode() function selects the pattern to be displayed. The example code you posted simply cycles through them all. If you open up WS2812FX.h, you’ll them them all defined. Look for all the lines that start with “#define FX_MODE_”. You can simple choose the ones you want to use with your project.

Thankyou so much for your replies :slight_smile:
@Gerdski yes it does some demo stuff, one after the other as you can see in the video. My home made star ws2812b - YouTube It’s not all the patterns but a short video of what I’ve done so far. I would like to edit the patterns like shorten some patterns and the speed of others too. As for the night rider that’s my next project I have just started. There’s a night rider pattern that is in the star I would like to extract and put into my new project.

My led hardware is the ws2812b led strips (about 800 LEDs) connected to an Arduino mega 2560, power supply is a 5v about 40amp, I have a larger supply for bigger projects if need be but 40amp is plenty!!

@gfvalvo thankyou I’ll play around with some code :slight_smile: