Created
February 20, 2014 17:52
-
-
Save Strikeskids/9119506 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
const int latchpin = 8; | |
const int clockpin = 12; | |
const int datapin = 11; | |
const int bits[10] = {0x3f, 0x06, 0x5b, 0x4f, 0x66, 0x6d, 0x7d, 0x07, 0x7f, 0x67}; | |
int curVal = 99; | |
void setup() { | |
pinMode(latchpin, OUTPUT); | |
pinMode(clockpin, OUTPUT); | |
pinMode(datapin, OUTPUT); | |
} | |
void loop() { | |
sendNumber(curVal); | |
delay(500); | |
if (curVal == 0) { | |
curVal = 99; | |
} else { | |
curVal--; | |
} | |
} | |
void sendNumber(int twodig) { | |
digitalWrite(latchpin, LOW); | |
sendDigit(twodig % 10); | |
sendDigit(twodig / 10); | |
digitalWrite(latchpin, HIGH); | |
} | |
void sendDigit(int digit) { | |
shiftOut(datapin, clockpin, MSBFIRST, bits[digit]); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment