Hackster is hosting Hackster Holidays, Ep. 6: Livestream & Giveaway Drawing. Watch previous episodes or stream live on Monday!Stream Hackster Holidays, Ep. 6 on Monday!
Pang Yu TingCher AnnK ZAndrew
Created January 25, 2021

Hamster Project

Cute Useful Tracks that limit no. of people entering any transport

Hamster Project

Things used in this project

Hardware components

M5Stack FIRE IoT Development Kit
×1
TOF Sensor distance sensor
×1
PIR Unit
×1
PA Hub
×1
Grove hub
×1
RGB Unit
×1
wires
×1

Story

Read more

Schematics

Our Circuit Diagram

The Circuit Diagram
File missing, please reupload.

Our Poster and Item display

Our board showcase

The Circuit Diagram On Fritz

Our powerpoint presentation

Enjoy :) !

Our Video Presentation

Press the link to watch our video
https://youtu.be/4pJQ3UhxqWI

Code

CuteUsefulTracker.py

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

setScreenColor(0x222222)
pir5 = unit.get(unit.PIR, unit.PORTB)
pahub3 = unit.get(unit.PAHUB, unit.PORTA)
rgb6 = unit.get(unit.RGB, unit.PORTB)
tof5 = unit.get(unit.TOF, unit.PAHUB2)
rfid0 = unit.get(unit.RFID, unit.PAHUB3)
servo4 = unit.get(unit.SERVO, (13, 5))


people = None
seats = None


label6 = M5TextBox(99, 200, "Press for sanitizer", lcd.FONT_Default, 0xFFFFFF, rotate=0)
circle4 = M5Circle(0, 112, 15, 0xFFFFFF, 0xFFFFFF)
circle5 = M5Circle(322, 112, 15, 0xFFFFFF, 0xFFFFFF)
label0 = M5TextBox(28, 97, "Number of people on board :", lcd.FONT_Default, 0xFFFFFF, rotate=0)
label1 = M5TextBox(28, 125, "Space available : ", lcd.FONT_Default, 0xFFFFFF, rotate=0)
label2 = M5TextBox(28, 155, "Card UlD :", lcd.FONT_Default, 0xFFFFFF, rotate=0)
label3 = M5TextBox(236, 97, "Text", lcd.FONT_Default, 0xFFFFFF, rotate=0)
label4 = M5TextBox(235, 125, "Text", lcd.FONT_Default, 0xFFFFFF, rotate=0)
label5 = M5TextBox(224, 155, "Text", lcd.FONT_Default, 0xFFFFFF, rotate=0)
title0 = M5Title(title="Welcome To kawaii Transport", x=55, fgcolor=0xFFFFFF, bgcolor=0xff2d00)
circle0 = M5Circle(73, 46, 5, 0xFFFFFF, 0xFFFFFF)
circle1 = M5Circle(238, 46, 5, 0xFFFFFF, 0xFFFFFF)
line0 = M5Line(M5Line.PLINE, 141, 57, 161, 69, 0xFFFFFF)
line1 = M5Line(M5Line.PLINE, 161, 69, 180, 58, 0xFFFFFF)
circle2 = M5Circle(58, 238, 25, 0xFFFFFF, 0xFFFFFF)
circle3 = M5Circle(259, 238, 25, 0xFFFFFF, 0xFFFFFF)
label7 = M5TextBox(28, 175, "Contact tracing purpose", lcd.FONT_DefaultSmall, 0xFFFFFF, rotate=0)

from numbers import Number




people = 0
seats = 5
label4.setText(str(seats))
label3.setText(str(people))
while True:
  if (tof5.distance) <= 150:
    people = (people if isinstance(people, Number) else 0) + 1
    seats = (seats if isinstance(seats, Number) else 0) + -1
    label4.setText(str(seats))
    label3.setText(str(people))
    speaker.sing(294, 1)
    rgb6.setColor(1, 0x33ff33)
    label5.setText(str(rfid0.readUid()))
    wait(1)
    rgb6.setColorFrom(2, 3, 0xffffff)
  elif (pir5.state) == 1:
    people = (people if isinstance(people, Number) else 0) + -1
    seats = (seats if isinstance(seats, Number) else 0) + 1
    label4.setText(str(seats))
    label3.setText(str(people))
    speaker.sing(156, 1)
    rgb6.setColor(3, 0xff0000)
    rgb6.setColorFrom(1, 2, 0xffffff)
    wait(1)
  else:
    people = (people if isinstance(people, Number) else 0) + 0
    seats = (seats if isinstance(seats, Number) else 0) + 0
    rgb6.setColor(2, 0xff6600)
    rgb6.setColor(3, 0xffffff)
    rgb6.setColor(1, 0xffffff)
    wait(1)
  if people >= 5:
    line0.setSize(140, 62, 160, 50)
    line1.setSize(160, 50, 179, 63)
    rgb.setColorAll(0xff0000)
  elif people >= 3:
    line0.setSize(134, 60, 184, 60)
    line1.setSize(134, 60, 184, 60)
    rgb.setColorAll(0xff6600)
  elif people <= 2:
    line0.setSize(141, 57, 161, 69)
    line1.setSize(161, 69, 180, 58)
    rgb.setColorAll(0x33ff33)
  else:
    rgb.setColorAll(0x66ffff)
  if btnA.isPressed():
    speaker.sing(889, 1)
    label6.setColor(0xff0000)
    wait(1)
    label6.setColor(0xffffff)
  wait(1)
  wait_ms(2)

Credits

Pang Yu Ting

Pang Yu Ting

1 project • 1 follower
Cher Ann

Cher Ann

1 project • 0 followers
K Z

K Z

1 project • 2 followers
Andrew

Andrew

1 project • 2 followers

Comments