Bitbloq - die Weboberflächer für Programmiereinsteiger


Have you ever wanted to have more fun with your robots and inventions? Did you know you can easily make melodies with the buzzer? Music is food for the soul… as long as you´re not out of tune! Today we will show you a few tools and resources for creating melodies and even instruments, using nothing more than bitbloq and your buzzer. Want to find out how? Then connect to earth and let´s get started!



bitbloq and the buzzer blocks

We have already looked at the functioning of the  buzzer blocks. Can you remember how they work?

On the basic block you will find seven notes from C to B (in the scale of C major). These notes correspond to the central scale on the piano or the recorder.


But what happens when you want to write a melody with accidentals (b flat or # sharp notes)?

In the advanced block, you tell the buzzer which frequency to use, or in other words, which note to play. This is really useful for playing special notes which can be used to make more sophisticated tunes.

Now let´s leave the theory to one side and start practising!

Old MacDonald had a farm… Making our first melody

Now we will to play our first tune using the buzzer. It´s a very famous song… You will know it for sure!


To do this, you will need to use the basic buzzer block and enter the following notes:



As you can see in the program, we have used a duration of 400 ms for the crotchet notes, so the minim notes will therefore be double: 800 ms. For the last note, which is dotted and increases its duration by half the original value, we have set a time of 1200 ms (800 ms + 400 ms).
However, creating tunes in this way can be confusing as there are so many notes and the program ends up being really long. So why not take advantage of  the functions  to make it more organised?

Have a look at the next program:

Clica en la imagen para ampliar

Clica en la imagen para ampliar

We have used four functions to write the notes of each bar separately. This makes it a whole lot easier to write melodies using a stave. What´s more, if you make a mistake, you will quickly realise which stave the note is on and you will be able to change it easily.


Using special notes

It´s fun to make melodies like this, but what if we wanted to play a tune which has flat or sharp notes? When you need to use these kind of notes, the only way to do it is by using the advanced block and entering the frequency. But don´t worry! You don´t need to write down or remember every frequency for every note. Below you will see a tool for translating the notes to frequencies which will help you create your advanced melodies more easily.


Translate musical notes to frequencies

Write a series of notes   


You can enter the notes as “do”, “re”, “mi”, etc… or you can use English musical notation. You can also make a note higher or lower by writing a number at the side of it. For example, middle C on the piano would be “C4″.


We can play a tune using different frequencies. Look carefully at how we would create the program:

Clica en la imagen para ampliar

SpongeBob SquarePants!

As you can see, we only played the notes that would be possible on the advanced buzzer. We have also defined global variables to determine the length of minims, crotchets and quavers, which makes it a lot easier to the understand the melody, extend and modify it.


Online tunes

You can find loads of ready-made tunes on the internet which can be played on Arduino together with your buzzer. If you can find the tune you are looking for, search for the score instead. Then you can create it yourself and share it with the community! You can easily pass the melodies to bitbloq if you want. Simply read the tone() function, qwhich makes the buzzer sound in Arduino language and enter the values in the advanced block as follows: bloque_arduino_bitbloq

The first element of the tone() function is the pin that we have connected to the buzzer (9), the second is the frequency (261) and the third is the duration (400).
We have also collected and prepared a series of melodies on bitbloq for you to try out. You will find them under the Downloads section, which we will keep updating as we go along. Have a go at making your own melodies! We accept donations!
You can now create as many tunes as you like! You will find loads of scores in music books or online, and you will also find the buzzer frequencies or the melody on Arduino. Or why not have a go a making your own instrument? How about making a robot that can beat a drum? With a little practice, you´ll soon see what a great composer you are! Music maestro please!