/*
* 4連のLED MATRIX
* 参考
*
https://earthbondhon.com/8x32-led-matrix-max7219-tutorial-with-scrolling-text/
*/
#include <SPI.h>
#include <Adafruit_GFX.h> // Install from Library
Manager
#include <Max72xxPanel.h> //
https://github.com/markruys/arduino-Max72xxPanel
int pinCS = 15; // Attach CS to this pin, DIN to MOSI and
CLK to SCK (cf http://arduino.cc/en/Reference/SPI )
int numberOfHorizontalDisplays = 4;
int numberOfVerticalDisplays = 1;
// LED Matrix Pin -> ESP8266 Pin
//
Vcc
-> 3v (3V on NodeMCU 3V3 on WEMOS)
//
Gnd
-> Gnd (G on NodeMCU)
//
DIN
-> D7 (Same Pin for WEMOS)
//
CS
-> D8 (Same Pin for WEMOS)
//
CLK
-> D5 (Same Pin for WEMOS)
Max72xxPanel matrix = Max72xxPanel(pinCS,
numberOfHorizontalDisplays, numberOfVerticalDisplays);
String tape = "Eng. Tutul live Dhaka Bangladesh";
int wait = 100; // In milliseconds
int spacer = 1;
int width = 5 + spacer; // The font width is 5 pixels
void setup() {
matrix.setIntensity(7); // Use a value between 0
and 15 for brightness
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 in <2, 0>
matrix.setPosition( 3, 3, 0) ; // The fourth
display is at <3, 0>
matrix.setRotation(0, 1); // The first display is
position upside down
matrix.setRotation(1, 1); // The first display is
position upside down
matrix.setRotation(2, 1); // The first display is
position upside down
matrix.setRotation(3, 1); // The first display is
position upside down
}
void loop() {
for ( int i = 0 ; i < width * tape.length() +
matrix.width() - 1 - spacer; i++ ) {
matrix.fillScreen(LOW);
int letter = i / width;
int x = (matrix.width() - 1) - i %
width;
int y = (matrix.height() - 8) / 2; //
center the text vertically
while ( x + width - spacer >= 0
&& letter >= 0 ) {
if ( letter <
tape.length() ) {
matrix.drawChar(x, y, tape[letter], HIGH, LOW, 1);
}
letter--;
x -= width;
}
matrix.write(); // Send bitmap to
display
delay(wait);
}
}
|