unsigned long changeTime;
int timeDelay = 200;
int ones, tens = 0;
void setup()
{
for (int i = 0; i <= 13; i++)
pinMode(i, OUTPUT); //all pins Output
display_ones(0);
display_tens(0);
delay(300);
}
//array of digits from 0 to 9
const int number[11] = {0b0111111, 0b0000110, 0b1011011, 0b1001111, 0b1100110, 0b1101101, 0b1111101, 0b0000111, 0b1111111, 0b1101111};
void loop(){
if ((millis() - changeTime) > timeDelay) {
ones ++;
if ( ones > 9){
ones = 0;
tens ++;
if (tens > 9) tens = 0;
}
display_ones(ones);
display_tens(tens);
changeTime = millis();
}
}
void display_tens(const int tens){
int pin1, a; //
for (pin1 = 0, a = 0; pin1 < 7; pin1++, a++) {
digitalWrite(pin1, bitRead(number[tens], a));
}
}
void display_ones(const int ones){
int pin2, b;
for (pin2 = 7, b = 0; pin2 <= 13; pin2++, b++) {
digitalWrite(pin2, bitRead(number[ones], b));
}
}