// Copyright 2007, Sandeep Gangadharan // For more free scripts go to http://www.sivamdesign.com/scripts/

Car Tunes with Code Car

 
 

Take your horn beeps to the next level with more tones and tunes! Beep the horn on Code Car automatically in song sequences.

Code

The code below already works and is ready to upload! Upload the code to Code Car and see what happens. Then, you'll 'take apart' the code to learn what each piece of the program does.

Walkthrough Videos

Watch the videos for line-by-line explanation of how the example program works. Then you'll be ready to make some changes of your own!

Challenges

How many can you complete? Change the code according to the challenges below. Upload your code to see the effect when you're finished. Complete a challenge? Check it off the list!

Use the internet to find a table that converts hertz to musical notes. Can you make some of the following songs?



Concepts

These are the new code concepts covered in this example program. To become a great coder, read through these concepts to learn new vocabulary.

New Concept: Repetition and Patterns (Again)

The challenges on this lesson are very open-ended, and they can get long. Some students have written hundreds of lines of code to create their favorite song from a movie or video game. Most songs, like most code, is made up of patterns that repeat or at least use the same tools (notes and pauses, for example) to create something unique. So while it may seem intimidating to look at a huge block of code, remember to try to pick out the patterns and deconstruct the program into its pieces.

Quiz

If you're having trouble, try to run an experimental program or look at the example code to help you find the answer.

If you type:
tone(2,500);
noTone(2);
how long will you hear the tone of 500 hertz?