How to use a 2 Digit 7-Segment Display with SevSeg.h Library?

I'm trying a SevSeg code I got from this post which suppose to display a counting number but all I got on the display is steady "88". I'm using Arduino Leonardo and wired the correct pins to each of the pins on the 2-digit 7-segment display.

/* SevSeg Counter Example
 
 Copyright 2017 Dean Reading
 
 Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License.
 You may obtain a copy of the License at
 http://www.apache.org/licenses/LICENSE-2.0
 
 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.
 
 
 This example demonstrates a very simple use of the SevSeg library with a 4
 digit display. It displays a counter that counts up, showing deci-seconds.
 */

#include "SevSeg.h"
SevSeg sevseg; //Instantiate a seven segment controller object

void setup() {
  byte numDigits = 2;
  byte digitPins[] = {};
  byte segmentPins[] = {2, 3, 4, 5, 6, 7, 8};
  bool resistorsOnSegments = false; // 'false' means resistors are on digit pins
  byte hardwareConfig = COMMON_CATHODE; // See README.md for options
  bool updateWithDelays = false; // Default. Recommended
  bool leadingZeros = false; // Use 'true' if you'd like to keep the leading zeros
 
  sevseg.begin(hardwareConfig, numDigits, digitPins, segmentPins, resistorsOnSegments, updateWithDelays, leadingZeros);
  sevseg.setBrightness(90);
}

void loop() {
  static unsigned long timer = millis();
  static int Seconds = 0;
 
  if (millis() - timer >= 1000) {
    timer += 1000;
    Seconds++; // 1000 milliSeconds is equal to 1 Second
   
    if (Seconds == 100) { // Reset to 0 after counting for 100 seconds.
      Seconds=0;
    }
    sevseg.setNumber(Seconds, 1);
  }

  sevseg.refreshDisplay(); // Must run repeatedly
 
}

I can't seem to find any other sample code using a 2-digit 7-segment display. Anyone?

byte digitPins[] = {};

I think you need to specify the digit pins

groundFungus:

byte digitPins[] = {};

I think you need to specify the digit pins

Yeah I tried that already and it just lit up the two dots.

Well, the point is that unless you specify the digit pins, it will absolutely not work, so that is from where you must start. Specify the digit pins, figure out what the two dots mean and progress from there.

2n3904:
I'm using Arduino Leonardo and wired the correct pins to each of the pins on the 2-digit 7-segment display.

Well, that's your claim, but if it's not working, either the wiring or the code or both - are wrong. So I think it is time for a picture of your layout, taken outside in daylight but not full sun so each part can be seen and perhaps pictures of the "88" and dots on the display.

Paul__B:
Well, the point is that unless you specify the digit pins, it will absolutely not work, so that is from where you must start. Specify the digit pins, figure out what the two dots mean and progress from there.
Well, that's your claim, but if it's not working, either the wiring or the code or both - are wrong. So I think it is time for a picture of your layout, taken outside in daylight but not full sun so each part can be seen and perhaps pictures of the "88" and dots on the display.

You're right I misunderstood the digitPins as I don't usually specify anything on it when using a single-digit segment display.

It's working now, thank you! :slight_smile:

The above code sample is misleading (apart from the missing digitPins[] already pointed out in the responses) because it shows only seven segment pins defined, that is the decimal point pin is not defined, but omits the necessary parameter to the begin() method to indicate that the decimal point pin is not in use. This incorrect combination can give unpredictable results. See Unpredictable behavior in a specific case of unused decimal point pins caused by an array out of bounds condition · Issue #109 · DeanIsMe/SevSeg · GitHub.

Check out an example from the library, say SevSeg/examples/testDisplay/testDisplay.ino at master · DeanIsMe/SevSeg · GitHub to see all the parameters in an sample sketch.