from machine import Pin, I2C, PWM
import time
import ssd1306
# Pin arrangement
i2c = I2C(0, scl=Pin(21), sda=Pin(20))
# ground and VCC to GND and voltage 3v3
Buzz = PWM(Pin(18))
Buzz.freq(500)
oled_width = 128
oled_height = 64
oled = ssd1306.SSD1306_I2C(oled_width, oled_height, i2c)
button = machine.Pin(5, machine.Pin.IN, machine.Pin.PULL_UP)
MedicineSchedule = {
0:"Pre Breakfast Meds",
9:"Paracetamol",
13:"Pre Lunch Meds",
14:"Post Lunch Meds",
21:"Pre Dinner Meds",
22: "Post Dinner Meds"
}
while True:
CurDateTime = time.gmtime()
if CurDateTime[3] in MedicineSchedule:
oled.text(MedicineSchedule[CurDateTime[3]], 0, 20)
oled.show()
Buzz.duty_u16(200)
while True:
if button.value() == 0:
Buzz.duty_u16(0)
break
oled.text("", 0, 20)
oled.show()
time.sleep(3600)