#include <SevSeg.h>
SevSeg sevseg; //Instantiate a seven segment controller object
void setup()
{
byte numDigits = 4;
byte digitPins[] = {27, 23, 16, 17}; //Digits: 1,2,3,4 <--put one resistor (ex: 220 Ohms, or 330 Ohms, etc, on each digit pin)
byte segmentPins[] = {15, 4, 14, 33, 13, 2, 3, 32}; //Segments: A,B,C,D,E,F,G,Period
sevseg.begin(COMMON_ANODE, numDigits, digitPins, segmentPins);
sevseg.setBrightness(10); //Note: 100 brightness simply corresponds to a delay of 2000us after lighting each segment. A brightness of 0
//is a delay of 1us; it doesn't really affect brightness as much as it affects update rate (frequency).
//Therefore, for a 4-digit 7-segment + pd, COMMON_ANODE display, the max update rate for a "brightness" of 100 is 1/(2000us*8) = 62.5Hz.
//I am choosing a "brightness" of 10 because it increases the max update rate to approx. 1/(200us*8) = 625Hz.
//This is preferable, as it decreases aliasing when recording the display with a video camera....I think.
}
void loop()
{
//local vars
static byte decPlace = 0;
sevseg.setNumber(6599,decPlace);
decPlace++;
decPlace %= 4; //rollover back to 0 once variable gets to 4; To anyone wondering: the % is called the "modulo" operator; see here for explanation & example: https://www.arduino.cc/en/Reference/Modulo
sevseg.refreshDisplay(); // Must run repeatedly; don't use blocking code (ex: delay()) in the loop() function or this won't work right
}