#include <LedControl.h>
// Pin definitions for the LED matrix
int DIN = 12;
int CS = 11;
int CLK = 10;
LedControl lc = LedControl(DIN, CLK, CS, 0); // Create LedControl object
// Pin for voice detection
int voicePin = A0;
void setup() {
lc.shutdown(0, false); // Wake up displays
lc.setIntensity(0, 15); // Set brightness level (0 to 15)
lc.clearDisplay(0); // Clear display register
pinMode(voicePin, INPUT); // Set voicePin as input
}
void loop() {
// Check if there is voice input
bool voiceDetected = (digitalRead(voicePin) == HIGH); // Change this if using analog or different logic
if (voiceDetected) {
// Display TALK1 and TALK2 if voice is detected
displayTalk();
} else {
// Display FACE if no voice is detected
displayFace();
}
}
void displayFace() {
delay(1000);
tone(7, 262, 250);
// Pattern for FACE
byte FACE[8] = {
B00111100,
B01000010,
B10100101,
B10000001,
B10100101,
B10011001,
B01000010,
B00111100
};
printByte(FACE);
delay(1000);
}
void displayTalk() {
delay(1000);
// Pattern for TALK1
byte TALK1[8] = {
B00111100,
B01000010,
B10100101,
B10000001,
B10011001,
B10100101,
B01011010,
B00111100
};
printByte(TALK1);
delay(1000);
// Pattern for TALK2
byte TALK2[8] = {
B00111100,
B01000010,
B10100101,
B10000001,
B10000001,
B10111101,
B01000010,
B00111100
};
printByte(TALK2);
delay(1000);
}
void printByte(byte character[]) {
for (int i = 0; i < 8; i++) {
lc.setRow(0, i, character[i]); // Set each row of the display
}
}