Jo highVoltage Gingerbread Pond with CPX, Crickit & CircuitPython

Jo highVoltage made a Gingerbread Pond where a gingerbread skater spins in the middle when a button on the CPX is pressed.  A DC motor is under the pond and is attached to a skateboard bearing which is attached to a piece of PVC board that is cut in a circle.  Using CircuitPython the CPX/Crickit is programmed to make the motor turn causing the skater to “spin”.

 

The code is below:

from adafruit_circuitplayground.express import cpx
from adafruit_crickit import crickit
import time
import audioio
import board

motor_1 = crickit.dc_motor_1

wave_file = open(“jb.wav”, “rb”)
wave = audioio.WaveFile(wave_file)
audio = audioio.AudioOut(board.A0)

while True:
if cpx.button_a:
print(“button a was pushed”)
audio.play(wave)
pass
motor_1.throttle = -0.30
time.sleep(6)

if cpx.button_b:
audio.stop()

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s