Bhavithiranidriszmy
Published © MIT

EDU:BIT Cat Feeder | MicroPython

Guide to program Cat Feeder with EDU:BIT (project kit for micro:bit) using MicroPython

BeginnerFull instructions provided30 minutes717
EDU:BIT Cat Feeder | MicroPython

Things used in this project

Hardware components

EDU:BIT
Cytron Technologies EDU:BIT
×1

Software apps and online services

Mu
Python Editor for micro:bit

Story

Read more

Code

Cat Feeder

Python
This tutorial's full code
from edubit import *

sets_servo_position(S1, position=140)                   # close the bottle
display.show(Image.HAPPY)                               # show happy icon
Activate = 0
while True:
	init()                                              # initialize EDU:BIT
	if button_a.is_pressed():                           # button A pressed  / Manual control
	    sleep(500)
	    sets_servo_position(S1, position=140)
	    sleep(300)
	    sets_servo_position(S1, position=95)            # open the bottle
	elif button_b.is_pressed():                         # button B pressed  / Automatic control
	    Activate = 1
	
	if Activate == 1:
	    if is_IR_sensor_triggered():                    # IR sensor detects object
	        display.show(Image.YES)                     # show yes icon
	        sleep(500)
	        sets_servo_position(S1, position=140)
	        sleep(300)
	        sets_servo_position(S1, position=95)
	        sleep(60000)                                # wait for one minute for the cat to finish the food
	        display.show(Image.NO)                      # show no icon
	

Credits

Bhavithiran

Bhavithiran

16 projects • 7 followers
idriszmy

idriszmy

1 project • 0 followers

Comments