#include <TM1637Display.h>
#define CLK 2
#define DIO 3
#define BTN_INC 4
#define BTN_DECR 5
TM1637Display display(CLK, DIO);
uint16_t value = 0;
unsigned long lastPressTime = 0;
void setup() {
pinMode(BTN_INC, INPUT_PULLUP);
pinMode(BTN_DECR, INPUT_PULLUP);
display.setBrightness(7); // Parlaklık (0-7)
}
void loop() {
static unsigned long lastMillis = 0;
bool upPressed = digitalRead(BTN_INC) == LOW;
bool downPressed = digitalRead(BTN_DECR) == LOW;
if (millis() - lastMillis > 100) {
lastMillis = millis();
if (upPressed) {
if (value < 0xFFFF) value++;
}
if (downPressed) {
if (value > 0x0000) value--;
}
}
uint8_t digits[] = {
(value >> 12) & 0xF,
(value >> 8) & 0xF,
(value >> 4) & 0xF,
(value) & 0xF
};
for (int i = 0; i < 4; i++) {
if (digits[i] > 9) digits[i] += 7; // A-F harflerini göstermek için
}
display.showNumberDecEx(value, 0, true);
}