I am just getting started with FastLED and I'm using an Arduino Nano. I'm running the following basic sketch.
#include <Arduino.h>
#include <FastLED.h>
#define FASTLED_INTERNAL
int led = 13;
#define NUM_LEDS 60
#define LED_PIN 9
CRGB leds[NUM_LEDS] = {0};
// the setup routine runs once when you press reset:
void setup() {
pinMode(led, OUTPUT);
pinMode(LED_PIN, OUTPUT);
FastLED.addLeds<WS2812B, LED_PIN, GRB>(leds, NUM_LEDS);
FastLED.setBrightness(10);
}
// the loop routine runs over and over again forever:
void loop() {
digitalWrite(led, HIGH);
leds[0] = CRGB::Red;
leds[1] = CRGB::Blue;
FastLED.show();
delay(1000);
leds[0] = CRGB::Blue;
leds[1] = CRGB::Red;
FastLED.show();
delay(1000);
}
When I'm powering the LED strip from the 5v/GND of the Nano, it works fine - I get alternating blue/red colors from the first two LEDs on the strip. However, when I power the LED strip from a variable power supply with 5v, they light up white and don't seem to respond to the instructions from the NANO.
Here is how I have it wired for external power (I noticed that I don't have my resistor for the data line or capacitor for the power in these pictures - apologies as I was going a little nuts tearing it down and rewiring it as I attempted to troubleshoot this myself. If it matters, their inclusion makes no difference to this issue as far as I can tell):
The external power supply goes to the breadboard and the power in turn is fed to the LED strip. The green alligator clip for the data line is unchanged from how I use it when when powering directly from the Nano as noted above. Also note that I've run GND from the Nano to the breadboard, too.
One additional thing: the strip arrived with an in-line controller that when powered with 5v will cycle through some simple patterns. It works like a champ when powered from the external power supply. Any assistance is greatly appreciated!
and when you power the nano from the external PS as well.
note: you seem to have connected everything correctly with the exception of a 470R resistor on the dataline. There is no real reason for it to behave like that, other than wonky connections.
When you power the LED strip from the Nano, it should not work. The Nano is not a power supply, but that isn't what your photo shows.
The resistor in the data line is for impedance matching and can be any value from 1K to 10K. Most setups work without it just fine.
The capacitor on the power line is to remove low frequency noise from the power source which presents as strange intensity waviness of the LEDs. Or if powering the controller and LEDs from the same marginal source then fluctuating loads from the processor would glitch the data to the LEDs.
For further diagnosis, please draw a schematic. Note: Pretty Fritzing pictures are NOT a schematic.
I understand that the Nano is not a power supply, however, it is certainly capable of (and successful at) driving 2 LEDs on the strip (a maximum of 120 mA at full brightness) for testing/PoC purposes. I would not ask more of it.
I stated that I'd been using a capacitor (the size was not stated - 100µF for the record) but that I'd simply forgotten to put it back into the picture in my haste along with the resistor on the data line. This didn't make a difference in the behavior of the strip, however. I can try a larger one (maybe 1000 µF) when I get home, though, if you think that'd help.
I'll see if I can find something to help me better diagram the circuit to display how everything is wired together better than the images I provided.
Why pen and paper when I can Google it and find a tool I didn't even know about, lol! I think this is a fair representation of what I'm doing, pardon my liberties with some of the symbols.
The Nano is powered by USB and the line coming from it in the image is a '-', in line with similar notation for the WS2812B object. In retrospect, it is difficult to see.
I managed to test the +/- on the breadboard this morning and it is continuous, so that's one thing to cross off of the list. I did note an odd behavior (to me), though. If the Nano is powered on (via USB) and then I turn on the power supply for the WS2812B, they come on white as I outlined earlier. However, if I power them on in the opposite order, nothing lights up. No clue if that makes any difference at all as far as troubleshooting is concerned.
Grumpy_Mike, I'm going to move the Nano out of its breakout and onto the breadboard today/tonight, kids willing, and run the continuity tests as you described. It should reduce the wire length for everything and make it all a bit more photogenic if needed later. Thanks!
Not so much, apparently the WS2812b lights up white when it has no Input signal.
As stated before, if you have it the way you've drawn it should work. Have you tried powering the Nano with the external powersupply ? (rather than USB) The most suspect to me is the common GND between the nano and the rest. Can you verify with a multimeter that it is actually connected properly ?
Just to check i looked at your code, and saw
void setup() {
pinMode(led, OUTPUT);
pinMode(LED_PIN, OUTPUT); // this is obsolete
// doesn't change anything of course, but FastLED sets the pin to output already
FastLED.addLeds<WS2812B, LED_PIN, GRB>(leds, NUM_LEDS);
FastLED.setBrightness(10);
}
So the jumper I was using for GND with the Nano turned out to be bad. It actually passed the continuity check that Grumpy_Mike recommended when I was running through his suggestions. However, when I tried powerimg the Nano as you suggested, suddenly I had nothing. It turns out that jumper was making contact when bent a certain way, but not when bent a different way.
So long story short, everything is working now and thank you all for your help!