Saravanan Sylesh
Published

Medicine Dispenser by Group 5

Create a device which allows the elderly to have their medicine on time while being able to alert helpers if they need help.

BeginnerProtip10 hours94
Medicine Dispenser by Group 5

Things used in this project

Story

Read more

Schematics

Foam Board

For the Block Diagram, the app buttons is supposed to be
M5 Stack Buttons

Main M5 Code First Part

Main M5 Code Second Part

Secondary M5 Code

Code

Main M5 Python Code

Python
from m5stack import *
from m5ui import *
from uiflow import *
import time
import unit
remoteInit()

setScreenColor(0x222222)
servo_0 = unit.get(unit.SERVO, unit.PORTC)
pir_1 = unit.get(unit.PIR, unit.PORTB)


rp_gauge2_data = None
hours = None



label0 = M5TextBox(0, 179, "Text", lcd.FONT_Default, 0xFFFFFF, rotate=0)
label1 = M5TextBox(1, 24, "hours set:", lcd.FONT_Default, 0xFFFFFF, rotate=0)
label2 = M5TextBox(72, 24, "Text", lcd.FONT_Default, 0xFFFFFF, rotate=0)




def gauge_2_callback():
  global rp_gauge2_data, hours, servo_0, pir_1 
  return rp_gauge2_data
lcd.qrcode('https://flow.m5stack.com/remote?id=undefined', 100, 1, 90)
while True:
  label0.hide()
  servo_0.write_angle(90)
  hours = 1
  label2.setText(str(hours))
  while hours <= 24:
    if btnA.isPressed():
      hours = hours + 1
      wait(0.2)
      label2.setText(str(hours))
    else:
      if btnB.isPressed():
        hours = hours - 1
        wait_ms(200)
        label2.setText(str(hours))
    if btnC.isPressed():
      break
  wait((hours * 10))
  speaker.tone(1800, 200)
  label0.setFont(lcd.FONT_Ubuntu)
  label0.setText('Time to take your medicine. Place your hand under the senser')
  rgb.setColorAll(0xff0000)
  wait(10)
  if (pir_1.state) >= 1:
    rp_gauge2_data = 1
    servo_0.write_angle(0)
    wait(10)
    servo_0.write_angle(90)
    label0.setText('Good Job')
    rgb.setColorAll(0x33cc00)
    wait(10)
    label0.hide()
  else:
    rp_gauge2_data = 0
  wait_ms(2)

Secondary M5 Python Code

Python
from m5stack import *
from m5ui import *
from uiflow import *
import unit

setScreenColor(0x222222)
rgb_0 = unit.get(unit.RGB, unit.PORTB)
rfid_2 = unit.get(unit.RFID, unit.PORTA)






image0 = M5Img(23, 156, "res/arrow_down.png", True)
image1 = M5Img(113, 156, "res/arrow_down.png", True)
image2 = M5Img(205, 156, "res/arrow_down.png", True)
label0 = M5TextBox(33, 121, "Go outside", lcd.FONT_Default, 0xFFFFFF, rotate=0)
label1 = M5TextBox(133, 121, "Need Water", lcd.FONT_Default, 0xFFFFFF, rotate=0)
label2 = M5TextBox(252, 121, "etc", lcd.FONT_Default, 0xFFFFFF, rotate=0)


while True:
  if btnA.isPressed():
    rgb_0.setColorFrom(1, 3, 0xff0000)
    speaker.tone(1800, 200)
  if btnB.isPressed():
    rgb_0.setColorFrom(1, 3, 0xffcc66)
    speaker.tone(1800, 200)
  if btnC.isPressed():
    rgb_0.setColorFrom(1, 3, 0x6600cc)
    speaker.tone(1800, 200)
  if rfid_2.isCardOn():
    rgb_0.setColorFrom(1, 3, 0x33cc00)
    speaker.tone(900, 200)
  wait_ms(2)

Credits

Saravanan Sylesh
1 project • 0 followers
Thanks to Vinz Koh Yong Le and UG Sachin.

Comments