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()