Lesson 5

At this point, we have a pretty basic game of laser tag. From here on, we will be adding onto the code to make the tag unit do more things.


One way that we can add onto the laser tag unit is to add sound. To do that, we will add a piezo electric speaker. A piezo is a crystal that makes sound when you apply voltage to it. However, in order to make a sound, you need to send pulses of electricity to the piezo speaker (similar to how we send pulses to the infrared LED). Fortunately, there is a library for sending sounds to an arduino, called the tone library. Tone is already included in the arduino code, so we don't need to download it and tell our computer where the code is.

There are a few elements to sound. The one that we will focus on is pitch. Pitch is how high or low a sound is. You control the pitch of a sound by how fast you vibrate the piezo speaker. The faster you send electrical pulses to it, the faster it will vibrate and the pitch will sound higher. We are going to change what pitch of a sound the arduino makes when you send a tag, receive a tag, can not tag and are out.

And now, on to Lab 5, where we will learn how to hook up a piezo to the arduino.

Leave a Reply

Your email address will not be published. Required fields are marked *