-
-
Save ElectronicsIdiot/3ef9cdecffb68426b64e3a87c9f0becc to your computer and use it in GitHub Desktop.
Test
This file contains 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 12 | |
#define CLOCK 11 | |
int rows[] = {10, 9, 8, 7, 6, 5, 4}; // Row drive pins | |
void setup() { | |
pinMode(DATA, OUTPUT); | |
pinMode(CLOCK, OUTPUT); | |
for (int i = 0; i < 7; ++i) { | |
pinMode(rows[i], OUTPUT); | |
} | |
} | |
void shift(int data) { | |
digitalWrite(DATA, data); | |
delayMicroseconds(1); // Works fine without delays but I added them to make sure I'm operating within datasheet limits | |
digitalWrite(CLOCK, HIGH); // Pulse clock | |
delayMicroseconds(1); | |
digitalWrite(CLOCK, LOW); | |
delayMicroseconds(1); | |
} | |
void loop() { | |
delay(1); // Make sure all transistors have time to switch before shift (1ms) | |
shift(HIGH); // Shift a high | |
for (int j = 0; j < 30; ++j) { // Display is 30 wide, push the 1 off the end of the last shift register | |
shift(LOW); | |
} | |
delay(1); // Make sure all transistors have time to switch after shift (1ms) | |
// Bright LEDs at bottom if looping forwards, bright at top if looping backwards | |
if (true) { // True for looping forwards, false for backwards | |
for (int i = 0; i < 7; ++i) { // Pulse rows | |
digitalWrite(rows[i], LOW); // Inverted, low drives the row high | |
//Delay would go here | |
digitalWrite(rows[i], HIGH); // Disable the row | |
} | |
} else { | |
for (int i = 6; i >= 0; --i) { // Pulse rows | |
digitalWrite(rows[i], LOW); // Inverted, low drives the row high | |
// Delay would go here | |
digitalWrite(rows[i], HIGH); // Disable the row | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment