Changing I2C Address

Author Gravatar Image LADY ADA
The HT16K33 driver chip on these LED backpacks has a default I2C address of 0x70. Since each device on an I2C bus must have a unique address, its important to avoid collisions or you'll get a lot of strange responses from your electronic devices!

Luckily, the HT16K33 has 2 or 3 address adjust pins, so that the address can be changed! The mini 0.8" 8x8 matrix backpack has 2 address adjust pins. The 1.2" 8x8, bi-color 8x8, bi-color bargraph and 4 x 7-segment backpacks have 3 address adjust pins.

That means that you can set the backpacks to these addresses:

  • Mini 0.8" 8x8: 0x70, 0x71, 0x72, 0x73
  • Small 1.2" 8x8: 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77
  • 4 x 7-segment: 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77
  • Bi-color 1.2" 8x8: 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77
  • Bi-color 24-bargraph: 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77
You can mix-and-match matrices, as long as each one has a unique address!

Changing Addresses

You can change the address of a backpack very easily. Look on the back to find the two or three A0, A1 or A2 solder jumpers. Each one of these is used to hardcode in the address. If a jumper is shorted with solder, that sets the address. A0 sets the lowest bit with a value of 1, A1 sets the middle bit with a value of 2 and A2 sets the high bit with a value of 4. The final address is 0x70 + A2 + A1 + A0. So for example if A2 is shorted and A0 is shorted, the address is 0x70 + 4 + 1 = 0x75. If only A1 is shorted, the address is 0x70 + 2 = 0x72

A2 does not appear on the mini 0.8" 8x8 matrix, so you cannot set the address higher than 0x73

On the 1.2" 8x8 backpacks, the labels for A1 and A2 are swapped! Sorry about that!

Changing the address in your code


Once you've adjusted the address on the backpack, you'll also want to adjust the address in the code!
For the Arduino library we wrote, its simple. For example, lets say you want to have two seven-segment matrices. One is set to address 0x70 and the other is set to 0x71. Find this code in the example
Copy Code
Adafruit_7segment matrix = Adafruit_7segment();

void setup() {
  Serial.begin(9600);
  Serial.println("7 Segment Backpack Test");

  matrix.begin(0x70);
}
And change it to this:
Copy Code
Adafruit_7segment matrix1 = Adafruit_7segment();
Adafruit_7segment matrix2 = Adafruit_7segment();

void setup() {
  Serial.begin(9600);
  Serial.println("Double 7 Segment Backpack Test");

  matrix1.begin(0x70);
  matrix2.begin(0x71);
}

That is, instantiate two matrix objects. Then one is called with begin(0x70) and the other is called with begin(0x71). Each one can be used individually. If you need more matrices, just instantiate more objects at the top and begin() each one with the unique i2c address.
Last updated on 2014-04-18 at 09.50.40 PM Published on 2012-07-29 at 03.58.38 PM