#define dig1 2
#define dig2 15
int vl1,vl2;
int cont=0;
int tempo= 1;
//indices: 0 1 2 3 4 5 6
// a b c d e f g
int seg[7]={23,22,21,19,18,5,4};
// a b c d e f g
int tabinseg[16][7]={1,1,1,1,1,1,0, //0
0,1,1,0,0,0,0, //1
1,1,0,1,1,0,1, //2
1,1,1,1,0,0,1, //3
0,1,1,0,0,1,1, //4
1,0,1,1,0,1,1, //5
1,0,1,1,1,1,1, //6
1,1,1,0,0,0,0, //7
1,1,1,1,1,1,1, //8
1,1,1,1,0,1,1, //9
1,1,1,0,1,1,1, //A
0,0,1,1,1,1,1, //B
1,0,0,1,1,1,0, //C
0,1,1,1,1,0,1, //D
1,0,0,1,1,1,1, //E
1,0,0,0,1,1,1};//F
void setup() {//configuração
pinMode(dig1, OUTPUT);
pinMode(dig2, OUTPUT);
for(int i=0;i<7;i++){
pinMode(seg[i], OUTPUT);
}
vl1=9;
vl2=9;
}
void loop() {//inicio da função loop
cont++;
if(cont>785){
cont=0;
vl2--;
if(vl2<0){
vl1--;
vl2=9;
if(vl1<0)
vl1=9;
}
}
EscreveNoDisplay(1,vl1);
delay(tempo);
EscreveNoDisplay(2,vl2);
delay(tempo);
}
void EscreveNoDisplay(int d, int v){
digitalWrite(dig1, HIGH);
digitalWrite(dig2, HIGH);
for(int j=0;j<7;j++){
digitalWrite(seg[j], tabinseg[v][j]);
}
if(d==1){
digitalWrite(dig1, LOW);
digitalWrite(dig2, HIGH);
}
else if(d==2){
digitalWrite(dig1, HIGH);
digitalWrite(dig2, LOW);
}
}