from microbit import *

Inisialisasi variabel jam dan menit

hours = 0
minutes = 0

while True:
if button_a.is_pressed() and button_b.is_pressed():
# Reset jam dan menit jika kedua tombol ditekan bersamaan
hours = 0
minutes = 0
display.scroll(“{}:{}”.format(hours, minutes))
elif button_a.is_pressed():
# Tambahkan jam jika tombol A ditekan
hours = (hours + 1) % 24
display.scroll(“{}:{}”.format(hours, minutes))
elif button_b.is_pressed():
# Tambahkan menit jika tombol B ditekan
minutes = (minutes + 1) % 60
display.scroll(“{}:{}”.format(hours, minutes))

# Tampilkan waktu saat ini setiap 10 detik
sleep(10000)
display.scroll("{}:{}".format(hours, minutes))

Leave a comment

Your email address will not be published. Required fields are marked *