The FreePixel RGB LEB Module is an addressable multi-colour LED that can be daisy-chained into long strings. You can start with one module and simply add more as you need them, without requiring any additional I/O pins from your microcontroller.
The FreePixel module has two sets of connections: one for input on the left, and one for output on the right to daisy-chain to other modules.
If you only have a single module, ignore the connections on the right and only use the connections on the left.
- V+ supplies power to the module. This is typically connected to the 5V header of your Arduino. You can also run the module at a lower voltage such as 3.3V, but the LED won't be as bright. The current required may be significant if many modules are connected together. More information about this later.
- G is the ground connection of the module. Connect to the GND header of your Arduino.
- DI is the "data input" connection to the module. This is a low-current digital connection that sends commands to the module.
- DO is the "data output" connection from the module. This passes commands through to the next module in a chain.
Connect G on the module to GND on your Arduino.
Connection V+ on the module to 5V on your Arduino.
Connect DI on the module to a digital pin oun your Arduino. It can be any pin, but we'll use digital pin 3 in this tutorial.
The FreePixel module includes a WS2812B LED driver IC, so you can control it using libraries or code that are compatible with that IC.
Compatible software includes the FastLED library and the NeoPixel library. We'll use the FastLED library.
Go to FastLED.io and follow the instructions to download and install the library. Then restart the Arduino IDE.
In the Arduino IDE, select "File -> Examples -> FastLED -> Blink".
Line 9 of the Blink example specifies the DATA_PIN setting, which is the digital pin used to communicate with the module. The example uses pin 3, but you can change it to suit your project.
Line 10 specifies the CLOCK_PIN setting, but we don't care about that. You can leave it unchanged, or even comment it out.
Line 23 specifies the device type as a NEOPIXEL. You can leave that unchanged because the driver IC is the same.
Now you're ready to go. The last part of the sketch flashes the red channel on and off at half second intervals, so if you run the sketch now it will flash the FreePixel red.
Powering the modules
The 5V header on your Arduino may be limited to 500mA or less, depending on the rating of the onboard voltage regulator and whether power is being sourced from the DC IN jack or USB.
Each FreePixel can draw up to 60mA of current at 5V, when each element (red, green, and blue) is fully illuminated. Unless you're driving your pixels at maximum brightness white they will require less than this, but it's a good idea to keep it in mind when planning your project. This means that just 8 pixels may be enough to overload the regulator on your Arduino if you drive them to full brightness at the same time.
If you don't intend to run your pixels in full-brightness white, a good rule of thumb is to take the number of pixels and multiply it by 20mA to see how much current you need to supply. Then allow a bit extra for safety.
If that number exceeds the power available from your Arduino, you may need to add an external 5V power source for the modules. You can connect the power source GND to Arduino GND, and then connect the power source + to the VCC input on your module:
If you have more than a couple of pixels connected together it's also a good idea to add some bulk capacitance across the power rails, to help smooth out the power supply voltage when the LEDs rapidly change their illumination and also handle the inrush current when they first power up. Something like a 470uF or 1000uF electrolytic is good. Just make sure that it's rated well above the supply voltage, so if you're running your pixels at 5V you'll need a capacitor rated to at least 6.3V (but 10V is better) for safety. Connect the "+" side of the capacitor to the V+ line, and the "-" side of the capacitor to the GND (G) line.