Created
July 24, 2015 16:09
-
-
Save ticapix/c7e42889188a9af76240 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 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); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Any one know how to change this to countdown from 10 please??