#include <IRremote.hpp>
#include <MD_Parola.h>
#include <MD_MAX72xx.h>
#include <SPI.h>
#include <LedControl.h>
LedControl lc=LedControl(11,13,10,0);
#define MAX_DEVICES 4 // Adjust this based on the number of MAX7219 devices you are using.
// Define the IR remote button hex codes
#define BUTTON_A 1570963200 //ON/OF
#define BUTTON_B 501415680 //MENU
#define BUTTON_C 3710058240 //TEST
#define BUTTON_D 4244832000 //+
#define BUTTON_E 1036189440 //RETURN
#define BUTTON_F 534839040 //|<<
#define BUTTON_G 1470693120 //> PLAY
#define BUTTON_H 1871773440 //>>|
#define BUTTON_0 2540240640
#define BUTTON_1 3476094720
#define BUTTON_2 3877175040
#define BUTTON_3 2239430400
#define BUTTON_4 4010868480
#define BUTTON_5 3342401280
#define BUTTON_6 2774204160
#define BUTTON_7 3175284480
#define BUTTON_8 3041591040
#define BUTTON_9 2907897600
// Create an instance of the IRremote library and specify the IR receiver pin
const int RECV_PIN=2;
IRrecv irrecv(RECV_PIN);
//decode_results results;
// Create an instance of the MD_Parola library
MD_Parola parola = MD_Parola(MD_MAX72XX::PAROLA_HW, 10, MAX_DEVICES);
MD_MAX72XX mx = MD_MAX72XX(MD_MAX72XX::PAROLA_HW, 10, MAX_DEVICES);
// Custom messages to display
char message1[] = "MERCEDES";
char message2[] = "NISSAN";
char message3[] = "AUDI";
char message4[] = "BMW";
char message5[] = "HYUNDAI";
char message6[] = "TOYOTA";
char message7[] = "KIA";
byte smile[8]= {0x3C,0x42,0xA5,0x81,0xA5,0x99,0x42,0x3C};
byte neutral[8]= {0x3C,0x42,0xA5,0x81,0xBD,0x81,0x42,0x3C};
byte frown[8]= {0x3C,0x42,0xA5,0x81,0x99,0xA5,0x42,0x3C};
byte IntensivityRate = 0;
void setup() {
// Initialize the IR receiver and LED matrix
Serial.begin(9600);
IrReceiver.begin(RECV_PIN, ENABLE_LED_FEEDBACK);
parola.begin();
parola.displayClear();
// Set the intensity (brightness) of the display (0-15)
parola.setIntensity(5);
lc.clearDisplay(0); // and clear the display
}
void loop() {
// Check for incoming IR remote signals
if (IrReceiver.decode()) {
Serial.println(IrReceiver.decodedIRData.decodedRawData);
// вывод текста
if (IrReceiver.decodedIRData.decodedRawData == BUTTON_A) {
displayMessage(message1);
} else if (IrReceiver.decodedIRData.decodedRawData == BUTTON_B) {
displayMessage(message2);
} else if (IrReceiver.decodedIRData.decodedRawData == BUTTON_C) {
displayMessage(message3);
} else if (IrReceiver.decodedIRData.decodedRawData == BUTTON_D) {
scrollText(message4);
} else if (IrReceiver.decodedIRData.decodedRawData == BUTTON_E) {
displayMessage(message5);
} else if (IrReceiver.decodedIRData.decodedRawData == BUTTON_F) {
displayMessage(message6);
} else if (IrReceiver.decodedIRData.decodedRawData == BUTTON_G) {
scrollText(message7);
}
// вывод лого
else if (IrReceiver.decodedIRData.decodedRawData == BUTTON_0) {
printByte(smile);
delay(1000);
}
else if (IrReceiver.decodedIRData.decodedRawData == BUTTON_1) {
printByte(neutral);
delay(1000);
}
else if (IrReceiver.decodedIRData.decodedRawData == BUTTON_2) {
printByte(frown);
delay(1000);
}
// изменение яркости
else if (IrReceiver.decodedIRData.decodedRawData == BUTTON_3) {
parola.setIntensity(IntensivityRate+=3);
if (IntensivityRate > 15){
IntensivityRate = 0;
parola.setIntensity(0);
}
}
IrReceiver.resume(); // Receive the next value
}
}
void displayMessage(char* message) {
// Display the custom message on the LED matrix
parola.displayText(message, PA_CENTER, 0, 0, PA_PRINT, PA_NO_EFFECT);
parola.displayAnimate();
//delay(2000);
}
void scrollText(char* message) {
// Continue scrolling the text until any IR button is pressed
parola.displayReset(); // Clear any existing display content
parola.displayText(message, PA_CENTER, 60, 0, PA_SCROLL_LEFT, PA_SCROLL_LEFT);
while (!parola.displayAnimate()) {
parola.displayAnimate();
//delay(50); // Adjust this delay to control the scrolling speed
}
parola.displayReset(); // Clear the display after the loop
displayMessage(message);
}
//parola.displayText(message, PA_CENTER, 0, 0, PA_PRINT, PA_NO_EFFECT);
// Display the message for 2 seconds (adjust as needed)
void printByte(byte character [])
{
int i = 0;
for(i=0;i<8;i++)
{
lc.setRow(0,i,character[i]);
}
}