Last active
April 8, 2021 16:18
-
-
Save cbscribe/60fc5fdd85eb8736082c47fc394c898b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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