Skip to content

Instantly share code, notes, and snippets.

@maxpromer
Created October 31, 2025 02:33
Show Gist options
  • Save maxpromer/3ce762d37b382c21cf1c07420a69f7f5 to your computer and use it in GitHub Desktop.
Save maxpromer/3ce762d37b382c21cf1c07420a69f7f5 to your computer and use it in GitHub Desktop.
#include <Wire.h>
#include <Adafruit_GFX.h>
#include "Adafruit_LEDBackpack.h"
Adafruit_7segment matrix = Adafruit_7segment();
int hours = 12;
int minutes = 0;
int seconds = 0;
void setup() {
matrix.begin(0x70);
matrix.setBrightness(8);
}
void loop() {
// แสดงเวลาในรูปแบบ HH:MM
int displayValue = hours * 100 + minutes;
matrix.print(displayValue, DEC);
// แสดงเครื่องหมาย colon (:) กระพริบ
matrix.drawColon(seconds % 2 == 0);
matrix.writeDisplay();
// อัปเดตเวลา
seconds++;
if (seconds >= 60) {
seconds = 0;
minutes++;
if (minutes >= 60) {
minutes = 0;
hours++;
if (hours >= 24) {
hours = 0;
}
}
}
delay(1000);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment