#include <TM1637.h>
// Define the CLK and DIO pins for both displays
#define CLK1 4
#define DIO1 5
#define CLK2 2
#define DIO2 3
// Create two display objects
TM1637 display1(CLK1, DIO1);
TM1637 display2(CLK2, DIO2);
void setup() {
display1.init(); // Initialize the first display
display1.set(BRIGHT_TYPICAL); // Set brightness for the first display
display1.point(POINT_OFF); // Turn off the colon point for the first display
displayNumber(display1, 1234);
display2.init(); // Initialize the second display
display2.set(BRIGHT_TYPICAL); // Set brightness for the second display
display2.point(POINT_OFF); // Turn off the colon point for the second display
displayNumber(display2, 3456);
}
void loop() {
// No need to update the display in the loop
}
void displayNumber(TM1637 &display, int number) {
if (number < 0 || number > 9999) {
// Handle error if number is not a 4-digit integer
Serial.println("Error: Number out of range (0-9999)");
return;
}
// Extract and display each digit
display.display(0, number / 1000); // Thousands place
display.display(1, (number / 100) % 10); // Hundreds place
display.display(2, (number / 10) % 10); // Tens place
display.display(3, number % 10); // Ones place
}