SBK\_BarDrive Library
High-level Arduino library for controlling animated LED bar meters using MAX7219/MAX7221 or HT16K33 drivers. Ideal for prop-making, visual meters, and signal-driven lighting effects.
π What's New in v2.0.4
Version 2.0.4 introduces major architectural and feature improvements. Previous versions (1.x) are deprecated due to internal changes in how offset positioning and multi-device spanning are handled. π§ Core Enhancements
* Block-based animations β upwardUnstackingBlocks() and downwardUnstackingBlocks()
* Signal-driven modes β followSignalFloatingPeak()
* Offset support β bar meters can now start from arbitrary row/column or segment positions
* Multi-device mapping β segments can span across multiple driver devices (via auto-mapping, matrix presets or custom mappings)
* Full custom segment mapping β define precise {device, row, col} mappings for advanced layouts
β οΈ Deprecation Notice
Previous versions (1.x) are no longer compatible due to architectural changes. Please migrate existing projects by updating segment mappings and constructor parameters to match the v2.0+ format.
β¨ Features
- Unified API for both SPI (MAX72xx) and I2C (HT16K33) LED drivers
- Built-in bar meter animations (e.g., filling, bouncing, signal-following, block effects)
- Support for custom [row, col] segment mappings or preset types
- Compile-time options to optimize for memory:
- SBK_BARDRIVE_WITH_ANIM to include animations
- SBK_TRACK_PIXEL_STATE to enable pixel state caching
- Designed for SBK BarMeter and SBK BarDrive PCBs
- Reverse display modes and flexible mapping
- Internal buffer with batch .show() updates
- Software SPI (MAX72xx) β works on any 3 digital pins: DATA, CLK, and CS
- I2C (HT16K33) β uses SDA and SCL pins (standard I2C bus)
βοΈ Supported Hardware Combinations
This library is compatible with any LED matrix or bar display using MAX7219, MAX7221, or HT16K33 drivers β as long as a valid [row, col], aka [anode,cathode], segment mapping is provided or configured using a built-in preset.
When using custom segment mappings with SBK_BarDrive, each segment is defined as a {row, col} pair β representing the physical LED connection: {row, col} = {anode, cathode}
This matches the wiring convention of common LED driver ICs:
| Driver | Row (Anode / V+) | Column (Cathode / GND) |
| MAX72xx | SEGx (source, V+) | DIGx (sink, GND) |
| HT16K33 | Rx (source, V+) | Cx (sink, GND) |
This library is designed to work with the following hardware combinations:
- π’ SBK BarDrive *SK*28 PCB + SBK BarMeter 28 PCB + BL28-3005SKxx type (28seg com. cathode Bar Meter)
- π΅ SBK BarDrive *SA*28 PCB + SBK BarMeter 28 PCB + BL28-3005SAxx type (28seg com. anode Bar Meter)
- π£ SBK BarDrive 64 PCB + SBK BarMeter 24 PCB + 3x B8x type (8seg com. cathode Bar Meter)
- π SBK BarDrive 64 PCB + SBK BarMeter 40 PCB + 5x B8x type (8seg com. cathode Bar Meter)
For more information, schematics, and PCB files, visit: https://github.com/sbarabe/SBK_PCBs
π¦ Dependencies
The SBK_BarDrive library depends on one of the following display driver libraries to function:
| Dependency | Description | Required For |
| SBK_MAX72xx | Software SPI driver for MAX7219/MAX7221 LED drivers | MAX72xx-based displays |
| SBK_HT16K33 | IΒ²C driver for HT16K33 LED driver (8x16 matrices or bar displays) | HT16K33-based displays |
You must install at least one of these drivers depending on your hardware.
If using PlatformIO or Arduino Library Manager, these will be installed automatically as dependencies.
To manually install:
# For MAX72xx (SPI)
git clone https://github.com/sbarabe/SBK_MAX72xx.git
# For HT16K33 (I2C)
git clone https://github.com/sbarabe/SBK_HT16K33.git
Then place them in your Arduino libraries folder.
β¬οΈ Installation
Download or clone the library into your Arduino libraries folder:
git clone https://github.com/sbarabe/SBK_BarDrive.git
In your Arduino sketch, enable features as needed:
#define SBK_BARDRIVE_WITH_ANIM
#define SBK_TRACK_PIXEL_STATE
High-level controller for animated bar meters and LED displays compatible with external SBK_MAX72xx o...
π Quick Start Examples
Using MAX7219:
#define SBK_BARDRIVE_WITH_ANIM
#include <SBK_MAX72xx.h>
SBK_MAX72xx max72xx(DATA_PIN, CLK_PIN, CS_PIN, 1);
void setup() {
max72xx.begin();
bar.animations().animInit().fillUpIntv(50).loop();
}
void loop() {
bar.animations().update();
bar.show();
}
Unified interface combining SBK_BarMeter logic with optional built-in animation support.
Definition SBK_BarDrive.h:591
Using HT16K33:
#define SBK_BARDRIVE_WITH_ANIM
#include <SBK_HT16K33.h>
SBK_HT16K33 ht(1);
void setup() {
ht.setAddress(0,0x70);
ht..setDriverRows(0,8);
ht.begin();
bar.animations().animInit().scrollingUpBlocks(60, 2, 1).loop();
}
void loop() {
bar.animations().update();
bar.show();
}
Using a custom mapping :
If you want full control over how segments map to physical LED positions, you can supply a custom [device, row, col] mapping array. This is ideal for irregular layouts or displays spanning multiple devices.
#define SBK_BARDRIVE_WITH_ANIM
const uint8_t mapping[5][3] = {
{0, 0, 0},
{0, 0, 1},
{0, 0, 2},
{1, 0, 0},
{1, 0, 1}
};
#include <SBK_MAX72xx.h>
SBK_MAX72xx max72xx(DATA_PIN, CLK_PIN, CS_PIN, 2);
void setup() {
max72xx.begin();
bar.animations().animInit().fillUpIntv(60).loop();
}
void loop() {
bar.animations().update();
bar.show();
}
ποΈ Built-In Animations
These functions start animations and can be chained with modifiers like .loop() or .pause().
Fill / Empty
fillUpIntv();
fillDownIntv();
fillUpDur();
fillDownDur();
emptyUpIntv();
emptyDownIntv();
emptyUpDur();
emptyDownDur();
Bounce Effects
bounceFillUpIntv();
bounceFillDownIntv();
bounceFillUpDur();
bounceFillDownDur();
bounceFillFromCenterIntv();
bounceFillFromCenterDur();
bounceFillFromEdgesIntv();
bounceFillFromEdgesDur();
Block-Based Animations
scrollingUpBlocks();
scrollingDownBlocks();
collidingBlocks();
explodingBlocks();
upwardStackingBlocks();
downwardStackingBlocks();
upwardUnstackingBlocks();
downwardUnstackingBlocks();
upwardUnstackingBlocks();
downwardUnstackingBlocks();
Signal-Driven
followSignalSmooth();
followSignalWithPointer();
followDualSignalFromCenter();
followDualSignalFromEdges();
followSignalFloatingPeak();
Random & Beat
randomFill();
randomEmpty();
beatPulse();
Static Setters
setAllOn();
setAllOff();
setAll(bool);
π§° Animation Helpers (Chainable)
These methods allow you to control, manipulate, or conditionally alter animations at runtime. Most are event-driven triggersβideal for reacting to user input, state transitions, or timed events.
You can chain these calls because they return a reference to the active animation controller:
bar.animations().pause();
bar.animations().resume();
bar.animations().stop();
bar.animations().loop();
bar.animations().noLoop();
bar.animations().toggleLogic();
bar.animations().invertLogic();
bar.animations().resetLogic();
bar.animations().stopBlockEmission();
bar.animations().resumeBlockEmission();
```cpp
bar.animations().pause();
bar.animations().resume();
bar.animations().stop();
bar.animations().loop();
bar.animations().noLoop();
bar.animations().toggleLogic();
bar.animations().invertLogic();
bar.animations().resetLogic();
All helper functions return a reference to the SBK_BarMeterAnimations object, allowing chainable expressions like:
bar.animations().pause().setLogic(true).resume().stopBlockEmission();
```cpp
bar.animations()
.pause()
.setLogic(true)
.resume()
.stopBlockEmission();
π API Overview
| Class | Purpose |
| SBK_BarMeter | Handles segment mapping and direction logic |
| SBK_BarDrive | Wrapper that adds animation support |
| SBK_BarMeterAnimations | Provides animation control interface |
| SBK_MAX72xx | Software SPI driver for MAX7219/MAX7221 |
| SBK_HT16K33 | I2C driver for HT16K33 8x16 LED matrices |
πͺͺ License
Code
Licensed under the MIT License.
Documentation
Licensed under Creative Commons Attribution 4.0 (CC BY 4.0).
You are free to share and adapt the material, provided you give appropriate credit.
π§ Credits
Library by Samuel BarabΓ© (Smart Builds & Kits).
π οΈ Support
βοΈ Feel free to customize any URLs or email addresses before publishing!