I'm working on an LED controller for some WS2812B individually addressable LEDs. I ran into an issue where the Uno does not have enough memory to control the number of LEDs I need, so I purchased an Arduino Zero, which I've never used before.
For the life of me, I can't seem to get the Zero to control the LEDs properly.
Here's my wiring diagram. I followed this exact pattern on both the Uno and the Zero.
I've confirmed that it's not an issue with the power supply or the LED strips.
Here's the simple code I'm running on both the Zero and the Uno:
#include "FastLED.h"
#define NUM_LEDS 6
CRGB leds[NUM_LEDS];
void setup() {
// initialize digital pin LED_BUILTIN as an output.
pinMode(LED_BUILTIN, OUTPUT);
FastLED.addLeds<WS2811, 4>(leds, NUM_LEDS);
}
void loop() {
FastLED.setBrightness(2);
digitalWrite(LED_BUILTIN, HIGH); // turn the onboard LED o
leds[0] = CRGB::White; //enable ws2812b LED
FastLED.show();
delay(300);
digitalWrite(LED_BUILTIN, LOW); // turn the onboard LED off
leds[0] = CRGB::Black; //disable the ws2812b LED
FastLED.show();
delay(300);
}
When I run this code on the Uno, the onboard LED and the LED on the strip both blink. When I run the code on the Zero, the onboard LED blinks, so I know the program is running. But I get nothing on the strip:
Not may-be but it is not enough. I normally use two of the buffers in a 74HCT14 powered by 5V to do the voltage translation.
Also there is no large capacitor on the strip's power supply pins, nor no anti reflection / protection resistors on the data line. You will need these as the strip grows to accommodate those extra LEDs you could not address in the Uno. Also it is best to wire a power and ground to the end of the strip as well. For longer strips power and ground might be needed to be supplied in the middle as well.
Also the set brightness line should be in the setup function, there is no need to do it every time round the loop.
I am powering the LEDs via an external power supply, not the board itself. I did know about needing additional power at the other end. I'm just trying to get one LED working first before I tackle multiple strips
For someone who's fairly new to this sort of hardware, what's the easiest way for me to send a 5V signal? Or is there another Arduino I should use that is 5V but has more memory like the Zero?
And yes, the brightness should be in Setup. I added that last second because I was getting blinded by a very bright LED on my desk while writing this post.
Well the Mega has 8K of memory which is four times the memory the Uno has and is 5V.
There is not much in the way of ready built voltage level converters. Beware of the bidirectional level converters designed for I2C signals. They are right in the limit of being able to work at the required speed. We have had reports of them working and not working, with one of the more knowledgable members saying that the one he had stopped working when is fingers touch the wires. A sure fire way that someone is working at the edge.
You could use a FRAM memory device, 32K by 8 for just a few dollars. I use an arduino UNO or Nano and write code to stuff it with the values, big arrays will work. When it is loaded you are set, it is a nonvolital piece of memory and unlike EEPROM there are no delays, it will go as fast as the Arduino can drive it. Your choice, SPI, I2C, and parallel. You can keep all of your data there freeing a lot of program memory.