#include "SevSeg.h"
// Create object
SevSeg sevseg;
// Number of digits in display
byte numDigits = 4;
// Display select pins
byte digitPins[] = {13, 10, 12, 11};
// Display segment pins A,B,C,D,E,F,G,DP
byte segmentPins[] = {9, 2, 3, 5, 6, 8, 7, 4};
// Dropping resistors used
bool resistorsOnSegments = true;
// Display type
byte hardwareConfig = COMMON_CATHODE;
void setup() {
// Start display object
sevseg.begin(hardwareConfig, numDigits, digitPins, segmentPins, resistorsOnSegments);
// Set brightness
sevseg.setBrightness(90);
}
void loop() {
// Test each segment in sequence
for (byte segment = 0; segment < 8; segment++) {
for (byte digit = 0; digit < numDigits; digit++) {
testSegment(segment, digit);
delay(1000);
}
}
}
// Helper function to display a single segment on a single digit
void testSegment(byte segment, byte digit) {
byte segments[numDigits] = {0}; // Array to hold segment states for all digits
segments[digit] = 1 << segment; // Turn on the specific segment for the specific digit
sevseg.setSegments(segments); // Update the segment on the specific digit
sevseg.refreshDisplay();
}