#include <SevSeg.h>
SevSeg S1;
SevSeg S2;
SevSeg S3;
SevSeg S4;
int i = 60;
int j = 20;
int k = 20;
int l = 20;
int D1 = 9;
int D2 = 10;
int count = 0;
int count1 = 0;
int count2 = 0;
int count3 = 0;
boolean a = true;
unsigned long previoustime=0;
unsigned long currenttime;
void setup()
{
byte digitPins_1[] = {9,10};
byte segmentPins_1[] = {2, 3, 4, 5, 6, 7, 8};
S1.begin(COMMON_ANODE, 2, digitPins_1, segmentPins_1);
byte digitPins_2[] = {11,12};
byte segmentPins_2[] = {14,15,16,17,18,19,20};
S2.begin(COMMON_ANODE, 2, digitPins_2, segmentPins_2);
byte digitPins_3[] = {29,30};
byte segmentPins_3[] = {22,23,24,25,26,27,28};
S3.begin(COMMON_ANODE, 2, digitPins_3, segmentPins_3);
byte digitPins_4[] = {38,39};
byte segmentPins_4[] = {31,32,33,34,35,36,37};
S4.begin(COMMON_ANODE, 2, digitPins_4, segmentPins_4);
S1.setBrightness(90);
S2.setBrightness(90);
S3.setBrightness(90);
S4.setBrightness(90);
}
void loop()
{
if (count == 0)
{
i = 60;
j = 40;
k = 20;
l = 20;
count = 1;
}
currenttime=millis();
if(currenttime-previoustime==1000)
{
previoustime = currenttime;
S4.setNumber(l);
S4.refreshDisplay();
S3.setNumber(k);
S3.refreshDisplay();
S2.setNumber(j);
S2.refreshDisplay();
S1.setNumber(i);
S1.refreshDisplay();
i--;
j--;
k--;
l--;
if (l == 0)
{
l = 60;
k = 20;
}
if (k == 0)
{
k = 60;
j = 20;
}
if (j == 0)
{
j = 60;
i = 20;
}
if (i == 0)
{
i = 60;
j = 40;
k = 20;
l = 20;
}
}
S1.refreshDisplay();
S2.refreshDisplay();
S3.refreshDisplay();
S4.refreshDisplay();
// }
// currenttime=millis();
// if(currenttime-previoustime==1000)
// {
// previoustime = currenttime;
// S4.setNumber(l);
// l--;
// }
// S4.refreshDisplay();
// currenttime=millis();
// if(currenttime-previoustime==1000)
// {
// previoustime = currenttime;
// S3.setNumber(k);
// k--;
// }
// S3.refreshDisplay();
// currenttime=millis();
// if(currenttime-previoustime==1000)
// {
// previoustime = currenttime;
// S2.setNumber(j);
// j--;
// }
// S2.refreshDisplay();
// currenttime=millis();
// if(currenttime-previoustime==1000)
// {
// previoustime = currenttime;
// S1.setNumber(i);
// i--;
// }
// S1.refreshDisplay();
}
// void display(int num, int a1, int b1, int c1, int d1, int e1, int f1, int g1, int D1, int D2)
// {
// for(int num = 15; num >= 10; num--)
// {
// digitalWrite(D1, HIGH);
// digitalWrite(D2, LOW);
// digitalWrite(a1, LOW);
// digitalWrite(b1, HIGH);
// digitalWrite(c1, HIGH);
// digitalWrite(d1, LOW);
// digitalWrite(e1, LOW);
// digitalWrite(f1, LOW);
// digitalWrite(g1, LOW);
// }
// for(int num = 9; num >= 0; num--)
// {
// digitalWrite(D1, HIGH);
// digitalWrite(D2, LOW);
// digitalWrite(a1, HIGH);
// digitalWrite(b1, HIGH);
// digitalWrite(c1, HIGH);
// digitalWrite(d1, HIGH);
// digitalWrite(e1, HIGH);
// digitalWrite(f1, HIGH);
// digitalWrite(g1, LOW);
// }
// }