Hi guys,
With my final LED purchase from China I decided to throw in some WS2811 for a change. I've been driving LPD6803 / IC1010 and WS2801 successfully but I hadn't touched anything else yet. The LEDs are supposed to be 5v (I can also read that off the small PCB inside each LED)
The LEDs are on what I would decribe as a strand. Seperated roughly 10~25 cm from each other, connected by 3 wires. I've downloaded a few libraries to drive them but I cannot seem to get any results.
Here's a list of what I have tried:
- Adafruit Neopixel library w/ various pins: GitHub - adafruit/Adafruit_NeoPixel: Arduino library for controlling single-wire LED pixels (NeoPixel, WS2812, etc.)
- Alan Beaklow's library http://bleaklow.com/2012/12/02/driving_the_ws2811_at_800khz_with_a_16mhz_avr.html
- FastSPI_LED2 library: Google Code Archive - Long-term storage for Google Code Project Hosting.
For each of these libraries I have tried driving a single pixel and multiples. I have tried various pins. For Alan's lib I tried PORTB pin 0 which should be digital pin 8 on the Uno. I have tried another Arduino device (Uno, Mini, Ethernet).
What happens:
- Nothing when I plug them in
- As they don't seem to have a direction, I've tried both ends
- After some random time a few leds will light up with random colors
Any tips on how to proceed?
Here's some of the code I used:
#include <Adafruit_NeoPixel.h>
// I HAVE TRIED SEVERAL PINS AND THE NEO_KHZ400 option too
Adafruit_NeoPixel strip = Adafruit_NeoPixel(60, 11, NEO_GRB + NEO_KHZ800);
void setup() {
strip.begin();
strip.show(); // Initialize all pixels to 'off'
}
void loop() {
// Some example procedures showing how to display to the pixels:
colorWipe(strip.Color(255, 0, 0), 50); // Red
colorWipe(strip.Color(0, 255, 0), 50); // Green
colorWipe(strip.Color(0, 0, 255), 50); // Blue
rainbow(20);
rainbowCycle(20);
}
#include "FastSPI_LED2.h"
#define NUM_LEDS 150
struct CRGB leds[NUM_LEDS];
void setup() {
delay(2000);
LEDS.setBrightness(64);
LEDS.addLeds<WS2811, 11>(leds, NUM_LEDS);
}
void loop() {
for(int i = 0; i < 3; i++) {
for(int iLed = 0; iLed < NUM_LEDS; iLed++) {
memset(leds, 0, NUM_LEDS * sizeof(struct CRGB));
switch(i) {
// You can access the rgb values by field r, g, b
case 0: leds[iLed].r = 128; break;
// or by indexing into the led (r==0, g==1, b==2)
case 1: leds[iLed][i] = 128; break;
// or by setting the rgb values for the pixel all at once
case 2: leds[iLed] = CRGB(0, 0, 128); break;
}
// and now, show your led array!
LEDS.show();
delay(10);
}
// fade up
for(int x = 0; x < 128; x++) {
// The showColor method sets all the leds in the strip to the same color
LEDS.showColor(CRGB(x, 0, 0));
delay(10);
}
// fade down
for(int x = 128; x >= 0; x--) {
LEDS.showColor(CRGB(x, 0, 0));
delay(10);
}
// let's fade up by scaling the brightness
for(int scale = 0; scale < 128; scale++) {
LEDS.showColor(CRGB(0, 128, 0), scale);
delay(10);
}
// let's fade down by scaling the brightness
for(int scale = 128; scale > 0; scale--) {
LEDS.showColor(CRGB(0, 128, 0), scale);
delay(10);
}
}
}
#include <avr/io.h>
#include <util/delay.h>
#include <WS2811.h>
#define BIT(B) (0x01 << (uint8_t)(B))
#define SET_BIT_HI(V, B) (V) |= (uint8_t)BIT(B)
#define SET_BIT_LO(V, B) (V) &= (uint8_t)~BIT(B)
#define PAUSE 1000 // msec
#define DELAY 10 // msec
// Define the output function, using pin 0 on port b.
DEFINE_WS2811_FN(WS2811RGB, PORTB, 0)
// Drive the three pixels in an infinit loop.
void threepixeldemo(void)
{
// Configure pin for output.
SET_BIT_HI(DDRB, 0);
SET_BIT_LO(PORTB, 0);
// off->red, off->green, off->blue
RGB_t rgb[3] = {{0,0,0},{0,0,0},{0,0,0}};
WS2811RGB(rgb, ARRAYLEN(rgb));
_delay_ms(PAUSE);
for (int i = 0; i < 255; i++) {
rgb[0].r += 1;
rgb[1].g += 1;
rgb[2].b += 1;
WS2811RGB(rgb, ARRAYLEN(rgb));
_delay_ms(DELAY);
}
// loop forever.
for (;;) {
// red->yellow, green->cyan, blue->magenta
for (int i = 0; i < 255; i++) {
rgb[0].g += 1;
rgb[1].b += 1;
rgb[2].r += 1;
WS2811RGB(rgb, ARRAYLEN(rgb));
_delay_ms(DELAY);
}
}
}
All of the code compiles and seems to be running. I am using Aruino 1.0.4.
Any help and suggestion is greatly appreciated. Here's a pic of the LEDs.