Chapter 5
Adding Sound and Motion to Your Arduino Projects
IN THIS CHAPTER
Making sound with a speaker
Using the TONE command to create frequencies
Using an MP3 shield to play sound effects and music
Creating motion with a servo
In this chapter, you learn how to work with devices that add sound and motion to your Arduino projects. To create sound, you can add a speaker to create audible output tones. This is useful in situations where your Arduino program might need to get someone’s attention or when you want to create a sound effect. For more realistic sound effects and music, you can add a shield to your Arduino to play MP3 files that are stored on a micro-SD card. To create motion, you can add a very useful device called a servo, which lets you control mechanical motion with an Arduino program.
Using a Speaker with an Arduino
An inexpensive way to add sound to an Arduino project is to simply add a small 8 Ω speaker to a digital output pin. You can then rapidly alternate the pin between HIGH and LOW to create a square-wave signal on the pin, which the speaker will render as ...
Get Electronics All-in-One For Dummies, 3rd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.