Musical tune

Step 1 /5


CodeBug can play music from it’s legs, when connected to a buzzer or speakers, with just a few simple blocks.

Step 2 /5

Setting up music leg

First you need to set leg 0 into music mode.

  • Click the blue cog on the start block and tick the checkbox next to leg 0 input/output, click the cog again to close this window.

  • Now click the leg 0 drop down that has appeared on the start block and select music (PWM) output.

Step 3 /5

Setting tempo

For our tune to sound right, we need to set the beat (tempo).

  • From the Music menu select the set tempo block and snap it to the start block.

Step 4 /5

Looping your music

You will want your tune to loop so it will play again and again.

  • From the Loops menu, drag in a repeat while true loop and snap it below your set tempo block.

Step 5 /5

Creating a tune

Now you can create your tune.

  • From the Music menu, drag in 8 play tone blocks and snap them one after the other inside your repeat while loop.

  • Click on the letter drop downs in your play tone blocks and change the letters so they read C for the first block, D for the second then E, F, G, A, B, C7.

  • Click play on the emulator and make sure your computer speakers are turned on.

You should be able to hear your tune. This is the scale of C!