
Fellow MU-tant (geddit?) Les Pounder, has a
stonking project
for Halloween trick-or-treating, made with an
Adafruit Circuit Playground Express
board, CircuitPython and Mu. It’s too cool not to re-blog! The video below
shows you all you need to know.
Regular readers will know that Les’s projects are fun, playful, cheap to build
and easy to assemble. Furthermore, not only has Les a gift for thinking up
such stonking project ideas, but he’s a virtuoso mentor when it comes to
explaining how to recreate such projects for yourself. Where am I going with
this?
If you are a teacher, Les’s blog is a GOLDMINE of ideas, resources and
projects for use in your own classroom.
In this case, the parts are all from PoundLand
(no relation), and the digital assets are an audio file and the following
short Python script:
import audioio
import board
from digitalio import DigitalInOut, Direction, Pull
# enable the speaker
spkrenable = DigitalInOut(board.SPEAKER_ENABLE)
spkrenable.direction = Direction.OUTPUT
spkrenable.value = True
# make the input trigger
trigger = DigitalInOut(board.A1)
trigger.direction = Direction.INPUT
trigger.pull = Pull.DOWN
#Create a function to play audio files.
def play_file(filename):
print("Playing file: " + filename)
wave_file = open(filename, "rb")
with audioio.WaveFile(wave_file) as wave:
with audioio.AudioOut(board.A0) as audio:
audio.play(wave)
while audio.playing:
pass
print("Finished")
#Main Loop, press a button...make noise!
while True:
if trigger.value:
play_file("sound.wav")
What are you waiting for?




近期评论