Let's Make Some Noise

Sound has always been an important feature of the Scribbler robot. The ability to easily create a variety of sounds, using built-in hardware, gives the Scribbler robot much of its unique and lovable personality. 


Did You Know?

The sound design for robots in movies helps give the robots or computers their on-screen personality. Think about the sounds of Optimus Prime in Transformers - heroic and strong; or the friendly and endearing sounds of R2-D2 from Star Wars, and WALL-E from WALL-E. Sounds really do matter.

There are several YouTube videos about the sound design for WALL-E that may give you a better appreciation for the process. Take a look when you have some extra time. You just may learn something neat!

The sounds you choose for your S3 robot are also important. Humans very strongly associate sound with meaning. Certain sounds or music in your S3’s program can be used to provide something simple like feedback on sensor conditions, or they could be used to mimic human emotional states like sadness or happiness.


 

The S3 GUI Program Maker

All of Parallax’s Scribbler robots (original blue (1), red (2), and green (3)) can also be programmed with a simple-to-use GUI Software (GUI - pronounced gooey - stands for Graphical User Interface). One of its fun and useful features is the “sound tile.” All versions of the GUI run on Windows operating systems only.

In the GUI, you can make tunes, trumpet sounds, piano notes, sound effects, Morse code, phone tones, and more. The tempo of playback, and note duration can also be controlled. This resource is fully available to Windows users with the Scribbler S3 GUI Software download.

BlocklyProp requires more of a hands-on approach when working with sound creation blocks. The rest of this tutorial will focus on using BlocklyProp to create sounds with your S3 robot.

 

Uh Oh!

One sound that seems to be universally recognizable is the “uh oh” sound. Without any visual indication, we can intuitively understand something has happened simply by hearing this two-tone sound combination. Since everyone runs into problems on occassion (even robots), let's learn how to program your S3 to make the "uh oh" sound.

In BlocklyProp, we will use the play tone block, found in the ACTIONS > SOUND category, to play a single tone. You may notice that you have the option of setting a second tone, located just underneath the first one. For this program, we will leave the second tone value at 0 (zero). This play tones block is defined by setting frequency (tone in Hz) and duration (time in ms). The wait block is for the "rest" or silent pause (in ms) between the tones. A volume setting is also on this block, and normally it has a numerical value where you can just type a number between 0 and 100. Here, we have introduced a different way to set volume: with a variable.

  • Start a new project, name it Uh Oh and snap together the BlocklyProp code shown below:

By setting the volume (0-100) using a number value block attached to a set variable block - we control it everywhere it appears in this program. Here, we used the set variable block first to initialize our "vol" variable with a value of 40. Now, anytime you insert a use variable block into your program, every "vol" variable block will actually behave as though you typed in the number 40.

Hint: If using the set variable block, to name a variable (click on "Item" and then on "Rename variable..." in the dropdown). The name you choose will automatically appear in the use variable block dropdown menu. Also, if you create a variable using the set variable block, its matching use variable block will appear in the VARIABLES menu block list.

In short programs like this one, replacing a typed-in number with a variable isn't always necessary, but it can save a lot of time and simplify troubleshooting in larger, longer programs. Why do you think this is?

  • If you are not yet comfortable with the set variable and use variable blocks (below), spend some time learning them before moving on.

  • Save, compile, load to EEPROM, and run the program to play the "uh oh" sound.

Now that you've heard it, you will understand how this sound conveys an error or problem without a written message or warning light. That is how powerful sounds are; we can intuitively understand the message without explanation. You have just created a sound that can be used in any BlocklyProp program and with your S3 to indicate a problem! This, and other sounds, can be extremely valuable tools in troubleshooting or autonomous navigation.

 

A "Major" Accomplishment

In the S3 Demo programs, music was used along with other features to make the programs more appealing and entertaining. We will now take a look at the play note block, BlocklyProp’s other block for creating sound. You will find it in the ACTIONS > SOUND category.

Not familiar with musical notes or vocabulary? Read "A Lesson on Sheet Music", part of a PBASIC-language project here on Learn called "Playing Sheet Music with a Piezospeaker".

  • Start a new project, name it "S3 Piano C Maj Scale" and snap together the BlocklyProp code shown below.  (Note: using the drop down windows, you can choose the octave, note, count value, and volume. There are too many options to list here for each. Try experimenting with them to learn what they each do.)

  • Save, compile, load to EEPROM, and run the program.

It doesn’t get much easier than that! With this block you can construct almost any simple tune.

The sound of any given of musical instrument can be represented by its frequency in Hertz (Hz) as used in the play tone block. If you really want to dive into the deep end, you can use the play tone block combined with any number of great online resources to create many fascinating musical programs. This will be covered in future tutorials and BlocklyProp projects.

 

Try This!

  • Using the code in the "A Major Accomplishment" section above as a starting point, build a BlocklyProp program that plays the ascending scale from middle C to tenor C and then descending from tenor C to middle C. Insert a pause between the up and down scales.

Special thanks to Parallax friend Whit Stodghill for his assistance in writing, editing, and testing material for these S3 tutorials.