#include "LedControl.h"
#include "binary.h"
const int TEMP_SENSOR_PIN = A0;
const int LED_BAR_GRAPH_PIN = 2;
#define DIN 3
#define CS 4
#define CLK 5
#define DEV 1 //No of Devices
LedControl lc=LedControl(DIN,CLK,CS,DEV);
void setup() {
lc.shutdown(0,false);
lc.setIntensity(0,8); // Set the brightness (0-15)
lc.clearDisplay(0);
}
void loop() {
int temp = analogRead(TEMP_SENSOR_PIN);
float temp_c = (temp - 500) / 10.0; //Assuming that temperature sensor has a nominal resistance of 10kΩ at 25°C
if (temp_c >= 30.0) {
lc.setRow(0, 0, 0b11111111);
} else if (temp_c >= 20.0) {
lc.setRow(0, 0, 0b11110000);
} else if (temp_c >= 10.0) {
lc.setRow(0, 0, 0b11000000);
} else {
lc.setRow(0, 0, 0b00000000);
}
// Display temperature value on MAX7219 matrix
lc.clearDisplay(1);
lc.setDigit(1, 3, int(temp_c) / 10, false);
lc.setDigit(1, 2, int(temp_c) % 10, false);
lc.setDigit(1, 1, '.', false);
lc.setDigit(1, 0, int(temp_c * 10) % 10, false);
delay(1000);
}