Jian Quanlee sheng kaiLeong Xuan HaoTeng Hang
Published

Hand Hygienics

Hand Hygienics aims to reduce spread of Covid-19 through contact.

IntermediateShowcase (no instructions)8 hours2,386
Hand Hygienics

Things used in this project

Story

Read more

Schematics

Block Diagram

Circuit Diagram

Fritzing

Circuit Diagram

Code

Code

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

setScreenColor(0x305161)
pir0 = unit.get(unit.PIR, (17,16))
tof0 = unit.get(unit.TOF, unit.PAHUB0)
tof1 = unit.get(unit.TOF, unit.PAHUB1)
earth5 = unit.get(unit.EARTH, unit.PORTB)


hide = None
usedsoap = None
washedhands = None
i = None
count = None


label0 = M5TextBox(0, 83, "Wash Your Hands", lcd.FONT_DejaVu56, 0xFFFFFF, rotate=0)
circle0 = M5Circle(297, 22, 10, 0xFFFFFF, 0xFFFFFF)
label1 = M5TextBox(203, 17, "Used Soap", lcd.FONT_Default, 0xFFFFFF, rotate=0)
label2 = M5TextBox(202, 44, "Soap Level", lcd.FONT_Default, 0xFFFFFF, rotate=0)
circle1 = M5Circle(297, 50, 10, 0xFFFFFF, 0xFFFFFF)
label4 = M5TextBox(13, 70, "For", lcd.FONT_DejaVu24, 0xFFFFFF, rotate=0)
label10 = M5TextBox(3, 19, "Text", lcd.FONT_Default, 0xFFFFFF, rotate=0)
label11 = M5TextBox(13, 200, "Fingers", lcd.FONT_DejaVu18, 0xFFFFFF, rotate=0)
label3 = M5TextBox(13, 33, "Soap Your Hands", lcd.FONT_DejaVu24, 0xFFFFFF, rotate=0)
label5 = M5TextBox(60, 58, "20", lcd.FONT_DejaVu40, 0xFFFFFF, rotate=0)
label6 = M5TextBox(120, 70, "Seconds", lcd.FONT_DejaVu24, 0xFFFFFF, rotate=0)
label7 = M5TextBox(13, 149, "Remeber To", lcd.FONT_DejaVu24, 0xFFFFFF, rotate=0)
label8 = M5TextBox(14, 179, "Scrub Your Hands", lcd.FONT_DejaVu18, 0xFFFFFF, rotate=0)
image0 = M5Img(203, 135, "res/step2.jpg", True)
label9 = M5TextBox(3, 2, "Text", lcd.FONT_Default, 0xFFFFFF, rotate=0)

from numbers import Number


def mainitems(hide):
  global usedsoap, washedhands, i, count
  if hide:
    circle0.hide()
    circle1.hide()
    label0.hide()
    label1.hide()
    label2.hide()
    label9.hide()
    label10.hide()
  else:
    circle0.show()
    circle1.show()
    label0.show()
    label1.show()
    label2.show()
    label9.show()
    label10.show()

def countdownitems(hide):
  global usedsoap, washedhands, i, count
  if hide:
    label3.hide()
    label4.hide()
    label5.hide()
    label6.hide()
    label7.hide()
    label8.hide()
    label11.hide()
    image0.hide()
  else:
    label3.show()
    label4.show()
    label5.show()
    label6.show()
    label7.show()
    label8.show()
    image0.show()

def CountDown():
  global hide, usedsoap, washedhands, i, count
  mainitems(True)
  countdownitems(False)
  label3.setText('Soap Your Hands')
  for i in range(20, 0, -1):
    if i == 20:
      rgb.setColorAll(0x990000)
      rgb.setBrightness(100)
    if i == 18:
      label8.setText('Rub Your Palms')
      image0.changeImg("res/step3.jpg")
      rgb.setColorAll(0xff0000)
    if i == 13:
      label11.show()
      label8.setText('Lather Between')
      image0.changeImg("res/step4.jpg")
      rgb.setColorAll(0x993300)
    if i == 8:
      label11.hide()
      label8.setText('Wash Fingernails')
      image0.changeImg("res/step8.jpg")
      rgb.setColorAll(0xff6600)
    if i == 5:
      label8.setText('Scrub The Back')
      image0.changeImg("res/step5.jpg")
      rgb.setColorAll(0xffff00)
    if i >= 10:
      label5.setText(str(i))
    else:
      label5.setText(str((str(' ') + str(str(i)))))
    wait(1)
  label3.setText('Rinse Your Hands')
  for i in range(10, 0, -1):
    if i == 10:
      label8.setText('Rinse Hands With')
      label11.setText('Water')
      label11.show()
      rgb.setColorAll(0x33ff33)
      image0.changeImg("res/step10.jpg")
    if i >= 10:
      label5.setText(str(i))
    else:
      label5.setText(str((str(' ') + str(str(i)))))
    wait(1)
  label11.hide()
  countdownitems(True)
  mainitems(True)
  setScreenColor(0x33cc00)
  label0.setText('Your Hands are CLEAN')
  label0.show()
  rgb.setColorAll(0x33cc00)
  wait(2)
  setScreenColor(0x336666)
  rgb.setBrightness(0)

def soapchecker():
  global hide, usedsoap, washedhands, i, count
  label10.setText(str(earth5.analogValue))
  if (earth5.analogValue) >= 500:
    circle1.setBgColor(0x33ff33)
  elif (earth5.analogValue) >= 100:
    circle1.setBgColor(0xff9900)
  if (earth5.analogValue) < 100:
    return False
  return True

def washing():
  global hide, usedsoap, washedhands, i, count
  while not washedhands:
    if btnB.isPressed():
      break
    if (tof0.distance) > 80 and (tof1.distance) > 80:
      label0.setText('Wash Your Hands')
    elif usedsoap and (tof0.distance) <= 80:
      CountDown()
      washedhands = True
    elif (tof1.distance) <= 80:
      usedsoap = True
    elif (tof0.distance) <= 80:
      label0.setText('USE SOAP')
      image0.show()
      if (tof1.distance) <= 80:
        usedsoap = True
    if pir0.state:
      count = 0
    else:
      count = (count if isinstance(count, Number) else 0) + 1
      wait_ms(100)
    if count == 50:
      washedhands = True
    label9.setText(str(count))
    statusupdate()

def statusupdate():
  global hide, usedsoap, washedhands, i, count
  if usedsoap:
    circle0.setBgColor(0x33ff33)
  else:
    circle0.setBgColor(0xff0000)



countdownitems(True)
while True:
  mainitems(False)
  usedsoap = False
  washedhands = False
  if (pir0.state) == 1:
    lcd.setBrightness(100)
    label0.show()
    if soapchecker():
      speaker.tone(1800, 200)
      label0.setText('Wash Your Hands')
      washing()
    else:
      label0.setText('Use the     next sink')
      circle1.setBgColor(0xff0000)
      rgb.setColorAll(0xff0000)
  else:
    label0.hide()
    lcd.setBrightness(0)
    usedsoap = False
    washedhands = False
    statusupdate()
  wait_ms(2)

Credits

Jian Quan

Jian Quan

2 projects • 0 followers
lee sheng kai

lee sheng kai

2 projects • 0 followers
Leong Xuan Hao

Leong Xuan Hao

1 project • 0 followers
Teng Hang

Teng Hang

1 project • 0 followers

Comments