#include <MD_MAX72xx.h>
#include <SPI.h>
#define HARDWARE_TYPE MD_MAX72XX::FC16_HW
#define MAX_DEVICES 1
#define CLK_PIN 13
#define DATA_PIN 11
#define CS_PIN 10
// Pines para botones (conectados a GND con resistencia pull-up)
#define BOTON_FELIZ 2
#define BOTON_TRISTE 3
MD_MAX72XX mx = MD_MAX72XX(HARDWARE_TYPE, CS_PIN, MAX_DEVICES);
// Expresiones de EVA (8x8)
uint8_t evaFeliz[] = {
0b00000000,
0b01100110, // Ojos grandes
0b01100110,
0b00000000,
0b00011000, // Boca sonriente (^)
0b00100100,
0b01000010,
0b00000000
};
uint8_t evaTriste[] = {
0b00000000,
0b01100110, // Ojos iguales
0b01100110,
0b00000000,
0b01000010, // Boca triste (v)
0b00100100,
0b00011000,
0b00000000
};
uint8_t evaNeutral[] = {
0b00000000,
0b01100110,
0b01100110,
0b00000000,
0b00111100, // Boca recta
0b00000000,
0b00000000,
0b00000000
};
void setup() {
mx.begin();
mx.control(MD_MAX72XX::INTENSITY, 5); // Brillo medio
mx.clear();
// Configurar botones con resistencias pull-up internas
pinMode(BOTON_FELIZ, INPUT_PULLUP);
pinMode(BOTON_TRISTE, INPUT_PULLUP);
// Mostrar cara neutral inicial
mostrarExpresion(evaNeutral);
}
void loop() {
// Leer botones (LOW = presionado)
if (digitalRead(BOTON_FELIZ) == LOW) {
mostrarExpresion(evaFeliz);
delay(300); // Anti-rebote
}
else if (digitalRead(BOTON_TRISTE) == LOW) {
mostrarExpresion(evaTriste);
delay(300);
}
}
void mostrarExpresion(uint8_t expresion[]) {
for (int fila = 0; fila < 8; fila++) {
mx.setRow(0, fila, expresion[fila]);
}
}
Feliz
Triste