A few weeks back I had an idea to build an LED meter to display our Splunk license usage at work. Splunk is an application we use to collect and monitor logs all across our systems. I currently have a web dashboard that will tell me what our license usage is. A normal day follows a relatively standard license usage pattern. It generally rises at a certain rate and hits a certain log volume by the end of the day. If the log volume is higher or lower than usual, it is a basic signal that something may be wrong on the network. The problem with the web dashboard is that I have to remember to open that tab and refresh it every so often in order to keep tabs on it. I figured if I could just have an LED bar on the side of my monitor keeping tabs on the license usage for me, my brain would naturally get used to daily patterns and be able to notice subconsciously when something is wrong. Last night was our open house night at Eugene Maker Space and I finally had some time to start working on this project.
The first thing I had to do was figure out how I was going to build this thing. I knew that Adafruit sold some nice RGB LED strips so I figured those would be perfect for the LED bar. They are already in a strip and they are super easy to interface with a microcontroller. For my microcontroller I decided to use an Arduino since they are cheap, simple to use and I am the most familiar with it. However, rather than use a normal Arduino I decided to use one of my Teensy Arduinos that I bought a few months back. The Teensy acts just like a normal Arduino for the most part. It is just way smaller and has a build in USB interface in it’s tiny package. It can also support USB serial communication as well as emulate a keyboard or mouse! For this project, I figure I will end up just using the USB connection for serial communication and perhaps power.
Those are really the only two parts I need for this project. The LED strip should be able to interface directly to the Teensy with no supporting circuitry. My friend @willbradley in Arizona was kind enough to send me an RGB LED strip that is just about the right length for this project. The strip he sent me is the old model of this strip sold by Adafruit. The Adafruit tutorial for using the old version of the strip is located here. I had used the newer version of the strip before and it was dead simple. The older version has an extra pin I had to interface with called the “latch” pin in order to get it working.
I had a heck of a time getting this to work. There were multiple problems. The main problem I had was getting the “advanced” PWM Adafruit libraries to work with this strip on the Teensy. I’m not sure why but I just could not get it to work right. Originally I had the wires soldered to the wrong pins on the Teensy but I finally figured out which pins were needed and I still couldn’t get it to work right. I had to use the build in hardware SPI pins and even though I was, it just didn’t seem to ever work properly. Sometimes the strip would light up but never in a pattern that made sense for the example code.
Here are some shots of the solder connections on the Teensy. You can see that the Data and Clock pins of the RGB strip are soldered to the Teensy’s pins 1 and 2 which should be correct.
After a couple hours of debugging and swapping pins and soldering and desoldering I finally noticed that there was a more basic library I could try. I must have skimmed right past that part in the tutorial. The downside to the basic library is that it doesn’t support PWM control, meaning that you only get about 7 colors to choose from instead of millions. Also, it doesn’t directly support dimming the lights which could be an issue if the USB port doesn’t provide enough current to light up all of the LEDs in full brightness at once. I figured that I would go ahead and try it any way since for this project I really only need Green, Red, Yellow and maybe one other color. All of those colors can be created without PWM. The basic library does not use hardware SPI because it doesn’t need that high speed. Therefore, you can choose any output pins in software to use to control the LED strip. This makes things much easier because I don’t have to desolder and move the wires around if I attach them to the wrong place.
I downloaded and installed the Adafruit Basic library for the LED strip. After restarting the Arduino app I was ready to go. I loaded up the one example program that came with the library and modified the pin settings in the code to the pins that I used. I also changed the number of LEDs in the strip from 32 to 12 since my strip only has 12 LEDs on it. I flashed over the code and lo and behold, it worked! After a few hours I finally had some basic animation patterns working on this thing.
I managed to get it working just before I had decided to leave the shop. Now that I have the basic animations working I need to get some code written and working to control the strip the way I want. I’m hoping to use serial communication to control the strip. I want the Arduino code to just listen for two number values. One value is the total license we are allowed from Splunk. The second value will be our current license usage. Then the Arduino will use those two numbers to figure out how many LEDs to light up and what colors those LEDs should be. I’ll post another update once I have made more progress.