47 lines
1.4 KiB
Plaintext
47 lines
1.4 KiB
Plaintext
#include <SPI.h>
|
|
#include <Adafruit_GFX.h>
|
|
#include <Max72xxPanel.h>
|
|
|
|
int pinCS = 10; // Attach CS to this pin, DIN to MOSI and CLK to SCK (cf http://arduino.cc/en/Reference/SPI )
|
|
int numberOfHorizontalDisplays = 1;
|
|
int numberOfVerticalDisplays = 1;
|
|
|
|
Max72xxPanel matrix = Max72xxPanel(pinCS, numberOfHorizontalDisplays, numberOfVerticalDisplays);
|
|
|
|
void setup() {
|
|
matrix.setIntensity(0);
|
|
|
|
// Adjust to your own needs
|
|
// matrix.setPosition(0, 0, 0); // The first display is at <0, 0>
|
|
// matrix.setPosition(1, 1, 0); // The second display is at <1, 0>
|
|
// matrix.setPosition(2, 2, 0); // The third display is at <2, 0>
|
|
// matrix.setPosition(3, 3, 0); // And the last display is at <3, 0>
|
|
// ...
|
|
// matrix.setRotation(0, 2); // The first display is position upside down
|
|
// matrix.setRotation(3, 2); // The same hold for the last display
|
|
}
|
|
|
|
int wait = 50;
|
|
int inc = -2;
|
|
|
|
void loop() {
|
|
|
|
for ( int x = 0; x < matrix.width() - 1; x++ ) {
|
|
matrix.fillScreen(LOW);
|
|
matrix.drawLine(x, 0, matrix.width() - 1 - x, matrix.height() - 1, HIGH);
|
|
matrix.write(); // Send bitmap to display
|
|
delay(wait);
|
|
}
|
|
|
|
for ( int y = 0; y < matrix.height() - 1; y++ ) {
|
|
matrix.fillScreen(LOW);
|
|
matrix.drawLine(matrix.width() - 1, y, 0, matrix.height() - 1 - y, HIGH);
|
|
matrix.write(); // Send bitmap to display
|
|
delay(wait);
|
|
}
|
|
|
|
wait = wait + inc;
|
|
if ( wait == 0 ) inc = 2;
|
|
if ( wait == 50 ) inc = -2;
|
|
}
|