#include <TM1637Display.h>
#define CLK 6 // Pin Clock untuk TM1637
#define DIO 7 // Pin Data untuk TM1637
#define START_BUTTON 3 // Pin untuk tombol start
#define PAUSE_BUTTON 4 // Pin untuk tombol pause
#define RESET_BUTTON 5 // Pin untuk tombol reset
TM1637Display display(CLK, DIO);
int countdownValue = 10; // Waktu countdown dalam detik
bool isCounting = false;
void setup() {
display.setBrightness(7); // Atur tingkat kecerahan seven segment display
pinMode(START_BUTTON, INPUT_PULLUP);
pinMode(PAUSE_BUTTON, INPUT_PULLUP);
pinMode(RESET_BUTTON, INPUT_PULLUP);
}
void loop() {
if (digitalRead(START_BUTTON) == LOW) {
startCountdown();
}
if (digitalRead(PAUSE_BUTTON) == LOW) {
pauseCountdown();
}
if (digitalRead(RESET_BUTTON) == LOW) {
resetCountdown();
}
if (isCounting) {
countdownValue--;
display.showNumberDec(countdownValue, false);
if (countdownValue == 0) {
// Countdown selesai, lakukan sesuatu di sini
isCounting = false;
}
delay(1000); // Delay 1 detik
}
}
void startCountdown() {
isCounting = true;
}
void pauseCountdown() {
isCounting = false;
}
void resetCountdown() {
countdownValue = 10; // Reset waktu countdown
display.showNumberDec(countdownValue, false);
isCounting = false;
}