int segment[] = {
2, 3, 4, 5, 6, 7, 8
};
int digits[] = {
9, 10, 11, 12
};
byte numbers[] = {
0b1000000,//0
0b1111001,//1
0b0100100,//2
0b0110000,//3
0b0011001,//4
0b0010010,//5
0b0000010,//6
0b1111000,//7
0b0000000,//8
0b0010000,//9
};
void setup() {
// put your setup code here, to run once:
for(int i = 0;i <= 7;i++){
pinMode(segment[i], OUTPUT);
pinMode(digits[i], OUTPUT);
}
}
void loop() {
// put your main code here, to run repeatedly:
for(int i = 0;i <= 9;i++){
display1(i, 0);
delay(400);
}
for(int i = 0;i <= 9;i++){
display(i, 1);
delay(400);
}
for(int i = 0;i <= 9;i++){
display(i, 2);
delay(400);
}
digitalWrite(digits[2], LOW);
for(int i = 0;i <= 9;i++){
display(i, 3);
delay(400);
}
digitalWrite(digits[3], LOW);
delay(1000);
}
void display1(int number, int digit){
digitalWrite(digits[digit], LOW);
for(int i = 0;i <= 7;i++){
digitalWrite(segment[i], ((numbers[number] >> i) & 1));
}
digitalWrite(digits[digit], HIGH);
delay(1);
}
void display(int number, int digit){
digitalWrite(digits[digit], HIGH);
delay(1);
for(int i = 0;i <= 7;i++){
digitalWrite(segment[i], ((numbers[number] >> i) & 1));
}
digitalWrite(digits[digit], LOW);
}