1

I recently designed a board for an LED project. I am using WS2812B as the LED, and an ATMEGA328P-AU as the microcontroller. I also am using an arduino nano as my ISP and using "flash with programmer". When I flashed the FastLED blink example (Code below) the LED lit up as white and stayed white when it was supposed to flash red. I tried various examples and they all had the same outcome, just white. Am I missing a crucial component in my circuit (aside from some decoupling capacitors)? Is it a software problem?

#include <FastLED.h>

#define NUM_LEDS 1
#define DATA_PIN 5

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

void setup() { 
     FastLED.addLeds<WS2812B, DATA_PIN, GRB>(leds, NUM_LEDS);  // GRB ordering is typical
}

void loop() { 
  // Turn the LED on, then pause
  leds[0] = CRGB::Red;
  FastLED.show();
  delay(500);
  // Now turn the LED off, then pause
  leds[0] = CRGB::Black;
  FastLED.show();
  delay(500);
}

enter image description here

3
  • Sounds like a timing problem. Have you set your fuses to use the external 16MHz or is it still on the internal 1MHz (or 8MHz whatever the default is)?
    – Majenko
    Jul 28, 2020 at 19:48
  • @Majenko It was a timing thing! thank you for the suggestion! I burnt the bootloader onto the chip, then flashed the sketch and it fixed the problem! Jul 28, 2020 at 21:00
  • Then yes, it was the fuses set wrong.
    – Majenko
    Jul 28, 2020 at 21:02

1 Answer 1

4

The WS2812B chips are very sensitive to timing. They rely on pulses being just the right length for things to work.

It is common if the timing is off that you just end up with white.

Since you have a blank chip that you have never put a bootloader on the fuses will be set wrongly for your configuration. By default a chip comes configured for the internal 8MHz oscillator. That means that everything will be running at half the speed.

You need to set the fuses to use the 16MHz crystal so that it matches the F_CPU setting of 16000000 in the board configuration. Either that or use a board configuration that expects to run at 8MHz.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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