Create code.py
Initial code for the cat treat dispenser guide
This commit is contained in:
parent
ef9aa64c8f
commit
a435200285
1 changed files with 22 additions and 0 deletions
22
Cat_Treat_Dispenser/code.py
Normal file
22
Cat_Treat_Dispenser/code.py
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
import time
|
||||
import board
|
||||
import audioio
|
||||
from adafruit_crickit import crickit
|
||||
|
||||
print("Cat Feeder")
|
||||
|
||||
feed_servo = crickit.servo_1
|
||||
|
||||
# audio output
|
||||
cpx_audio = audioio.AudioOut(board.A0)
|
||||
f = open("activate.wav", "rb")
|
||||
wav = audioio.WaveFile(f)
|
||||
|
||||
while True:
|
||||
if crickit.touch_1.value:
|
||||
time.sleep(0.1)
|
||||
cpx_audio.play(wav)
|
||||
feed_servo.angle = 180
|
||||
time.sleep(0.2)
|
||||
feed_servo.angle = 0
|
||||
time.sleep(0.1)
|
||||
Loading…
Reference in a new issue