0

I am working with the LED strip WS2812b and FastLED library, currently I have only 3 LEDs connected in such a way that the first 2 receive a color (say green) and the last one receives another one (say blue).

The problem is that by putting the color (blue) on the last LED, the other two (currently only in green) also take a portion of blue, preventing it from being a pure (green) color. It happens with any combination of color.

I leave the piece of my code referring to the LED strip:

#include "FastLED.h"
#define NUM_LEDS 3
#define DATA_PIN 2

//Variables declaration...
....

void setup() {
  FastLED.addLeds<WS2812B, DATA_PIN, RGB>(leds, NUM_LEDS);
.....

  }


void loop() {
  ReadMySerial();       //This function take data from serial port and set the color for the leds
  FastLED.setBrightness(brigth);

  for (int pinNo = 0; pinNo <= 2; pinNo++){
    leds[pinNo].setRGB(green_inactive,red_inactive,blue_inactive);
    FastLED.show();
      if (digitalRead(pinNo+3) == HIGH){
        leds[pinNo].setRGB(green_reactive,red_reactive,blue_reactive);
           FastLED.show();
            }
        }


  }

I already change the pin for where I put the signal for the LED strip, I try to change the type of LED strip

  • FastLED.addLeds<NEOPIXEL, DATA_PIN>(leds, NUM_LEDS)
  • FastLED.addLeds<WS2812, DATA_PIN, RGB>(leds, NUM_LEDS)
  • FastLED.addLeds<WS2812, DATA_PIN, COLOR_ORDER>(leds, NUM_LEDS)

without any success...

Can anyone point me in the rigth direction?

Edit: actually, the first LED of the strip is flashing, not in the way of the Blinking example, but I can see a little flashing.

1

I can see what the problem is, I put FastLED.show(); where it should not, that's also why I saw the flash ... fix it and here's the result:

void loop() {
  ReadMySerial();       //This function take data from serial port and set the color for the leds
  FastLED.setBrightness(brigth);

  for (int pinNo = 0; pinNo <= 2; pinNo++){
    leds[pinNo].setRGB(green_inactive,red_inactive,blue_inactive);
    FastLED.show();
    if (digitalRead(pinNo+3) == HIGH){
      leds[pinNo].setRGB(green_reactive,red_reactive,blue_reactive);
    }
  }

  FastLED.show(); //NOW IS IN THE RIGHT POSITION
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.