Skip to content

Instantly share code, notes, and snippets.

@ticapix
Created July 24, 2015 16:09
Show Gist options
  • Select an option

  • Save ticapix/c7e42889188a9af76240 to your computer and use it in GitHub Desktop.

Select an option

Save ticapix/c7e42889188a9af76240 to your computer and use it in GitHub Desktop.
const uint8_t SYMBOLS[17] =
{
0xC0, // 0
0xF9, // 1
0xA4, // 2
0xB0, // 3
0x99, // 4
0x92, // 5
0x82, // 6
0xF8, // 7
0x80, // 8
0x90, // 9
0b10001000, // A
0b10000011, // b
0xC6, // C
0xA1, // d
0b10000110, // E
0b10001110, // F
0b00111111 // -.
};
const int SCLK = 11; // CLOCK
const int RCLK = 12; // LATCH
const int DIO = 13; // DATA
uint8_t DIGITS[4] = {0, 0, 0, 0};
void setup ()
{
pinMode(SCLK, OUTPUT);
pinMode(RCLK, OUTPUT);
pinMode(DIO, OUTPUT);
}
void loop()
{
update_display();
unsigned long x = millis() / 100;
for(int i = 0; i < 4; i++) {
DIGITS[i] = SYMBOLS[x % 10];
x /= 10;
}
// adding the comma on the 3th digit
DIGITS[1] = DIGITS[1] & 0b01111111;
}
void update_display(void)
{
for (uint8_t i = 0; i < 4; ++i) {
shiftOut(DIO, SCLK, MSBFIRST, DIGITS[i]);
shiftOut(DIO, SCLK, MSBFIRST, 1 << i);
digitalWrite(RCLK, LOW);
digitalWrite(RCLK, HIGH);
}
}
@g4ztd
Copy link
Copy Markdown

g4ztd commented Dec 12, 2015

Any one know how to change this to countdown from 10 please??

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment