Hi all, Completely new user to Arduino and fastled.I have a strip of ws2812b

Hi all,
Completely new user to Arduino and fastled.I have a strip of ws2812b led’s but I am having great difficulty in reversing the direction of the led’s.I can make 5 leds travel the length of the strip (150 leds) but how do you get them to run the other way i.e 150 to 0.Any help would be greatly appreciated.Thank you.

Replace i by (NUM_LEDs -i-1)

for(i=0; i<NUM_LEDs; i++)
{ int position= NUM_LEDs-i-1c; strip.setPixelColor(position, strip.Color(i,position,0));}

Hi Walter.Thank you for your very swift reply.I will try that.

Sorry the c after the 1 is a typo.

Thank you.Noted.

Hi again.I have looked at my code and it is quite different to http://yours.So I am not sure how to integrate http://it.My code is as follows.
#include <FastLED.h>
#define LED_DT 6
#define COLOR_ORDER GRB
#define LED_TYPE WS2812
#define NUM_LEDS 300
uint8_t max_bright = 255;
struct CRGB leds[NUM_LEDS];

int index1;
int index2;
int index3;
unsigned long initialtime;

void setup() {
delay (1000);
LEDS.addLeds<LED_TYPE, LED_DT, COLOR_ORDER>(leds, NUM_LEDS);
FastLED.setBrightness(max_bright);
index1 = 0;
// index2 = 0;
// index3 = 0;
initialtime = millis();

void FASTLED() {
for(int a =0;a<=299; a++){
FastLED.clear();
set5leds(index1);
index1 = (index1 + 1) % (NUM_LEDS - 5);
if (millis() - initialtime > 1000) {

}
set5leds(index2);
index2 = (index2 + 1) % (NUM_LEDS - 5);
if (millis() - initialtime > 2700) {

set5leds(index3);
index3 = (index3 + 1) % (NUM_LEDS - 5);
if (millis() - initialtime > 3000) {
}
FastLED.show();
delay (1);
}
}
return 0;
}

void set5leds(int pos) {
leds[pos].setRGB (255, 255, 0);
leds[pos + 1].setRGB (255, 255, 0);
leds[pos + 2].setRGB (255, 255, 0);
leds[pos + 3].setRGB (255, 255, 0);
leds[pos + 4].setRGB (255, 255, 0);
return 0;
}

Whenever you call set5leds replace pos by (NUM_LEDS-pos-1).

In the routine itself replace all the positions in the square bracket index to Leds by
leds[constrain(pos,0, NUM_LEDS-1)]so as not to get out of range and mess up the fastlib.
You are on a perfect way, neat clearly structured program, a pleasure to read.
Alternatively you can add another parameter to set5leds e.g. set5leds(int index, bool reverse]
and at the begining add the statement
if(reverse) pos=NUM_LEDS-pos-1

This will NOT have any effect on where you call the function. A parameter is just a local variable writing to it will not effect the caller.

Hi Walter.Thank you so much for your help and thank you for the compliment too.I will try this now and let you know the result.