O'Reilly logo

Raspberry Pi Projects for Kids - Second Edition by Daniel Bates

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

A real tune

So, we've had fun creating random tunes; now let's try making something a little more structured. Open a fresh workspace by clicking on one of the Workspace tabs underneath the Code Editor. This is where we'll create our new tune. You can switch back to your previous program any time by clicking on its tab.

In this section, we're going to build on the same piece of code, getting the sound we produce closer and closer to a tune you might know. How far will you get before you recognize the tune? A complete code listing is at the end of this chapter just in case you get stuck.

Here's the very first version of the code— you might recognize it already!

 play :G sleep 1 play :G sleep 1 play :G sleep 1 play :Eb sleep 1 play :Bb sleep 1 play ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required