Pololu Robotics & Electronics
My account Comments or questions? About Pololu Contact Ordering information Distributors

Control addressable LED (SK6812) directly via .net api?


I’m trying to achieve something shockingly simple.
I want to use an addressable LED strip as a random indicator, i.e. have the LEDs “pick” various items arranged below them.
No more than 8 LEDs will ever be lit at the same time. Doesn’t even need to be in different colors. ON/OFF is just fine. No fancy running lights, nothing.
Yet the process of selecting these items is a bit more complex (parsed user input) and I want it to run as a small .net(C#) application. LEDs should change immidiately on a mouse click.
How exactly do I hook the LED strip to my PC for this? Which “driver” do I need to install?
Any hints are appreciated :slight_smile:



A typical PC does not have the sort of general purpose output pins that are needed to control an SK6812 LED strip directly. If you want to control an SK6812 LED strip from your computer, I would recommend getting an A-Star programmable controller and running the PololuLedStrip library on it. You would use the A-Star’s USB interface to receive commands from the PC and use the PololuLedStrip library to update the LEDs.

You would have to write some C++ code on the A-Star to process the serial commands. A good starting point for the A-Star code would be the LedStripColorTester example that comes with the library, since it shows how to receive a color over USB and then send that color to the LEDs.

On the PC side, you can use the .NET SerialPort class to send commands to the A-Star.

Another option to consider would be to get a Raspberry Pi computer, install Windows 10 IoT Core on it, and then write .NET code on the Raspberry Pi to control an LED strip directly through the Raspberry Pi’s GPIO pins. You would want to use an APA102-based LED strip instead of an SK6812 one, because the SK6812 strips require very precise timing that is probably not possible with an operating system like Windows.



Thanks :relaxed:

Would there be any noticable delays involved with the first solution? i.e. how long would it take for “click - send to port - receive & process command”?
Since it’s supposed to test reaction times, too, everything above 100ms would be a moot point :neutral_face:
In this case I would need to build a device from a RasperryPi with an LCD screen :scream: or go for a different solution alltogether …


With the first solution, I would expect the A-Star to be able to react within a millisecond after receiving the serial data from the computer over USB. The latency between the click and the transmission of the data by the computer is harder to predict because it depends on the details of your operating system, but I still expect it to be too small to notice in most cases.



I think I will risk testing the A-star-setup then :sunglasses:

IF I find I DO have to move the whole thing onto a rasperry, .net wouldn’t be a requirement anymore anyway. That’s just what’s running on my dev PC.

Just one thing regarding the SK6812 strips. If I’d chain them together … is addressing a continous thing?


The “Chaining” section of the product page for any SK6812-based LED strip on our website says:

Multiple LED strips can be chained together by connecting input connectors to output connectors. When strips are chained this way, they can be controlled and powered as one continuous strip. Please note, however, that as chains get longer, they will require more power. If this becomes an issue, you can chain the data lines while separately powering shorter subsections of the chain.

If that does not answer your question, can you please elaborate?



I was wondering whether, e.g. the 1st LED of the second strip can be addressed as “61” when the first one is a 60 LED piece.
So I guess from " they can be controlled … as one continuous strip" is a “yes”, right?


That is basically correct. There is nothing special about the begining or end of the strip in terms of how you control the LEDs. If you are using our Arduino library, the LEDs of the first LED strip would be at indices 0 through 59, and the LEDs of the second strip would be at indices 60 through 119, and you don’t have to do anything special to control the LEDs on the second strip.



I got it working. Yay me LOL! :slight_smile:
Had to dig for a RGBW control script because the SK6812 showed funky colors but I’m all set now.