from machine import Pin, I2C
import ssd1306
import time
i2c = I2C(0, scl=Pin(22), sda=Pin(21))
oled = ssd1306.SSD1306_I2C(128, 64, i2c)
start_btn = Pin(15, Pin.IN, Pin.PULL_UP)
stop_btn = Pin(4, Pin.IN, Pin.PULL_UP)
led1 = Pin(18, Pin.OUT)
led2 = Pin(19, Pin.OUT)
count = 10
running = False
paused = False
def blink_leds():
led1.on()
led2.on()
time.sleep(0.3)
led1.off()
led2.off()
time.sleep(0.3)
def show_count(num):
oled.fill(0)
oled.text("Countdown", 20, 0)
oled.text(str(num), 60, 30)
oled.show()
def show_group():
oled.fill(0)
oled.text("Group 1", 0, 0)
oled.text("Kapoy", 0, 20)
oled.text("akong", 0, 32)
oled.text("life.", 0, 44)
oled.show()
led1.on()
led2.on()
while True:
if start_btn.value() == 0:
running = True
paused = False
time.sleep(0.3)
if stop_btn.value() == 0:
paused = True
time.sleep(0.3)
if running and not paused:
if count >= 0:
show_count(count)
blink_leds()
count -= 1
else:
running = False
show_group()
if paused:
led1.off()
led2.off()