Fastled issue

Hello all

I know you like the code to be shown... out in the truck at the moment, but when I get back I can upload if required.

RGB addressable strip. All going fine with Fastled library.

Except... when I issue this command:

if (Led_Col==1);{leds1[Led_Tilt_Pos] = CRGB(255, 0, 0);FastLED.show();} (Hope I remembered that right).

It is changing all the LED colours, and not just the one at the position 'Led_Tilt_Pos'.
Is there a list of Fastled functions anywhere? I Googled and failed. Not 100% I am using the correct function to illuminate a single led.

OK... commented out various lines...

leds1[6] = CRGB(255,255,255);FastLED.show();

This illuminates led number 7 as it should in white, but it changes all the other leds in the strip to blue?
Comment this line out, and everything works as it should.

Is this not the correct way of illuminating a single led?

You really need to post your complete program or a smaller but complete program that illustrates the problem. Without that we have no way of knowing how and where leds1[] is declared for example.

Your command is correct, as Bob says there must be a problem somewhere else that makes you think it's here.

(deleted)

(deleted)

I am trying to find a list of the Fastled commands that isn't madly complicated.
Just found Fastled.clear... that removes my for loop statements to clear the whole strip for starters

I did not look at your code.

To swap colours

FastLED.addLeds<WS2812B, DATA_PIN, [b][color=red]GRB[/color][/b]>(leds, NUM_LEDS);

Did you look @spycatcher2k's reply #4.

Yes.. I saw reply 4. That line is commented out, so it's not that.

I am trying to find a list of the Fastled commands that isn't madly complicated.

FastLED wiki works for me

You can call Serial.flush() after a Serial.print() to guarantee that the Serial buffer is emptied before continuing.

void Change_barrel () {

  Serial.println("Change barrel routine");
  Serial.flush();

Serial.print() will happily work without blocking till the Serial buffer is full. You can check how much you can still write to the buffer using Serial.availableForWrite() and do not write to the buffer if there is insufficient space.

void Change_barrel () {

  if(Serial.available() >23)
  {
    Serial.println("Change barrel routine");
  }
  else
  {
    skip the print
  }

or a blocking version

void Change_barrel () {

  // wait till there is sufficient space
  while(Serial.available() < 23);
  Serial.println("Change barrel routine");

Note:
21 is the size of the text Change barrel routine; 2 extra added for

You are writing out of bounds...

void Illuminate_barrel () {                                                                 //Light the barrel

  if (Barrel > 0) {
    for (int g = 0; g < NUM_LEDS1 / 1.8; g++) {
      if ((Barrel > 6) and (Barrel < 10)) {
        g++; //If every other led required, then skip the count
      }
      leds1[g] = CRGB(Green, Red, Blue);
      leds1[NUM_LEDS1 - g] = CRGB(Green, Red, Blue);
      FastLED.show();
      delay(6);
    }
  }
}

first time through the loop, g = 0 so you are writing to leds1[NUM_LEDS1].

I would second the advise about putting this together in pieces..

blh64:
first time through the loop, g = 0 so you are writing to leds1[NUM_LEDS1].

Totally agree with you there ! but hey it's Fastled !

But isn't the first led address 0?

Steve-SFX:
But isn't the first led address 0?

Yes, but the last LED is not NUM_LEDS, but NUM_LEDS-1. Array index starts at 0, so final element is (length-1) not (length).

blh64:
You are writing out of bounds...

first time through the loop, g = 0 so you are writing to leds1[NUM_LEDS1].

I would second the advise about putting this together in pieces..

Nice catch, karma added

Gotcha.... thank you for that.

I have re-written the code so that it sets the RGB colours, and only updates the strip once a loop, rather than updating every time something changes.
Seems to be OK at the moment.

Thank you for all advice!