Cregan HORussell LeeAymanKynaston
Published

Automated Animal Feeder

An automated animal feeder that will make feeding farm animals more convenient for farmers

BeginnerShowcase (no instructions)5 hours371
Automated Animal Feeder

Things used in this project

Story

Read more

Schematics

schematics diagram

a simple diagram to show how the project works

Code

Animal feeder code

Python
Python code for the animal feeder
from m5stack import *
from m5ui import *
from uiflow import *
import time
import unit

setScreenColor(0x222222)
pahub_0 = unit.get(unit.PAHUB, unit.PORTA)
pbhub_0 = unit.get(unit.PBHUB, unit.PAHUB5)
servo_0 = unit.get(unit.SERVO, unit.PORTB)
tof_0 = unit.get(unit.TOF, unit.PAHUB0)


distance = None



label0 = M5TextBox(15, 33, "Distance:", lcd.FONT_DejaVu24, 0xFFFFFF, rotate=0)
label1 = M5TextBox(172, 17, "T", lcd.FONT_DejaVu40, 0xFFFFFF, rotate=0)
label2 = M5TextBox(256, 33, "CM", lcd.FONT_DejaVu24, 0xFFFFFF, rotate=0)
label3 = M5TextBox(134, 97, "Text", lcd.FONT_DejaVu24, 0xFFFFFF, rotate=0)
label4 = M5TextBox(134, 164, "Text", lcd.FONT_DejaVu24, 0xf70505, rotate=0)




while True:
  distance = int(((tof_0.distance) / 10))
  label1.setText(str(distance))
  label3.setText(str(pbhub_0.analogRead(0)))
  if distance > 18 and (pbhub_0.analogRead(0)) < 570:
    label4.setText('Dispensing')
    wait(3)
    servo_0.write_angle(90)
    wait(1)
    servo_0.write_angle(0)
    rgb.setColorAll(0x33cc00)
  elif distance > 18 and (pbhub_0.analogRead(0)) > 570:
    label4.setText('Empty but animal is near')
    rgb.setColorAll(0xff0000)
    else:
    label4.setText('Full')
    rgb.setColorAll(0x000000)
wait_ms(2)

Credits

Cregan HO
1 project • 2 followers
Russell Lee
0 projects • 1 follower
Ayman
0 projects • 0 followers
Kynaston
1 project • 0 followers

Comments