#include <MD_Parola.h>
#include <MD_MAX72xx.h>
#include <SoftwareSerial.h> // Include the SoftwareSerial library for Bluetooth communication

#define HARDWARE_TYPE MD_MAX72XX::PAROLA_HW
#define MAX_DEVICES 4 // 4 blocks
#define CS_PIN 10

MD_Parola ledMatrix = MD_Parola(HARDWARE_TYPE, CS_PIN, MAX_DEVICES);

SoftwareSerial bluetoothSerial(2, 3); // RX, TX pins for Bluetooth module

void setup()
{
    ledMatrix.begin();
    ledMatrix.setIntensity(10); // Set brightness (0 to 15)
    ledMatrix.displayClear();  // Clear the display

    bluetoothSerial.begin(9600); // Initialize Bluetooth communication
}

void loop()
{
    if (bluetoothSerial.available())
    {
        String receivedMessage = bluetoothSerial.readString(); // Read incoming message
        const char* messageCharArray = receivedMessage.c_str(); // Convert String to const char*

        ledMatrix.displayScroll(messageCharArray, PA_CENTER, PA_SCROLL_LEFT, 100);
    }

    if (ledMatrix.displayAnimate())
    {
        ledMatrix.displayReset();
    }
}