int digs[] = {9, 10, 11, 12};
int segs[] = {2, 3, 4, 5, 6, 7, 8};
byte nums[] = {
B1000000,
B1111001,
B0100100,
B0110000,
B0011001,
B0010010,
B0000010,
B1111000,
B0000000,
B0010000
};
void setup() {
// put your setup code here, to run once:
for (int i : segs)
{
pinMode(i, OUTPUT);
}
for (int i : digs)
{
pinMode(i, OUTPUT);
}
digitalWrite(digs[0], 1);
}
void loop() {
// put your main code here, to run repeatedly:
for (int i = 0; i <= 9; i++)
{
showNum(i);
}
}
void showNum(int num)
{
int readBit;
switch (num)
{
case 0:
for (int i = 0; i < 10; i++)
{
readBit = bitRead(nums[0], i);
digitalWrite(segs[i], readBit);
}
break;
case 1:
for (int i = 0; i < 10; i++)
{
readBit = bitRead(nums[1], i);
digitalWrite(segs[i], readBit);
}
break;
case 2:
for (int i = 0; i < 10; i++)
{
readBit = bitRead(nums[2], i);
digitalWrite(segs[i], readBit);
}
break;
case 3:
for (int i = 0; i < 10; i++)
{
readBit = bitRead(nums[3], i);
digitalWrite(segs[i], readBit);
}
break;
case 4:
for (int i = 0; i < 10; i++)
{
readBit = bitRead(nums[4], i);
digitalWrite(segs[i], readBit);
}
break;
case 5:
for (int i = 0; i < 10; i++)
{
readBit = bitRead(nums[5], i);
digitalWrite(segs[i], readBit);
}
break;
case 6:
for (int i = 0; i < 10; i++)
{
readBit = bitRead(nums[6], i);
digitalWrite(segs[i], readBit);
}
break;
case 7:
for (int i = 0; i < 10; i++)
{
readBit = bitRead(nums[7], i);
digitalWrite(segs[i], readBit);
}
break;
case 8:
for (int i = 0; i < 10; i++)
{
readBit = bitRead(nums[8], i);
digitalWrite(segs[i], readBit);
}
break;
case 9:
for (int i = 0; i < 10; i++)
{
readBit = bitRead(nums[9], i);
digitalWrite(segs[i], readBit);
}
break;
}
}