Getting Started With DotStar LEDs
DotStar LEDs are extremely popular and are great for creating high quality LED displays. They can easily be controlled using a microcontroller such as an Arduino. We're asked frequently how to connect them and begin to control them so we've put together this short guide to get you started.
Connecting to a Controller
We'll be using an Arduino Uno in this guide but the same wiring can easily be replicated across other DotStar compatible microcontrollers. Data can only flow through the LED strip in one direction so it is important to ensure you're using the connections on the correct side. The connections should be labelled on the LED strip either at the end where the connector is or on the PCB silkscreen, there is usually an arrow that indicates the direction of the dataflow. With a DotStar LED strip, there will be 4 connections, Data In (DI), Clock In (CI), VCC and GND.
- Data In (DI) -> Any digital data I/O pin on the controller
- Clock In (CI) -> Any digital data I/O pin on the controller
- VCC -> 5V Pin
- GND -> Ground Pin
When using a NeoPixel compatible LED strip there are a few different libraries that you can use, we suggest using the Adafruit DotStar library. If you're not familiar with how Arduino libraries are installed then feel free to check out our previous blog post on How to install libraries when using the Arduino IDE.
Using the Example Code
Once you've installed the library then we'd suggest starting by using one of the example programs. These are basic programs with clearly commented code that demonstrates the main functionality of the LED strip. In each of the examples, you'll need to change a couple of lines of code to customise the program to the LED strip that you're using.
You'll need to change the code so that the data & clock pins you have the strip connected to on the controller is correctly reflected in the code and also define the pixel length of the LED strip or ring that you're using.
The one last line of code you may need to edit is the complete definition of the LED strip. The code that says DOTSTAR_BRG defines the order of the LEDs in the data. It's most likely that you won't need to edit this line but if you notice that when you program an LED to be red and it displays green or blue then you'll need to change this.
Once you've changed those lines, program your Arduino/controller and you should see the LED strip light up. Now you can play around and change the code to create different colours and patterns. If you're looking for more information on powering LED strips then we'd suggest looking at this previous blog post.