Last active
January 25, 2023 07:01
-
-
Save RodrigoSC/a9d5029b71d3240bf0a68d4c3cd02f34 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
byte character[8]={0x24, 0x24, 0x24, 0xa5, 0x81, 0x81, 0x7e, 0x0}; | |
uint8_t colPins[8]={ 2, 3, 4, 5, 6, 7, 8, 9}; | |
#define SER_PIN 10 | |
#define SCK_PIN 11 | |
#define RCK_PIN 12 | |
void setup() { | |
// Turn everything to low | |
for(int i=0; i<8; i++) { | |
pinMode(colPins[i],OUTPUT); | |
} | |
pinMode(SER_PIN, OUTPUT); | |
pinMode(SCK_PIN, OUTPUT); | |
pinMode(RCK_PIN, OUTPUT); | |
Serial.begin(9600); | |
} | |
void loop() { | |
// iterate each row | |
int rowbits = 0x80; | |
for(int row=0; row<8; row++) { | |
for(int k=0; k<8; k++) | |
digitalWrite(colPins[k],HIGH); // Cleanup cols | |
write595(rowbits); // prepare to write the row | |
for(int col=0; col<8; col++) | |
digitalWrite(colPins[7-col], character[row] & 1 << col ? LOW : HIGH); | |
delay(1); | |
write595(0); | |
rowbits >>= 1; | |
} | |
} | |
void write595(byte data) { | |
digitalWrite(RCK_PIN, LOW); | |
shiftOut(SER_PIN, SCK_PIN, LSBFIRST, data); | |
digitalWrite(RCK_PIN, HIGH); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment