To talk to the LED helper chip you'll need to use our Arduino Adafruit LED Backpack library from github.
To download you can visit the repository, or simply click on this button:
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 it's your first library. We also have a great tutorial on Arduino library installation at:
http://learn.adafruit.com/adafruit-all-about-arduino-libraries-install-use
Install Adafruit GFX
You will need to do the same for the Adafruit_GFX library available here
Rename the uncompressed folder Adafruit_GFX and check that the Adafruit_GFX folder contains Adafruit_GFX.cpp and Adafruit_GFX.h
Place the Adafruit_GFX library folder your arduinosketchfolder/libraries/ folder like you did with the LED Backpack library
If using an older version of the Arduino IDE (pre-1.8.10), also locate and install the Adafruit_BusIO library (newer versions do this automatically when using the Arduino Library Manager).
Adafruit_GFX isn’t actually used for the segmented display, it's only for the matrix backpacks but it's still required by the library so please install it to avoid errors! Restart the IDE.
Run Test!
Once you've restarted you should be able to select the File->Examples->Adafruit_LEDBackpack->quadalphanum example sketch. Upload it to your Feather as usual. You should see a basic test program that goes through a bunch of different routines.
Upload to your Arduino, and open up the Serial console at 9600 baud speed. You'll see each digit light up all the segments, then the display will scroll through the 'font table' showing every character that it knows how to display. Finally, you'll get a notice to start typing into the serial console. Type a message and hit return, you'll see it scroll onto the display!
Library Reference
For the quad displays, we have a special object that can handle ascii data for easy printing.
You can create the object with
Adafruit_AlphaNum4 alpha4 = Adafruit_AlphaNum4();
There's no arguments or pins because the backpacks use the fixed I2C pins.
By default, the address is 0x70, but you can pass in the I2C address used when you initialize the display with begin
alpha4.begin(0x70); // pass in the address
Next up, the segments can be turned on/off for each digit by writing the 'raw' bitmap you want, for example, all the LEDs off on digit #3 is
alpha4.writeDigitRaw(3, 0x0);
All the segments on for digit #0, but not the decimal point, can be done by:
alpha4.writeDigitRaw(0, 0x3FFF);
This is the segment map:
The 16 bit digit you pass in for raw image has this mapping:
Name: -- DP N M L K J H G2 G1 F E D C B A Bit: 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
The left-most bit isn't used and is ignored. Named constants are also available for each segment:
#define ALPHANUM_SEG_A 0b0000000000000001 ///< Alphanumeric segment A #define ALPHANUM_SEG_B 0b0000000000000010 ///< Alphanumeric segment B #define ALPHANUM_SEG_C 0b0000000000000100 ///< Alphanumeric segment C #define ALPHANUM_SEG_D 0b0000000000001000 ///< Alphanumeric segment D #define ALPHANUM_SEG_E 0b0000000000010000 ///< Alphanumeric segment E #define ALPHANUM_SEG_F 0b0000000000100000 ///< Alphanumeric segment F #define ALPHANUM_SEG_G1 0b0000000001000000 ///< Alphanumeric segment G1 #define ALPHANUM_SEG_G2 0b0000000010000000 ///< Alphanumeric segment G2 #define ALPHANUM_SEG_H 0b0000000100000000 ///< Alphanumeric segment H #define ALPHANUM_SEG_J 0b0000001000000000 ///< Alphanumeric segment J #define ALPHANUM_SEG_K 0b0000010000000000 ///< Alphanumeric segment K #define ALPHANUM_SEG_L 0b0000100000000000 ///< Alphanumeric segment L #define ALPHANUM_SEG_M 0b0001000000000000 ///< Alphanumeric segment M #define ALPHANUM_SEG_N 0b0010000000000000 ///< Alphanumeric segment N #define ALPHANUM_SEG_DP 0b0100000000000000 ///< Alphanumeric segment DP
To turn on just the A segment, use ALPHANUM_SEG_A
or 0x0001
.
To turn on just the G1 segment, use ALPHANUM_SEG_G1
or 0x0040
.
To turn on multiple segments at once, you can combine them with the bitwise OR operator, |
. For instance, to turn on the top and bottom segments, do:
alpha4.writeDigitRaw(0, ALPHANUM_SEG_A | ALPHANUM_SEG_D);
ASCII data
If you're just looking to print 'text' you can use our font table, just pass in an ASCII character!
For example, to set digit #0 to A call:
alpha4.writeDigitAscii(0, 'A')
alpha4.writeDisplay();
That's what actually 'sets' the data onto the LEDs!
Page last edited March 08, 2024
Text editor powered by tinymce.