2

I recently purchased a pi and a string of individually addressable rgb led lights from shenhzen kapata (actually amazon, but they're the ones who sell it) and I'm trying to control it with my raspberry pi.

First a bit about my setup:

I have node compiled and installed and am using the pi-spi module to send a buffer through the spi. Documentation for that can be found at https://www.npmjs.com/package/pi-spi. My pi model is the B+ and I've connected the Data In (DI) lead from the lights to pin 19 (GPIO10 SPI0_MOSI) and the clock in (CI) to pin 23 (GPIO11 SPI0_SCLK) using alligator clips. I have spi enabled, and I know the node spi module is working, because connecting pin 19 (SPI0_MOSI) to pin 21 (SPI0_MISO), and sending a buffer of "hello world!" returns the same buffer back to me. I'm using another helper module called raspberrypixels which takes values for rgb, and the number of pixels in your strand * 3 (for rgb) and creates a hex buffer to send to the lights. My lights are 5 meters long and have 150 rgb led clusters, so 450 leds in total. The IC chip is LPD6803 which I believe is SPI compatible. A link to the lights here

My Problem

My issue is that I can't get the lights to behave in any predictable way. For instance, sending a buffer of

<Buffer ff ff 00 ff ff 00 ff ff 00 ff ff 00 ff ff 00 ff ff 00 ff ff 00 ff ff 00 ff ff 00 ff ff 00 ff ff 00 ff ff 00 ff ff 00 ff ff 00 ff ff 00 ff ff 00 ff ff 00 ...>

450 elements long I would expect to turn every light in the strand yellow

ff (255) red, ff (255) green and 00 blue 

but it has no effect. However sending a random string of data will turn some of the lights different colors. I have no way of predicting what works and what doesn't.

Does anyone have any experience with this kinda thing? I know I could use the pi-blaster module, but my lights don't have specific r,g,b leads, just data and clock. Also I want to control these via a web interface, hence Node.

This is the actualy code I'm using to test

var SPI = require('pi-spi');

var spi = SPI.initialize("/dev/spidev0.0"),
    Pixel = require('raspberrypixels'),
    test = Buffer("Hello, World!");
   // console.log(Pixel);
var PIXEL = new Pixel.PixelBuffer(150);

PIXEL.fillRGB(255,255,0);

test = PIXEL.get();

console.log(test);
console.log(test.length);

// reads and writes simultaneously
spi.transfer(test, test.length, function (e,d) {
    if (e) console.error(e);
    else console.log("Got \""+d.toString()+"\" back.");
  • Why do you think you can drive the LEDs through SPI? What type of LEDs? – joan Feb 8 '15 at 20:39
  • sorry forgot to add the IC chip details. The chip model is LPD6803 which from what I can tell should be SPI compatible. – richbai90 Feb 8 '15 at 20:46
  • adafruit.com/datasheets/LPD6803.pdf suggests there is a 32 bit start frame (all zeros) followed by a 16 bit word per LED. 1 bit high, then 5 bits for R, G, and B. – joan Feb 8 '15 at 20:53
  • Can you help me understand what that means? In my example of turning the lights yellow <Buffer ff ff 00 ...> following this pattern, what would that buffer need to look like? – richbai90 Feb 8 '15 at 21:07
  • 00 00 00 00 FC 00 FC 00 FC 00 FC 00 etc. The first four bytes are the 32 bit header. Then FC 00 (two bytes per LED). FC 00 is 1111 1100 0000 0000, break that up into 1 11111 00000 00000 (1 start bit, R fully on, G zero, B zero). – joan Feb 8 '15 at 21:34
0

A little bit of an old question, but for reference: I believe the lpd6803 is spi-like but needs the clock to continue to be send. The chips on your LED strip need the clock input for their PWM to work.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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