#include "SevSeg.h"
SevSeg sevseg;
float displayTimeSecs = 1; //how long do you want each number on display to show (in secs)
float displayTime = (displayTimeSecs * 5000);
long startNumber = 10; //countdown starts with this number
long startNumber2 = 5;
long endNumber = 0; //countdown ends with this number
const uint8_t A[]= {A0,A1,A2,A3,A4,A5};
int i = 0;
void setup() {
for(i = 0; i <sizeof(A);i++){
pinMode(A[i],OUTPUT);
}
byte numDigits = 2;
byte digitPins[] = { 7, 8};
byte segmentPins[] = {0, 1, 2, 3, 4, 5, 6};
bool resistorsOnSegments = false;
byte hardwareConfig = COMMON_ANODE;
bool updateWithDelays = false;
bool leadingZeros = false;
bool disableDecPoint = true;
sevseg.begin(hardwareConfig, numDigits, digitPins, segmentPins, resistorsOnSegments,
updateWithDelays, leadingZeros, disableDecPoint);
sevseg.setBrightness(90);
}
void CD() {
if (startNumber > endNumber) {
for (long i = 0; i <= displayTime; i++){
sevseg.setNumber(startNumber,0);
sevseg.refreshDisplay();
}
startNumber--;
}
if (startNumber == 0){
startNumber = 10;
}
}
void CD2() {
if (startNumber2 > endNumber) {
for (long i = 0; i <= displayTime; i++){
sevseg.setNumber(startNumber2,0);
sevseg.refreshDisplay();
}
startNumber2--;
}
if (startNumber2 == 0){
startNumber2 = 5;
}
}
void loop() {
//Line 1
CD();
digitalWrite(A0, HIGH);//G1 & R2
digitalWrite(A4, LOW);
digitalWrite(A1, LOW);
digitalWrite(A5, HIGH);
digitalWrite(A2, LOW);
digitalWrite(A3, LOW);
CD();
CD();
CD();
CD();
digitalWrite(A0, LOW); //G1 blink
digitalWrite(A3, LOW);
digitalWrite(A4, LOW);
digitalWrite(A5, HIGH);
delay(300);
digitalWrite(A0, HIGH);
digitalWrite(A3, LOW);
digitalWrite(A4, LOW);
digitalWrite(A5, HIGH);
CD();
digitalWrite(A0, LOW);
digitalWrite(A3, LOW);
digitalWrite(A4, LOW);
digitalWrite(A5, HIGH);
delay(300);
digitalWrite(A0, HIGH);
digitalWrite(A3, LOW);
digitalWrite(A4, LOW);
digitalWrite(A5, HIGH);
CD();
digitalWrite(A0, LOW);
digitalWrite(A3, LOW);
digitalWrite(A4, LOW);
digitalWrite(A5, HIGH);
delay(300);
digitalWrite(A0, HIGH);
digitalWrite(A3, LOW);
digitalWrite(A4, LOW);
digitalWrite(A5, HIGH);
CD();
digitalWrite(A0, LOW);
digitalWrite(A3, LOW);
digitalWrite(A4, LOW);
digitalWrite(A5, HIGH);
delay(300);
digitalWrite(A0, HIGH);
digitalWrite(A3, LOW);
digitalWrite(A4, LOW);
digitalWrite(A5, HIGH);
CD();
digitalWrite(A0, LOW);
digitalWrite(A3, LOW);
digitalWrite(A4, LOW);
digitalWrite(A5, HIGH);
delay(300);
digitalWrite(A0, HIGH);
digitalWrite(A3, LOW);
digitalWrite(A4, LOW);
digitalWrite(A5, HIGH);
CD();
digitalWrite(A0, LOW);//R2 & Y1
digitalWrite(A3, LOW);
digitalWrite(A4, LOW);
digitalWrite(A5, HIGH);
digitalWrite(A0, LOW);
digitalWrite(A1, HIGH);
digitalWrite(A2, LOW);
digitalWrite(A3, LOW);
digitalWrite(A4, LOW);
digitalWrite(A5, HIGH);
CD2();
CD2();
CD2();
CD2();
CD2();
//Line 2
digitalWrite(A2, HIGH);//Y2 & Gr2
digitalWrite(A3, HIGH);
digitalWrite(A0, LOW);
digitalWrite(A1, LOW);
digitalWrite(A5, LOW);
digitalWrite(A4, LOW);
CD();
CD();
CD();
CD();
CD();
digitalWrite(A3, HIGH);//G2 blink
delay(300);
digitalWrite(A3, LOW);
CD();
digitalWrite(A3, HIGH);
delay(300);
digitalWrite(A3, LOW);
CD();
digitalWrite(A3, HIGH);
delay(300);
digitalWrite(A3, LOW);
CD();
digitalWrite(A3, HIGH);
delay(300);
digitalWrite(A3, LOW);
CD();
digitalWrite(A3, HIGH);
delay(300);
digitalWrite(A3, LOW);
CD();
digitalWrite(A5, LOW);//Y2
digitalWrite(A3, LOW);
digitalWrite(A4, HIGH);
CD2();
CD2();
CD2();
CD2();
CD2();
}