/*
* LED matrix with potentiometer example
* Adapted from https://esp32io.com/tutorials/esp32-led-matrix
*
* This ESP32 code is created by esp32io.com
*
* This ESP32 code is released in the public domain
*
* For more detail (instruction and wiring diagram), visit https://esp32io.com/tutorials/esp32-led-matrix
*/
#include <MD_Parola.h>
#include <MD_MAX72xx.h>
//#define HARDWARE_TYPE MD_MAX72XX::FC16_HW
#define HARDWARE_TYPE MD_MAX72XX::PAROLA_HW
#define MAX_DEVICES 4 // 4 blocks
#define CS_PIN 5
// create an instance of the MD_Parola class
MD_Parola ledMatrix = MD_Parola(HARDWARE_TYPE, CS_PIN, MAX_DEVICES);
#define POT 35
// create an instance of the MD_MAX72XX class for low-level graphics
MD_MAX72XX maxx = MD_MAX72XX(HARDWARE_TYPE, CS_PIN, MAX_DEVICES);
void setup() {
ledMatrix.begin(); // initialize the LED Matrix
ledMatrix.setIntensity(7); // set the brightness of the LED matrix display (from 0 to 15)
ledMatrix.displayClear(); // clear LED matrix display
maxx.begin();
maxx.clear();
}
int row = 0;
int col = 0;
// This function scrolls one dot accross the matrix
void loop() {
int a = analogRead(POT);
maxx.setPoint(row, col, true);
delay(a / 50 + 2);
maxx.setPoint(row, col, false);
if (++col == 32){
col = 0;
row = (row + 1) % 8;
}
}
// Rename this to loop() and the above function to loop2() to see the original demo */
void loop2() {
ledMatrix.setTextAlignment(PA_LEFT);
ledMatrix.print("Left"); // display text
delay(2000);
ledMatrix.setTextAlignment(PA_CENTER);
ledMatrix.print("Center"); // display text
delay(2000);
ledMatrix.setTextAlignment(PA_RIGHT);
ledMatrix.print("Right"); // display text
delay(2000);
ledMatrix.setTextAlignment(PA_CENTER);
ledMatrix.setInvert(true);
ledMatrix.print("Invert"); // display text inverted
delay(2000);
ledMatrix.setInvert(false);
ledMatrix.print(1234); // display number
delay(2000);
}