monkeypet
Posts: 2
Joined: Thu Oct 09, 2014 4:20 pm

Small animal autofeeder

Sun Nov 11, 2018 5:01 pm

My daughter's 7th grade project, a Pet Auto Feeder. A stepper motor mounted directly to the pillbox which spins the lid controlled by a Rapberry Pi with a PiFace IO extension board. More details in comments. Easy for other kids to try.

My original post on Twitter: https://twitter.com/MonkeyPetKing/statu ... 9048760320

Parts List:
  • 1. kuman Stepper Motor for Arduino 28BYJ-48 ULN2003 5V Stepper Motor + ULN2003 Driver Board + Better Dupont Wire 40pin Male to Female Breadboard Jumper Wires Ribbon Cables K67 http://a.co/d/84fkTT5
    2. PuTwo Pill Box Pill Organizer 7 Day Pill Case with Spinning open design
    http://a.co/d/0bnNoCK
    3. Rapberry Pi with a PiFace IO extension board
Wiring Diagram
pet-autofeeder-wiring.png
pet-autofeeder-wiring.png (192.44 KiB) Viewed 203 times
Code: pastebin.com/fAuB2icN

Code: Select all

import pifacedigitalio
import time

piface = pifacedigitalio.PiFaceDigital()

control_pins = [7,6,5,4]

halfstep_seq = [
  [1,0,0,0],
  [1,1,0,0],
  [0,1,0,0],
  [0,1,1,0],
  [0,0,1,0],
  [0,0,1,1],
  [0,0,0,1],
  [1,0,0,1],
]

# FULL SPIN 512
def turn(ii):
 for i in range(ii):
  for halfstep in range(8):
    for pin in range(4):
      x = halfstep_seq[halfstep][pin]
      piface.output_pins[control_pins[pin]].value = x
    time.sleep(0.00001)

 # Turn Pins off
 for x in range(7,-1,-1):
    piface.leds[x].turn_on()
    #piface.leds[x].turn_off()

now_plus_1 = time.time() + 1*60
while True:
  if piface.input_pins[0].value == 1:
    turn(16)
  elif piface.input_pins[1].value == 1:
    turn(64)
  elif piface.input_pins[2].value == 1:
    turn(512)
    now_plus_1 = time.time() + 1*60
  elif time.time() > now_plus_1:
    turn(64)
    now_plus_1 = time.time() + 1*60

Return to “Automation, sensing and robotics”