// TM1637 kütüphanesi gerekli / TM1637 library required
#include <Arduino.h>
#include <TM1637Display.h>
// Pin tanımlamaları / Pin definitions
const int CLK_PIN = 4;
const int DIO_PIN = 5;
// GPIO 5 strapping pin, boot'ta HIGH / GPIO 5 is strapping pin, HIGH at boot
TM1637Display display(CLK_PIN, DIO_PIN);
int counter = 0;
unsigned long lastUpdate = 0;
const unsigned long updateInterval = 100;
bool colonState = false;
uint8_t brightness = 7; // 0-7 parlaklık / 0-7 brightness
// "HELP" segment verisi / "HELP" segment data
const uint8_t SEG_HELP[] = {
SEG_B | SEG_C | SEG_E | SEG_F | SEG_G, // H
SEG_A | SEG_D | SEG_E | SEG_F | SEG_G, // E
SEG_D | SEG_E | SEG_F, // L
SEG_A | SEG_B | SEG_E | SEG_F | SEG_G // P
};
void setup() {
Serial.begin(115200);
Serial.println("ESP32 TM1637 4-Digit Display Demo");
display.setBrightness(brightness);
// Açılışta HELP göster / Show HELP on startup
display.setSegments(SEG_HELP);
delay(2000);
display.clear();
delay(500);
}
void loop() {
if (millis() - lastUpdate >= updateInterval) {
lastUpdate = millis();
counter++;
if (counter > 9999) {
counter = 0;
}
if (counter % 5 == 0) {
colonState = !colonState;
}
// Kolon maskesi 0b01000000 / Colon mask 0b01000000
display.showNumberDecEx(counter, colonState ? 0b01000000 : 0, true);
// Demo: parlaklık döngüsü / Demo: brightness cycle
if (counter % 1000 == 0 && counter != 0) {
brightness = (brightness + 1) % 8;
display.setBrightness(brightness);
Serial.printf("Counter: %d - Brightness: %d\n", counter, brightness);
}
}
}