Description: This library lets you control the addressable RGB LED strips from Pololu Robotics & Electronics.
This is a library for the mbed that allows you to control the addressable RGB LED strips from Pololu:
- Addressable RGB 30-LED Strip, 5V, 1m
- Addressable RGB 60-LED Strip, 5V, 2m
- Addressable RGB 150-LED Strip, 5V, 5m
It allows complete control over the color of an arbitrary number of LED strips with an arbitrary number of LEDs. Each LED can be individually controlled, and LED strips can be chained together.
This library should also work with any other LED strip based on the TM1804.
This library has been tested on the mbed NXP LPC1768 (Cortex-M3 at 96 MHz) and the mbed NXP LPC11U24 (Cortex-M0 at 48 MHz). It will probably work on the mbed FRDM KL25Z, but we have not tried it. It might require modifications to run on other boards.
Here are two example programs that show how to use the library:
This is an example program for the PololuLedStrip library. It generates a simple moving rainbow pattern.
This is an example program for the PololuLedStrip library. It generates a simple moving gradient pattern.
As a first step, you should compile and upload one of these to the mbed. When the program runs, the mbed should output color data on pin p8 every 12-18 ms. The expected signal is documented on the Pololu website. The example programs only send colors for 60 LEDs, but they can easily be changed to send more for a longer strip.
The addressable RGB LED strips can be purchased on Pololu's website using the links above.
The data input connector for the LED strip is transparent and has two male pins inside. When looking into the connector and orienting it with the flattened side on the bottom, the left pin is the signal wire and the right pin is ground. The LED strip's ground will need to be connected to the mbed's GND pin, and the LED strip's signal line will be need to be connected to one of the Arduino's I/O lines. Our example programs assume the signal line is connected to p8. These connections can be made using two Male-Female Premium Jumper Wires, with the female ends plugging into the LED strip and the male ends plugged into a breadboard that houses the mbed.
You will also need to connect a suitable power supply to the LED strip using one of the power connectors. The power supply must be at the right voltage and provide enough current to meet the LED strip's requirements.
If everything works properly, you will see a moving pattern of colors on the LED strip.
This library takes about 2 ms to update 30 LEDs (1 meter). The LED strips use a high speed one-wire protocol with relatively strict timing requirements, so this library disables interrupts to ensure reliable color transmission. Unfortunately, disabling the interrupts could cause problems in other libraries that uses interrupts.
This library provides an
interruptFriendly option that can let it coexist with interrupt-based libraries. When this option is enabled, the library will temporarily enable interrupts after each color is sent, about every 60 microseconds. If you can keep all of your interrupts short enough, then this option should allow this library to work in conjunction with your interrupt-based libraries. However, if you have an interrupt enabled that takes longer than about 8 microseconds, then this interrupt will sometimes cause an extra long low pulse to emitted, which will be interpreted by the LED strip as a reset command. This can cause visible flickering in the LED strip. To turn on the
interruptFriendly option, add this line to the beginning of your
PololuLedStrip::interruptFriendly = true;
Chaining LED Strips together
No special code is required to chain LED strips together. An X-meter LED strip chained to a Y-meter LED strip can be controlled in exactly the same way as a single (X+Y)-meter LED strip.
Files at revision 18:34ba573573df