#include <MD_Parola.h>
#include <MD_MAX72xx.h>
#include <SPI.h>
#define HARDWARE_TYPE MD_MAX72XX::PAROLA_HW
#define MAX_DEVICES 4
#define CLK_PIN 13
#define DATA_PIN 11
#define CS_PIN 10
// Constants for the NTC sensor
const int ntcPin = A0;
const float refResistor = 10000.0;
const float refVoltage = 5.0;
MD_Parola P = MD_Parola(HARDWARE_TYPE, CS_PIN, MAX_DEVICES);
void setup()
{
P.begin(2);
P.setInvert(false);
P.setZone(0, MAX_DEVICES - 4, MAX_DEVICES - 1);
analogReference(DEFAULT);
}
void loop()
{
int rawValue = analogRead(ntcPin);
float voltage = (rawValue / 1023.0) * refVoltage;
float resistance = (refResistor * voltage) / (refVoltage - voltage);
float temperatureC = 1.0 / (1.0 / (25 + 273.15) + log(resistance / 10000.0) / 3950.0) - 273.15;
char tempStr[10];
dtostrf(temperatureC, 3, 1, tempStr);
P.displayZoneText(0, tempStr, PA_CENTER, 0, 0, PA_PRINT, PA_NO_EFFECT);
P.displayAnimate();
}