AJB2K3
Published © GPL3+

M5Stack Digital Clock

How to create a 4 digit digital clock using the M5Stack Digital-Clock Unit.

BeginnerProtip1 hour997
M5Stack Digital Clock

Things used in this project

Hardware components

M5Stack Core2 AWS
×1
M5Stack Digi-Clock Unit
×1

Software apps and online services

M5Stack UIFLow

Story

Read more

Code

Basic digital Clock Code

MicroPython
Copy this the M5Stack Core2 AWS and press run!
from m5stack import *
from m5stack_ui import *
from uiflow import *
import time
import unit

screen = M5Screen()
screen.clean_screen()
screen.set_screen_bg_color(0xFFFFFF)
digi_clock_0 = unit.get(unit.DIGI_CLOCK, unit.PORTA)

label0 = M5Label('label0', x=2, y=49, color=0x000, font=FONT_MONT_14, parent=None)

rtc.settime('ntp', host='cn.pool.ntp.org', tzone=1)
label0.set_text(str(rtc.datetime()))
digi_clock_0.init_i2c_address(0x30)
while True:
  digi_clock_0.write_match_string(((str((rtc.datetime()[4])) + str((rtc.datetime()[5])))))
  wait_ms(500)
  wait_ms(2)

Credits

AJB2K3

AJB2K3

45 projects • 28 followers
I have always had an interest in electronics but having failed my school exams, it has taken me 20+ years to produce products to share.

Comments