Created
September 21, 2020 09:18
-
-
Save ekozhura/d4e58ba2b988c23b7cc7acba14565fa2 to your computer and use it in GitHub Desktop.
Arduino + 7-Segment Red LED + HCF4015B
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
#define DATA_PIN 3 // data | |
#define CLOCK_PIN 4 // clock | |
#define RESET_PIN 5 // reset | |
#define SEVEN_SEGMENTS_LENGTH 17 | |
static byte seven_segments_codes[SEVEN_SEGMENTS_LENGTH] = { | |
B10001000, // 0 | |
B11101011, // 1 | |
B01001100, // 2 | |
B01001001, // 3 | |
B00101011, // 4 | |
B00011001, // 5 | |
B00011000, // 6 | |
B11001011, // 7 | |
B00001000, // 8 | |
B00001011, // 9 | |
B00001010, // A | |
B00111000, // B | |
B10011100, // C | |
B01101000, // D | |
B00011100, // E | |
B00011110, // F | |
B01011101 // Error | |
}; | |
void writeData(byte data) { | |
shiftOut(DATA_PIN, CLOCK_PIN, MSBFIRST, data); | |
} | |
void setup() { | |
pinMode(DATA_PIN, OUTPUT); | |
pinMode(CLOCK_PIN, OUTPUT); | |
pinMode(RESET_PIN, OUTPUT); | |
} | |
void loop() { | |
for (int i = 0; i < SEVEN_SEGMENTS_LENGTH; i++) { | |
writeData(seven_segments_codes[i]); | |
delay(1000); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment