This backpack solves the annoyance of using lots of pins or a bunch of chips by having an I2C constant-current matrix controller sit neatly on the back of the PCB. The controller chip takes care of everything, drawing all 48 LEDs in the background. All you have to do is write data to it using the 2-pin I2C interface. There are three address select pins so you can select one of 8 addresses to control up to 8 of these on a single 2-pin I2C bus (as well as whatever other I2C chips or sensors you like). The driver chip can 'dim' the entire display from 1/16 brightness up to full brightness in 1/16th steps. It cannot dim individual LEDs, only the entire display at once.
The bargraph must be soldered on the correct orientation or it will not work! Check for the side of the bargraph that has printing on it. Then look for the outline on the PCB that has "Text on this side" marked!
Do not solder the matrix onto the back of the PCB, it won't work either!
This is an optional step - you only need to do this step if you're planning on using the bargraph in a breadboard. Chances are you may want to solder wires directly to the pads instead, so you can mount the bargraph elsewhere. Anyhow, skip this step if its not for you!
Break off a piece of male header, 4 pins long. Plug the long ends into a solderless breadboard.
Place the PCB on top. you may need to support it a little since its quite long.
Solder these 4 pins too, since you're good at it now this should be easy.
Wiring to the bargraph is really easy
- Connect SCL to the I2C clock - on Arduino UNO thats Analog #5, on the Leonardo its Digital #3, on the Mega its digital #21
- Connect SDA to the I2C data - on Arduino UNO thats Analog #4, on the Leonardo its Digital #2, on the Mega its digital #20
- Connect GND to common ground
- Connect VCC to power - 5V is best but 3V also seems to work for 3V microcontrollers.
Next, download the Adafruit LED Backpack library from github . To download click the DOWNLOADS button in the top right corner, rename the uncompressed folder Adafruit_LEDBackpack. Check that the Adafruit_LEDBackpack folder contains Adafruit_LEDBackpack.cpp and Adafruit_LEDBackpack.h Place the Adafruit_LEDBackpack library folder your arduinosketchfolder/libraries/ folder. You may need to create the libraries subfolder if its your first library. You'll also need to download the Adafruit GFX library that provides the graphics drawing routines. Restart the IDE.
Once you've restarted you should be able to select the File->Examples->Adafruit_LEDBackpack->bargraph24 example
sketch. Upload it to your Arduino as usual. You should see a basic test
program that tests all the LEDs with different colors
Adafruit_24bargraph bar = Adafruit_24bargraph();you can name it whatever you want, not just bar
Then initialize it with
bar.begin(0x70); // pass in the addressYou can init with any address from 0x70 to 0x77, just make sure you solder in the matching solder jumpers!
Finally, write to the bargraph with
bar.setBar(lednumber, ledcolor);Where lednumber is 0 thru 23. ledcolor can be LED_RED, LED_YELLOW, LED_GREEN or LED_OFF
The drawing routines only change the display memory kept by the Arduino. Don't forget to call bar.writeDisplay() after drawing to 'save' the memory out to the matrix via I2C.
There are also a few small routines that are special to the matrix:
- setBrightness(brightness)- will let you change the overall brightness of the entire display. 0 is least bright, 15 is brightest and is what is initialized by the display when you start
- blinkRate(rate) - You can blink the entire display. 0 is no blinking. 1, 2 or 3 is for display blinking.