Last active
July 3, 2017 08:26
-
-
Save linnil1/959f70d3fb5d8db500d29aaafa72303b to your computer and use it in GitHub Desktop.
This file contains 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
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