Skip to content

Instantly share code, notes, and snippets.

@mohitbhoite
Created July 29, 2025 19:37
Show Gist options
  • Save mohitbhoite/78fcb76f4949085ffcf13acfad36593b to your computer and use it in GitHub Desktop.
Save mohitbhoite/78fcb76f4949085ffcf13acfad36593b to your computer and use it in GitHub Desktop.
ATTINY861A and seven segment based temperature monitor
/* Tiny Temperature Monitor
* ATTINY861A and sevensegment based temperature monitor
* https://www.bhoite.com/sculptures/tiny-temp-monitor/
Display module: LTC-2723P COMMON CATHODE
ATTINY861A
01 DIGIT1 7
02 C,L3 5
03 DP 4
04 NC
05 E 3
06 D 2
07 G 1
08 DIGIT4 0
09 NC
10 NC
11 DIGIT3 9
12 DIGIT L1,L2,L3 11
13 A,L1 12
14 DIGIT2 13
15 B,L2 6
16 F 14
*/
#include "SevSeg.h"
#include <TinyBME280.h>
#include <Wire.h>
//#include <TinyWireM.h>
//#include <USI_TWI_Master.h>
#include <avr/power.h>
SevSeg sevseg; //Instantiate a seven segment controller object
unsigned long previousMillis = 0;
char dataF[10];
char dataC[10];
int8_t DISPLAY_STATE = 0;
int8_t COUNTER,ANI_COUNTER = 0;
bool ANIMATE = 1;
bool CHILL = 0;
/* Animation Data - HGFEDCBA Map */
const uint8_t ANIMATION1[16][4] = {
{ 0x01, 0x00, 0x00, 0x00 }, // Frame 0
{ 0x00, 0x01, 0x00, 0x00 }, // Frame 1
{ 0x00, 0x02, 0x00, 0x00 }, // Frame 2
{ 0x00, 0x00, 0x10, 0x00 }, // Frame 3
{ 0x00, 0x00, 0x08, 0x00 }, // Frame 4
{ 0x00, 0x00, 0x00, 0x08 }, // Frame 5
{ 0x00, 0x00, 0x00, 0x04 }, // Frame 6
{ 0x00, 0x00, 0x00, 0x02 }, // Frame 7
{ 0x00, 0x00, 0x00, 0x01 }, // Frame 8
{ 0x00, 0x00, 0x01, 0x00 }, // Frame 9
{ 0x00, 0x00, 0x20, 0x00 }, // Frame 10
{ 0x00, 0x04, 0x00, 0x00 }, // Frame 11
{ 0x00, 0x08, 0x00, 0x00 }, // Frame 12
{ 0x08, 0x00, 0x00, 0x00 }, // Frame 13
{ 0x10, 0x00, 0x00, 0x00 }, // Frame 14
{ 0x20, 0x00, 0x00, 0x00 } // Frame 15
};
/* Animation Data - HGFEDCBA Map */
const uint8_t ANIMATION2[6][4] = {
{ 0x10, 0x10, 0x10, 0x10 }, // Frame 0
{ 0x20, 0x20, 0x20, 0x20 }, // Frame 1
{ 0x01, 0x01, 0x01, 0x01 }, // Frame 2
{ 0x02, 0x02, 0x02, 0x02 }, // Frame 3
{ 0x04, 0x04, 0x04, 0x04 }, // Frame 4
{ 0x08, 0x08, 0x08, 0x08 } // Frame 5
};
void setup() {
clock_prescale_set(clock_div_1);
Wire.begin();
//TinyWireM.begin();
BME280setup();
byte numDigits = 5;
byte digitPins[] = {7,13,9,0,11}; //ATTINY861A D1 D2 D3 D4 COLON
byte segmentPins[] = {12,6,5,2,3,14,1,4};//ATTINY861A ABCDEFG DP
bool resistorsOnSegments = true; // 'false' means resistors are on digit pins
byte hardwareConfig = COMMON_CATHODE; // See README.md for options //MTRAS
//byte hardwareConfig = COMMON_ANODE; // See README.md for options
bool updateWithDelays = true; // Default 'false' is Recommended
bool leadingZeros = false; // Use 'true' if you'd like to keep the leading zeros
bool disableDecPoint = false; // Use 'true' if your decimal point doesn't exist or isn't connected
sevseg.begin(hardwareConfig, numDigits, digitPins, segmentPins, resistorsOnSegments,
updateWithDelays, leadingZeros, disableDecPoint);
sevseg.setBrightness(200);
delay(2000);
//sevseg.setNumber(8888, 1);
}
void loop() {
while(ANIMATE)
{
unsigned long currentMillis = millis();
if (currentMillis - previousMillis >= 100)
{
previousMillis = currentMillis;
sevseg.setSegments(ANIMATION1[COUNTER]);
COUNTER++;
if (COUNTER == 16)
{
COUNTER = 0;
ANI_COUNTER++;
}
if(ANI_COUNTER == 3)
{
ANIMATE = 0;
previousMillis = millis()+4000;
}
sevseg.refreshDisplay(); // Must run repeatedly
}
sevseg.refreshDisplay();
}
unsigned long currentMillis = millis();
if (currentMillis - previousMillis >= 2000)
{
previousMillis = currentMillis;
//displayTemp();
if(CHILL) sevseg.setChars("CHLL");
else sevseg.setChars("CHLLM");
CHILL = !CHILL;
}
sevseg.refreshDisplay();
}
void displayTemp(void)
{
//int temperature = ((BME280temperature()/100)*1.8)+32;
int tempC = BME280temperature();
//int tempF = ((tempC/100)*1.8)+32;
int tempCD = tempC-((tempC/100)*100);
if (((tempC/100) <110) && ((tempC/100) > -20))
{
sprintf(dataC,"%d.%dC",tempC/100,tempCD/10);
sevseg.setChars(dataC);
}
sevseg.refreshDisplay(); // Must run repeatedly
}
void animate(void)
{
// for(int i=0;i<16;i++){
// sevseg.setSegments(ANIMATION1[i]);
// sevseg.refreshDisplay();
// delay(200);
// }
for(int i=0;i<6;i++){
sevseg.setSegments(ANIMATION2[i]);
sevseg.refreshDisplay();
delay(100);
}
}
/// END ///
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment