/*
TM1637 Display Test
Wiring :
Display Arduino
CLK ----> 9
DIO ----> 10
VCC ----> 5V
GND ----> GND
*** O-Tech ***
A Place You Can Trust
https://wa.me/201207738604
https://www.facebook.com/profile.php?id=61555112881938
https://www.youtube.com/@OTECHegypt
*/
#include <TM1637Display.h>
// define the connections pins
#define CLK 9
#define DIO 10
// create a display object of type TM1637Display
TM1637Display display = TM1637Display(CLK, DIO);
// an array that sets individual segments per digit to display the word "dOnE"
const uint8_t done[] = {
SEG_B | SEG_C | SEG_D | SEG_E | SEG_G, // d
SEG_C | SEG_D | SEG_E | SEG_G, // o
SEG_C | SEG_E | SEG_G, // n
SEG_A | SEG_B | SEG_D | SEG_E | SEG_F | SEG_G // e
};
// degree celsius symbol
const uint8_t celsius[] = {
SEG_A | SEG_B | SEG_F | SEG_G, // Degree symbol
SEG_A | SEG_D | SEG_E | SEG_F // C
};
void setup() {
display.clear();
display.setBrightness(7); // set the brightness to 7 (0:dimmest, 7:brightest)
}
void loop() {
// show counter 0-9
int i;
for (i = 0; i < 10; i++) {
//void TM1637Display::showNumberDec(int num, bool leading_zero, uint8_t length, uint8_t pos)
display.showNumberDec(i + i*10 + i*100 + i*1000);
delay(500);
display.clear();
}
// displayed 15:30
// void TM1637Display::showNumberDecEx(int num, uint8_t dots, bool leading_zero,
// uint8_t length, uint8_t pos)
display.showNumberDecEx(1530, 0b11100000, false, 4, 0);
delay(2000);
display.clear();
// displayed 23°C
int temperature = 25; // or read from temperature sensor
display.showNumberDec(temperature, false, 2, 0);
//void TM1637Display::setSegments(const uint8_t segments[], uint8_t length, uint8_t pos)
display.setSegments(celsius, 2, 2);
delay(2000);
display.clear();
// displayed letters: dOnE
display.setSegments(done);
delay(2000);
display.clear();
}