WS2812B and FastLED not working for MEGA2560

Hi all,

Does anyone know why this code doesn’t work on my mega but works just fine on my Due?

Im sure im missing something simple here.

#include "FastLED.h"

#define NUM_LEDS 1
#define DATA_PIN 6

// Define the array of leds
CRGB leds[NUM_LEDS];

void setup() {
  FastLED.addLeds<NEOPIXEL, DATA_PIN>(leds, NUM_LEDS);
}

void loop() {
  // Turn the first led red for 1 second
  leds[0] = CRGB::Red; 
  FastLED.show();
  delay(1000);

  // Set the first led back to black for 1 second
  leds[0] = CRGB::Black;
  FastLED.show();
  delay(1000);
}

Things look okay.

Show us a good image of your wiring.

.

Photos attached.
Like I said, it works on my Due. The power source is good, only thing that appears to be at fault is the data in. I’ve tried different pins but no change…

You misunderstood, let's see how you are connecting it to the Mega.

.

should i be using one of the following class variables (i think that’s what it’s called), instead of NEOPIXEL?

     // Uncomment/edit one of the following lines for your leds arrangement.
      // FastLED.addLeds<TM1803, DATA_PIN, RGB>(leds, NUM_LEDS);
      // FastLED.addLeds<TM1804, DATA_PIN, RGB>(leds, NUM_LEDS);
      // FastLED.addLeds<TM1809, DATA_PIN, RGB>(leds, NUM_LEDS);
      // FastLED.addLeds<WS2811, DATA_PIN, RGB>(leds, NUM_LEDS);
      // FastLED.addLeds<WS2812, DATA_PIN, RGB>(leds, NUM_LEDS);
      // FastLED.addLeds<WS2812B, DATA_PIN, RGB>(leds, NUM_LEDS);
         FastLED.addLeds<NEOPIXEL, DATA_PIN>(leds, NUM_LEDS);
      // FastLED.addLeds<APA104, DATA_PIN, RGB>(leds, NUM_LEDS);
      // FastLED.addLeds<UCS1903, DATA_PIN, RGB>(leds, NUM_LEDS);
      // FastLED.addLeds<UCS1903B, DATA_PIN, RGB>(leds, NUM_LEDS);
      // FastLED.addLeds<GW6205, DATA_PIN, RGB>(leds, NUM_LEDS);
      // FastLED.addLeds<GW6205_400, DATA_PIN, RGB>(leds, NUM_LEDS);
      
      // FastLED.addLeds<WS2801, RGB>(leds, NUM_LEDS);
      // FastLED.addLeds<SM16716, RGB>(leds, NUM_LEDS);
      // FastLED.addLeds<LPD8806, RGB>(leds, NUM_LEDS);
      // FastLED.addLeds<P9813, RGB>(leds, NUM_LEDS);
      // FastLED.addLeds<APA102, RGB>(leds, NUM_LEDS);
      // FastLED.addLeds<DOTSTAR, RGB>(leds, NUM_LEDS);

      // FastLED.addLeds<WS2801, DATA_PIN, CLOCK_PIN, RGB>(leds, NUM_LEDS);
      // FastLED.addLeds<SM16716, DATA_PIN, CLOCK_PIN, RGB>(leds, NUM_LEDS);
      // FastLED.addLeds<LPD8806, DATA_PIN, CLOCK_PIN, RGB>(leds, NUM_LEDS);
      // FastLED.addLeds<P9813, DATA_PIN, CLOCK_PIN, RGB>(leds, NUM_LEDS);
      // FastLED.addLeds<APA102, DATA_PIN, CLOCK_PIN, RGB>(leds, NUM_LEDS);
      // FastLED.addLeds<DOTSTAR, DATA_PIN, CLOCK_PIN, RGB>(leds, NUM_LEDS);

I tried your sketch on an UNO, works fine with a single WS2812B.

bouldermonkey: should i be using one of the following class variables (i think that's what it's called), instead of NEOPIXEL

No

Have you correctly uploaded the sketch with correct board settings?

INTP: Have you correctly uploaded the sketch with correct board settings?

Yeah I can get simple blink code to work. However I think the board may be faulty as its not consistent on all digital pins.

It's almost never the board. Unless the user has killed it by abusing it.

INTP: It's almost never the board. Unless the user has killed it by abusing it.

I've just confirmed that the board is at fault. I can see some of the solder has come away from the pins. All seems to be consistent when I use the back of the pins. I dare say that this happened when I brought it over from the UK in my suitcase. So yeah, abuse from the user is a fair call.

Thanks for your help and input. Closing the thread.