Skip to content

Instantly share code, notes, and snippets.

@cbscribe
Last active April 8, 2021 16:18
Show Gist options
  • Save cbscribe/60fc5fdd85eb8736082c47fc394c898b to your computer and use it in GitHub Desktop.
Save cbscribe/60fc5fdd85eb8736082c47fc394c898b to your computer and use it in GitHub Desktop.
int A = 7;
int B = 8;
int C = 9;
int D = 10;
int E = 11;
int F = 12;
int G = 13;
byte digits[] = {126, 48, 109, 121, 51,
91, 95, 112, 127, 123};
void setup()
{
for (int i=A; i<=G; i++)
{
pinMode(i, OUTPUT);
}
}
void loop()
{
// countdown
for (int i=9; i>=0; i--)
{
displayDigit(i);
delay(1000);
}
}
void displayDigit(int d)
{
int mask = 64;
for (int segment = A; segment <= G; segment++)
{
digitalWrite(segment, digits[d] & mask);
mask = mask >> 1;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment