11

(Marcin) #1

Arduino programming: Sound, envelopes, and interrupts


SCHOOL OF MAKING


Arduino programming:


Sound, envelopes,


and interrupts


Build a simple sound generator that allows you to control


the pitch or timbre of the sound over time


e spent the previous couple
of tutorials putting some
of our programming theory
into action, creating a
simple game where the
player flew a craft through
an ever-decreasing tunnel. In this tutorial, we’re
returning to practical theory, but we’re going to
explore some ideas that could be used to expand
a game, and generally make your programming
life easier. These ideas are going to be based on
generating sounds using something we’ve not yet
covered – interrupts.
Sound is obviously important, not just
for games, but for all kinds of different
projects. Audio feedback can replace

Graham Morrison


@degville

Graham is a veteran
Linux journalist who is
on a life-long quest to
find music in the perfect
arrangement of silicon.

Right
You can use almost
anything you have
around to generate
sound from some
input trigger with
an Arduino

W


the need for a visual element, such as a screen,
and sound can be more intuitive and accessible.
You don’t need to explain the UI of an audible alert
or alarm, for example, and if the sound is annoying
enough, it can demand your attention in ways an
on-screen notification can’t. But the best thing
about sound is that it’s incredibly cheap and easy to
implement. Even a basic Arduino with no specific
Free download pdf