Last active
August 29, 2015 14:21
-
-
Save t-kashima/a93371b69a28a21e092f to your computer and use it in GitHub Desktop.
LED display stop watch for Arduino
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
// アソードコモンのため0の場所が光る | |
int num[10][8] = { | |
{0, 0, 1, 0, 1, 0, 0, 0}, // 0 | |
{1, 1, 1, 0, 1, 0, 1, 1}, // 1 | |
{0, 0, 1, 1, 0, 0, 1, 0}, // 2 | |
{1, 0, 1, 0, 0, 0, 1, 0}, // 3 | |
{1, 1, 1, 0, 0, 0, 0, 1}, // 4 | |
{1, 0, 1, 0, 1, 1, 0, 0}, // 5 | |
{0, 0, 1, 0, 1, 1, 0, 0}, // 6 | |
{1, 1, 1, 0, 1, 0, 0, 0}, // 7 | |
{0, 0, 1, 0, 0, 0, 0, 0}, // 8 | |
{1, 0, 1, 0, 0, 0, 0, 0} // 9 | |
}; | |
int count = 0; | |
void setup() { | |
// put your setup code here, to run once: | |
for (int i = 0; i < 8; i++) { | |
pinMode(i + 6, OUTPUT); | |
} | |
} | |
void loop() { | |
// put your main code here, to run repeatedly: | |
showDisplay(count); | |
count += 1; | |
if (10 <= count) { | |
count = 0; | |
} | |
delay(1000); | |
} | |
void showDisplay(int n) { | |
// LED show | |
for (int i = 0; i < 8; i++) { | |
digitalWrite(i + 6, num[n][i]); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment