#include "SevSeg.h"
SevSeg sevseg;
const int lm35Pin = A1; // LM35 sensor connected to analog pin A1
void setup() {
Serial.begin(9600);
byte numDigits = 4;
byte digitPins[] = {2, 3, 4, 5};
byte segmentPins[] = {6, 7, 8, 9, 10, 11, 12, 13};
bool resistorsOnSegments = false; // 'false' means resistors are on digit pins
byte hardwareConfig = COMMON_ANODE; // See README.md for options
sevseg.begin(hardwareConfig, numDigits, digitPins, segmentPins, resistorsOnSegments);
sevseg.setBrightness(90);
}
void loop() {
int lm35Value = analogRead(lm35Pin); // Read the analog value from the LM35
float voltage = lm35Value * (5.0 / 1023.0); // Convert the analog value to voltage
float temperature = voltage * 100.0; // Convert the voltage to temperature in Celsius
// Convert temperature to string with one decimal place
char tempStr[6];
dtostrf(temperature, 4, 1, tempStr); // 4 is width, 1 is precision
// Create an array to hold the segment values for each digit
byte segments[4];
// Convert temperature string to segments
sevseg.setChars(tempStr);
// Get the segment values from the converted temperature string
sevseg.getSegments(segments);
// Custom character for segments AFGB (A=1, F=1, B=1, G=1, others=0)
segments[2] = 0b1100011; // Bit pattern for AFGB
// Set the last digit to 'C'
segments[3] = 0b0111001; // Bit pattern for 'C' on a common anode display
// Turn on the decimal point of the 3rd digit
segments[2] |= 0b10000000; // Set the MSB to 1 to turn on the decimal point
// Update the display with the custom segments
sevseg.setSegments(segments);
sevseg.refreshDisplay();
}