Arduino > Matrice
Contents (hide)
// Pin connected to SRCLK of both 74HC595 int CLOCK = 10; // Pin connected to RCLK of both 74HC595 int LATCH = 9; // Pin connected to SER of 74HC595 for rows ( R1 to R8 ) int DATA = 8; byte column = 0; byte image[8]; void setup() { // Set pins to output so you can control the shift register: pinMode(LATCH, OUTPUT); pinMode(CLOCK, OUTPUT); pinMode(DATA, OUTPUT); // Fill the image array with data: image[0] = B00000001; image[1] = B00000010; image[2] = B00000100; image[3] = B00001000; image[4] = B00010000; image[5] = B00100000; image[6] = B01000000; image[7] = B10000000; } void loop() { // take the latchPin low digitalWrite(LATCH, LOW); // shift out the bits for the columns: shiftOut(DATA, CLOCK, MSBFIRST, B00000001 << column); // shift out the bits for the row: shiftOut(DATA, CLOCK, MSBFIRST, image[column]); //take the latch pin high so the LEDs update: digitalWrite(LATCH, HIGH); column = (column + 1) % 8; }