#include <LedControl.h>
// Define the number of devices we are using
#define NUM_DEVICES 1
// Create a new LedControl object
// Parameters: DIN pin, CLK pin, CS pin, number of devices
LedControl lc = LedControl(11, 13, 10, NUM_DEVICES);
// Face patterns for 8x8 LED matrix (eye and mouth shapes for animation)
const byte facePatterns[6][8] = {
// Face with closed mouth and open eyes
{
B01100110, // Row 0
B10011001, // Row 1
B10011001, // Row 2
B01100110, // Row 3
B00000000, // Row 4
B00000000, // Row 5
B00111100, // Row 6
B00000000 // Row 7
},
// Face with small open mouth and open eyes
{
B01100110, // Row 0
B10011001, // Row 1
B10011001, // Row 2
B01100110, // Row 3
B00000000, // Row 4
B00000000, // Row 5
B00111100, // Row 6
B00011000 // Row 7
},
// Face with wide open mouth and open eyes
{
B01100110, // Row 0
B10011001, // Row 1
B10011001, // Row 2
B01100110, // Row 3
B00000000, // Row 4
B00000000, // Row 5
B01111110, // Row 6
B00111100 // Row 7
},
// Face with closed mouth and closed eyes
{
B01100110, // Row 0
B01100110, // Row 1
B01100110, // Row 2
B01100110, // Row 3
B00000000, // Row 4
B00000000, // Row 5
B00111100, // Row 6
B00000000 // Row 7
},
// Face with small open mouth and closed eyes
{
B01100110, // Row 0
B01100110, // Row 1
B01100110, // Row 2
B01100110, // Row 3
B00000000, // Row 4
B00000000, // Row 5
B00111100, // Row 6
B00011000 // Row 7
},
// Face with wide open mouth and closed eyes
{
B01100110, // Row 0
B01100110, // Row 1
B01100110, // Row 2
B01100110, // Row 3
B00000000, // Row 4
B00000000, // Row 5
B01111110, // Row 6
B00111100 // Row 7
}
};
void setup() {
// Initialize the MAX7219 module
lc.shutdown(0, false); // Wake up the MAX7219
lc.setIntensity(0, 8); // Set brightness level (0 is min, 15 is max)
lc.clearDisplay(0); // Clear the display
}
void displayPattern(const byte pattern[8]) {
for (int row = 0; row < 8; row++) {
lc.setRow(0, row, pattern[row]);
}
}
void loop() {
// Loop through each face pattern to simulate talking and blinking
for (int i = 0; i < 6; i++) {
displayPattern(facePatterns[i]);
delay(500); // Wait for half a second before switching to the next pattern
}
}