Skip to content

Instantly share code, notes, and snippets.

@linnil1
Last active July 3, 2017 08:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save linnil1/959f70d3fb5d8db500d29aaafa72303b to your computer and use it in GitHub Desktop.
Save linnil1/959f70d3fb5d8db500d29aaafa72303b to your computer and use it in GitHub Desktop.
const int pinarray[7] = {12,13,7,9,8,11,10};
const int digitarray[10] =
{0x3F,0x06,0x5B,0x4F,0x66,0x6D,0x7D,0x07,0x7F,0x6F};
void setup()
{
for(int i=0; i<7; ++i)
pinMode(pinarray[i], OUTPUT);
}
void light(char *digits)
{
while(*digits)
{
// clear
for(int i=0; i<7; ++i)
digitalWrite(pinarray[i], LOW);
// main
int dig = digitarray[*digits - '0'];
++digits;
for(int j=0; j<7; ++j)
{
if((dig & 1) && pinarray[j])
digitalWrite(pinarray[j], HIGH);
dig >>= 1;
}
delay(500);
}
}
void loop()
{
char want[20] = "1234567890";
light(want);
delay(2000);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment