SevSeg Display with Backpack Error

Hello, I just purchased an Adafruit 0.56" 4-Digit 7-Segment Display w/I2C Backpack and I'm having trouble getting it working. The directions say if using the STEMMA QT version (which I am), to replace the example code matrix.begin(0x70); with matrix.begin(0x70, &Wire1);
The example code will compile just fine, but then not display anything on the display. When I do the above mentioned replacement (see below), it won't compile. I get "Compilation error: 'Wire1' was not declared in this scope."

I'm using Arduino IDE 2.3.4 and an Arduino Uno. Thanks for any help.

#include <Wire.h> 
#include <Adafruit_GFX.h>
#include "Adafruit_LEDBackpack.h"

Adafruit_7segment matrix = Adafruit_7segment();

void setup() {
  Serial.begin(9600);
  Serial.println("7 Segment Backpack Test");
  matrix.begin(0x70, &Wire1);
}

void loop() {
  // print a hex number
  matrix.print(0xBEEF, HEX);
  matrix.writeDisplay();
  delay(500);
}

Hi @fishysam.

I think those directions are misleading. On boards that have a "STEMMA QT"/"Qwiic" connector, that connector is generally connected to the microcontroller's second I2C bus. Since this secondary bus is referenced in the code using the Wire1 object, you must configure the library to use that object, as described in the directions. However, if you are connecting the backpack to a board like the UNO R3 that only has a single I2C bus then those directions are not appropriate, and you should instead use the default library configuration, which uses the primary I2C bus.

So change this line of your sketch:

back to this

matrix.begin(0x70);

then upload the sketch to the UNO R3 board again. Hopefully this time it will compile without any errors and work as expected.

2 Likes

Thanks for the reply. I did put the code back to the original example and as I was typing out my response here, removed some unnecessary wires from the Arduino and then the display came on. There must have been some kind of short somewhere. So it's working now!

You are welcome. I'm glad it is working now.

Regards, Per

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.