informatica:arduino:matrix_led
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
informatica:arduino:matrix_led [2022/10/24 23:50] – jose | informatica:arduino:matrix_led [2024/11/13 20:32] (current) – jose | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== | + | ====== Matrix |
- | Hay varias bibliotecas (que no librerías) | + | |
- | ====== 1. MD_MAX72XX y MD_Parola ====== | + | ^ ESP32 ^ MAX7219 ^ Descripción ^ |
- | https:// | + | | 5V | VCC | Alimentación | |
+ | | GND | GND | Tierra | | ||
+ | | GPIO 23 | DIN | Datos | | ||
+ | | GPIO 18 | CLK | Reloj | | ||
+ | | GPIO 5 | CS | Chip Select (CS/LOAD) | | ||
- | Bibliotecas: | ||
- | {{: | ||
- | |||
- | ^PANEL^ESP32^ | ||
- | |VCC|Vin| | ||
- | |GND|GND| | ||
- | |DIN|GPIO23| | ||
- | |CS|GPIO5| | ||
- | |CLK|GPIO18| | ||
- | |||
- | Texti de plano a pins | ||
- | < | ||
- | #include < | ||
- | #include < | ||
- | #include < | ||
- | |||
- | // Uncomment according to your hardware type | ||
- | #define HARDWARE_TYPE MD_MAX72XX:: | ||
- | //#define HARDWARE_TYPE MD_MAX72XX:: | ||
- | |||
- | // Defining size, and output pins | ||
- | #define MAX_DEVICES 4 | ||
- | #define DATA_PIN 23 | ||
- | #define CS_PIN 5 | ||
- | #define CLK_PIN 18 | ||
- | |||
- | |||
- | MD_Parola Display = MD_Parola(HARDWARE_TYPE, | ||
- | |||
- | void setup() { | ||
- | |||
- | Display.begin(); | ||
- | Display.setIntensity(0); | ||
- | Display.displayClear(); | ||
- | } | ||
- | |||
- | void loop() { | ||
- | Display.setTextAlignment(PA_LEFT); | ||
- | Display.print(" | ||
- | delay(2000); | ||
- | | ||
- | Display.setTextAlignment(PA_CENTER); | ||
- | Display.print(" | ||
- | delay(2000); | ||
- | |||
- | Display.setTextAlignment(PA_RIGHT); | ||
- | Display.print(" | ||
- | delay(2000); | ||
- | |||
- | Display.setTextAlignment(PA_CENTER); | ||
- | Display.setInvert(true); | ||
- | Display.print(" | ||
- | delay(2000); | ||
- | |||
- | Display.setInvert(false); | ||
- | delay(2000); | ||
- | } | ||
- | </ | ||
- | |||
- | ====== 2. Max72xxPanel y SPI ====== | ||
- | Con esta biblioteca (que no librería) podemos definir en que posición sale cada carácter. Por ejemplo, si hacemos una secuencia de números, el 1 es mas estrecho que el 2 | ||
- | |||
- | matrix.drawChar(x, | ||
- | Por ejemplo: | ||
- | matrix.drawChar(0, | ||
- | |||
- | < | ||
- | #include < | ||
- | #include < | ||
- | #include < | ||
- | |||
- | const int pinCS = 5; | ||
- | const int pinClk = 18; | ||
- | const int pinDin = 23; | ||
- | |||
- | String cadena = " | ||
- | |||
- | const int numberOfHorizontalDisplays = 4; | ||
- | //const int numberOfHorizontalDisplays = 1; // retirar comentario para una sola matriz | ||
- | const int numberOfVerticalDisplays = 1; | ||
- | Max72xxPanel matrix = Max72xxPanel(pinCS, | ||
- | |||
- | void setup() { | ||
- | |||
- | matrix.setIntensity(7); | ||
- | // | ||
- | matrix.setPosition(0, | ||
- | matrix.setPosition(1, | ||
- | matrix.setPosition(2, | ||
- | matrix.setPosition(3, | ||
- | matrix.setRotation(0, | ||
- | matrix.setRotation(1, | ||
- | matrix.setRotation(2, | ||
- | matrix.setRotation(3, | ||
- | |||
- | |||
- | } | ||
- | |||
- | void loop() { | ||
- | |||
- | matrix.drawChar(0, | ||
- | matrix.write(); | ||
- | } | ||
- | </ | ||
- | |||
- | Para escribir una palabra: | ||
- | Justificado a la izquierda | ||
- | < | ||
- | #include < | ||
- | #include < | ||
- | #include < | ||
- | |||
- | //Vcc - Vcc | ||
- | //Gnd - Gnd | ||
- | //Din - Mosi (Pin 11) | ||
- | //Cs - SS (Pin 10) | ||
- | //Clk - Sck (Pin 13) | ||
- | |||
- | const int pinCS = 5; | ||
- | const int numberOfHorizontalDisplays = 4; | ||
- | const int numberOfVerticalDisplays = 1; | ||
- | |||
- | Max72xxPanel matrix = Max72xxPanel(pinCS, | ||
- | |||
- | String tape = " | ||
- | |||
- | const int wait = 1000; // In milliseconds | ||
- | |||
- | const int spacer = 1; | ||
- | const int width = 5 + spacer; // The font width is 5 pixels | ||
- | |||
- | void setup() { | ||
- | | ||
- | |||
- | | ||
- | | ||
- | | ||
- | | ||
- | } | ||
- | |||
- | void loop() { | ||
- | for (int i = 0; i < tape.length(); | ||
- | matrix.drawChar(i*width, | ||
- | matrix.write(); | ||
- | } | ||
- | delay(wait); | ||
- | |||
- | matrix.fillScreen(0); | ||
- | matrix.write(); | ||
- | delay(wait); | ||
- | |||
- | } | ||
- | </ | ||
- | Texto con Scroll: | ||
- | < | ||
- | #include < | ||
- | #include < | ||
- | #include < | ||
- | |||
- | //Vcc - Vcc | ||
- | //Gnd - Gnd | ||
- | //Din - Mosi (Pin 11) | ||
- | //Cs - SS (Pin 10) | ||
- | //Clk - Sck (Pin 13) | ||
- | |||
- | const int pinCS = 5; | ||
- | const int numberOfHorizontalDisplays = 4; | ||
- | const int numberOfVerticalDisplays = 1; | ||
- | |||
- | Max72xxPanel matrix = Max72xxPanel(pinCS, | ||
- | |||
- | String tape = "Texto con Scroll"; | ||
- | |||
- | const int wait = 100; // In milliseconds | ||
- | |||
- | const int spacer = 1; | ||
- | const int width = 5 + spacer; // The font width is 5 pixels | ||
- | |||
- | void setup() { | ||
- | | ||
- | |||
- | | ||
- | | ||
- | | ||
- | | ||
- | } | ||
- | |||
- | 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, | ||
- | } | ||
- | |||
- | | ||
- | x -= width; | ||
- | } | ||
- | matrix.write(); | ||
- | |||
- | delay(wait); | ||
- | } | ||
- | } | ||
- | </ | ||
informatica/arduino/matrix_led.1666655446.txt.gz · Last modified: 2022/10/24 23:50 by jose