Barber Pole Style with SK6812 on UNO (only 3 colors continuous)

Hello, I would like to represent a kind of Barbers pole on a strip with 60 SK6812 on UNO, the colors white, red, white, blue should go through continuously. In the examples of the Adafruit Neopixel library I have not seen anything with fixed 3 continuous colors. Can someone help?

If I understand correctly you want to do the following

current = 0

  LED[current] to red
  LED[current + 1] to white
  LED[current + 2] to blue
  wait a bit
  increment current

Is that correct ?
If so can you see a simple pattern ?

Yes, that goes in the right direction. I thought about having 6 adjacent LEDs in one color.
In the library demos and on youtube I did not find examples for simple color samples, just all rainbow colors or monochrome, not simple 2 or 3-color patterns.
Maybe someone can help with a finished code, which also addresses the white LED of the RGBW SK8612 string with the help of the Adafruit NeoPixel-library.

I thought about having 6 adjacent LEDs in one color.

So

current = 0

  LED[current] to LED(current + 6] to red
  LED[current + 6] LED[current + 6 + 6] to white
  LED[current + 12] to LED[current + 12 + 6] to blue
  wait a bit
  increment current

Looks good on the logical side, but how do I translate the text to make it compilable? With the code below the colors can be shown one after the other.

void loop() {
  colorWipe(strip.Color(0, 0, 0, 255), 50); // White
  colorWipe(strip.Color(255, 0, 0), 50); // Red
  colorWipe(strip.Color(0, 0, 0, 255), 50); // White
  colorWipe(strip.Color(0, 0, 255), 50); // Blue
  

// Fill the dots one after the other with a color
void colorWipe(uint32_t c, uint8_t wait) {
  for(uint16_t i=0; i<strip.numPixels(); i++) {
    strip.setPixelColor(i, c);
    strip.show();
    delay(wait);
  }
}

how do I translate the text to make it compilable?

Do you know how to turn on a single LED with a colour of your choice ?
Do you know what a for loop is and how to create one ?
Could you use a for loop to turn 6 consecutive LEDs a colour of your choice ?

strip.setPixelColor(n, red, green, blue, white);

for example 1st led red, 2nd white, 3rd blue

strip.setPixelColor(0, 127, 0, 0, 0);
strip.setPixelColor(1, 0, 0, 0, 127);
strip.setPixelColor(2, 0, 0, 127, 0);

The code in the loop is always repeated.

void loop()
{
   delay(1000);
}

I do not know how to use a for loop to turn 6 consecutive LEDs a colour of my choice, I'm a beginner and I do not know any code example of what I could transfer.

for (int p = 0; p < 6; p++)
{
  //code here to turn led number p the colour of your choice 
}
//strip show code here to display the colours

This works so far with the 3 colors that each 6 adjacent LEDs have the same colors. Now I just need that pattern to go through and all 60 LEDs on.

void loop() {

for (int p = 0; p < 6; p++)
{
  //code here to turn led number p the colour of your choice
strip.setPixelColor(p, 0, 0, 0, 127);
}

for (int p = 6; p < 12; p++)
{
  //code here to turn led number p the colour of your choice
strip.setPixelColor(p, 0, 0, 127, 0);
}

for (int p = 12; p < 18; p++)
{
  //code here to turn led number p the colour of your choice
strip.setPixelColor(p, 127, 0, 0, 0);
}

//strip show code here to display the colours
  strip.show();
 }

One way would be to introduce an offset to the value of p in your for loops when you use it to set the colour of an LED. Imagine what the effect of adding 18 to p in your setPixel() functions, or maybe 32 etc

Of course I could fill the chain up to 59 p according to the pattern described above. For this I would have to call the part modified 9 times:

But how do I make it that goes through the pattern, like a spinning Barbers pole?

how do I make it that goes through the pattern, like a spinning Barbers pole?

Once you have got the array full of the colours you want then what would happen if you copied each value to the next in the array and show them again ?

After all LEDs are on, it should be simplified, as if there were only 18 LEDs, so go on:
RRRRRRWWWWWWBBBBBB
BRRRRRRWWWWWWBBBBB
BBRRRRRRWWWWWWBBBB
BBBRRRRRRWWWWWWBBB
BBBBRRRRRRWWWWWWBB
BBBBBRRRRRRWWWWWWB
BBBBBBRRRRRRWWWWWW
WBBBBBBRRRRRRWWWWW
WWBBBBBBRRRRRRWWWW

I've extended the code so far that the whole strip is filled.
Is that correct and can not be presented more easily?

for (int p = 0; p < 6; p++)
{
strip.setPixelColor(p, 0, 0, 0, 255);
}

for (int p = 6; p < 12; p++)
{
strip.setPixelColor(p, 255, 0, 0, 0);
}

for (int p = 12; p < 18; p++)
{
strip.setPixelColor(p, 0, 0, 0, 255);
}

for (int p = 18; p < 24; p++)
{
strip.setPixelColor(p, 0, 0, 255, 0);
}

for (int p = 24; p < 30; p++)
{
strip.setPixelColor(p, 0, 0, 0, 255);
}

for (int p = 30; p < 36; p++)
{
strip.setPixelColor(p, 255, 0, 0, 0);
}

for (int p = 36; p < 42; p++)
{
strip.setPixelColor(p, 0, 0, 0, 255);
}

for (int p = 42; p < 48; p++)
{
strip.setPixelColor(p, 0, 0, 255, 0);
}

for (int p = 48; p < 54; p++)
{
strip.setPixelColor(p, 0, 0, 0, 255);
}

for (int p = 54; p < 60; p++)
{
strip.setPixelColor(p, 255, 0, 0, 0);
}

However, I have no idea how I get the pattern to move, that it goes through, in LED 59 out and LED 0 back in. Alternatively, I would also be interested in not exchanging the single LED color, but the array of 6 neighboring LEDs.

Would be nice if someone can help me, so I get the movement there still.

Try this

#include <Adafruit_NeoPixel.h>
//#include <avr/power.h>
#define PIN            6
#define NUMPIXELS      36

unsigned long currentColours[NUMPIXELS];
Adafruit_NeoPixel strip = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);

unsigned long red = strip.Color(20, 0, 0);
unsigned long white = strip.Color(20, 20, 20);
unsigned long blue = strip.Color(0, 0, 20);

unsigned int startPosition = 0;

void setup()
{
  strip.begin();
  initPole();
}

void loop()
{
  showCurrent();
  delay(500);
  startPosition++;
}

void initPole()
{
  for (int block = 0; block < NUMPIXELS; block += 18)
  {
    for (int led = 0; led < 6; led++)
    {
      currentColours[block + led] = red;
      currentColours[block + led + 6] = white;
      currentColours[block + led + 12] = blue;
    }
  }
}

void showCurrent()
{
  for (int led = 0; led < NUMPIXELS; led++)
  {
    strip.setPixelColor((led + startPosition) % NUMPIXELS, currentColours[led]);
  }
  strip.show();
}

The colours for each pixel are held in an array and sent to the strip by the showCurrent() function.

The position in the strip is offset from the position in the array by the value of the startPosition variable. Once the colours have been shown this variable is incremented to give a new starting position but in order to make the pattern wrap round to the bottom of the pole the modulo operator (%) is used to derive display position for the wrapped pixels.

Thank you very much. After adjusting NUMPIXELS to 60, 12 LEDs turn red every third pass, why and how can this be corrected?

As you can tell from my code I tested it on a string of 36 pixels because that was all I had. Note that 36 is a multiple of 18 so that when the colours wrap round to the beginning they stay in order

If you have 60 LEDS then odd effects will happen as you have seen. Either adjust the number of LEDs to a multiple of 18 or change the number of colours in each band to 5 which should work as 60 is a multiple of 15