benscammell
Well-known member
So I think there is some kind of issue with FastLED and APA102 LED's.
I have 240 APA102 LED's in a strip being driven of the SPI pins (11, 13) with an 74HCT125 buffer on the data and clock lines. There are power taps and 0.1uF every 30 LED's and 1000uF every 120 LED's.
The PSU is a 50A, 5V supply.
I've tested with Adafruit_Dotstar library, using the demo "strandtest" and everything works perfectly, NO FLICKER.
I've tested with FastLED library, using the Cylon demo and there is (significant, red) flicker on the last 10 LED's.
Can anyone give me any advice?
Thanks, Ben
Note, what the demo's are doing is irrelevant... I'm just trying to prove I can drive the LED's effectively with the libraries, and my preference is you use FastLED.
With the Adafruit_Dotstar/strandtest demo all I changed in the code was the strip length, here's the code....
With the FastLED/cylon demo, here's the code I used...
I have 240 APA102 LED's in a strip being driven of the SPI pins (11, 13) with an 74HCT125 buffer on the data and clock lines. There are power taps and 0.1uF every 30 LED's and 1000uF every 120 LED's.
The PSU is a 50A, 5V supply.
I've tested with Adafruit_Dotstar library, using the demo "strandtest" and everything works perfectly, NO FLICKER.
I've tested with FastLED library, using the Cylon demo and there is (significant, red) flicker on the last 10 LED's.
Can anyone give me any advice?
Thanks, Ben
Note, what the demo's are doing is irrelevant... I'm just trying to prove I can drive the LED's effectively with the libraries, and my preference is you use FastLED.
With the Adafruit_Dotstar/strandtest demo all I changed in the code was the strip length, here's the code....
Code:
// Simple strand test for Adafruit Dot Star RGB LED strip.
// This is a basic diagnostic tool, NOT a graphics demo...helps confirm
// correct wiring and tests each pixel's ability to display red, green
// and blue and to forward data down the line. By limiting the number
// and color of LEDs, it's reasonably safe to power a couple meters off
// the Arduino's 5V pin. DON'T try that with other code!
#include <Adafruit_DotStar.h>
// Because conditional #includes don't work w/Arduino sketches...
#include <SPI.h> // COMMENT OUT THIS LINE FOR GEMMA OR TRINKET
//#include <avr/power.h> // ENABLE THIS LINE FOR GEMMA OR TRINKET
#define NUMPIXELS 240 // Number of LEDs in strip
// Here's how to control the LEDs from any two pins:
#define DATAPIN 11
#define CLOCKPIN 13
Adafruit_DotStar strip = Adafruit_DotStar(
NUMPIXELS, DATAPIN, CLOCKPIN, DOTSTAR_BRG);
// The last parameter is optional -- this is the color data order of the
// DotStar strip, which has changed over time in different production runs.
// Your code just uses R,G,B colors, the library then reassigns as needed.
// Default is DOTSTAR_BRG, so change this if you have an earlier strip.
// Hardware SPI is a little faster, but must be wired to specific pins
// (Arduino Uno = pin 11 for data, 13 for clock, other boards are different).
//Adafruit_DotStar strip = Adafruit_DotStar(NUMPIXELS, DOTSTAR_BRG);
void setup() {
#if defined(__AVR_ATtiny85__) && (F_CPU == 16000000L)
clock_prescale_set(clock_div_1); // Enable 16 MHz on Trinket
#endif
strip.begin(); // Initialize pins for output
strip.show(); // Turn all LEDs off ASAP
}
// Runs 10 LEDs at a time along strip, cycling through red, green and blue.
// This requires about 200 mA for all the 'on' pixels + 1 mA per 'off' pixel.
int head = 0, tail = -10; // Index of first 'on' and 'off' pixels
uint32_t color = 0xFF0000; // 'On' color (starts red)
void loop() {
strip.setPixelColor(head, color); // 'On' pixel at head
strip.setPixelColor(tail, 0); // 'Off' pixel at tail
strip.show(); // Refresh strip
delay(20); // Pause 20 milliseconds (~50 FPS)
if(++head >= NUMPIXELS) { // Increment head index. Off end of strip?
head = 0; // Yes, reset head index to start
if((color >>= 8) == 0) // Next color (R->G->B) ... past blue now?
color = 0xFF0000; // Yes, reset to red
}
if(++tail >= NUMPIXELS) tail = 0; // Increment, reset tail index
}
With the FastLED/cylon demo, here's the code I used...
Code:
#include "FastLED.h"
// How many leds in your strip?
#define NUM_LEDS 240
// Define the array of leds
CRGB leds[NUM_LEDS];
void setup() {
LEDS.addLeds<APA102>(leds,NUM_LEDS);
LEDS.setBrightness(84);
}
void fadeall() { for(int i = 0; i < NUM_LEDS; i++) { leds[i].nscale8(250); } }
void loop() {
static uint8_t hue = 0;
// First slide the led in one direction
for(int i = 0; i < NUM_LEDS; i++) {
// Set the i'th led to red
leds[i] = CHSV(hue++, 255, 255);
// Show the leds
FastLED.show();
// now that we've shown the leds, reset the i'th led to black
// leds[i] = CRGB::Black;
fadeall();
// Wait a little bit before we loop around and do it again
delay(10);
}
// Now go in the other direction.
for(int i = (NUM_LEDS)-1; i >= 0; i--) {
// Set the i'th led to red
leds[i] = CHSV(hue++, 255, 255);
// Show the leds
FastLED.show();
// now that we've shown the leds, reset the i'th led to black
// leds[i] = CRGB::Black;
fadeall();
// Wait a little bit before we loop around and do it again
delay(10);
}
}
Last edited: