The Adafruit Bi-Color 24-Bar Bargraph with I2C Backpack is a versatile and visually appealing LED display module. It features 24 individual segments, each capable of displaying red or green light, or a combination of both to create a yellow color. This component is ideal for creating visual indicators and bar graphs for a variety of applications, including audio level meters, battery monitors, and other multi-channel monitoring systems.
Pin | Description |
---|---|
VCC | Power supply (4.5V to 5.5V) |
GND | Ground connection |
SDA | I2C data line |
SCL | I2C clock line |
A0 | Address select bit 0 (solder jumper) |
A1 | Address select bit 1 (solder jumper) |
A2 | Address select bit 2 (solder jumper) |
#include <Wire.h>
#include <Adafruit_LEDBackpack.h>
#include <Adafruit_GFX.h>
Adafruit_BicolorMatrix matrix = Adafruit_BicolorMatrix();
void setup() {
matrix.begin(0x70); // Initialize the bargraph display with its I2C address
}
void loop() {
// Display a simple level meter that increases and decreases
for (uint8_t i = 0; i < 24; i++) {
matrix.setBar(i, LED_GREEN); // Set the bar to green
matrix.writeDisplay(); // Update the display
delay(100);
}
for (int8_t i = 23; i >= 0; i--) {
matrix.setBar(i, LED_RED); // Set the bar to red
matrix.writeDisplay(); // Update the display
delay(100);
}
}
setBar
function is called with the correct color constants.Q: Can I chain multiple bargraphs together? A: Yes, you can daisy-chain multiple bargraphs by connecting the SDA and SCL lines in parallel and setting unique I2C addresses for each bargraph.
Q: What is the maximum number of bargraphs I can control with one I2C bus? A: You can control up to 8 bargraphs on a single I2C bus by using different addresses ranging from 0x70 to 0x77.
Q: Can I display colors other than red, green, and yellow? A: The bargraph is limited to red and green LEDs, which can be combined to create yellow. Other colors are not possible with this hardware.
Q: How do I install the Adafruit LED Backpack library? A: You can install the library through the Arduino Library Manager by searching for "Adafruit LED Backpack" and installing the latest version.