Skip to content

Instantly share code, notes, and snippets.

@Strikeskids
Created February 20, 2014 17:52
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 Strikeskids/9119506 to your computer and use it in GitHub Desktop.
Save Strikeskids/9119506 to your computer and use it in GitHub Desktop.
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