Making Micro:bit Music

2017-06-07 Off By Admin

It’s been a couple of weeks and I confess I’m rusty. Riding high on a sea of ‘I feel confident about micro:bits now’ I was brought back down to earth when my colleague said ‘come on just program button A, you wrote about it in your blog post. How can you have forgotten?!’

So today I’m going to make music with my micro:bit and our sound cable which gives you the option to plug in headphones or speakers. Starting with something simple, I’m often singing ‘twinkle twinkle’ to my 18 month old, so yeah let’s let family life spill into work for a change 😉

The first thing to do is write the code. I open up a new Project and give it a name.

I then select the Music category from the menu and have a look at the choices. There is actually the facility to make something quite sophisticated which explains why one of my colleagues who is also a music graduate had so much fun coding Wagners ’Ride of the Valkyries’ last summer!

I think for this rather more basic project I’ll only need ‘playtone’ ‘rest’ and ‘set tempo’ blocks.

music blogSelecting ‘Input’ category from the menu and then ‘on button A’ (I’ve remembered now!). Drag and drop onto the project.

Then select ‘music’ category from the menu and ‘set tempo’ it automatically comes up as 120 bpm. No idea whether that will be ok, so I’ll leave it like that for now and see.

Next step is to drag and drop the play tone blocks. It automatically comes up as middle C but if you click onto it you get a keyboard visualisation which is rather nice (I have little bit of a music background). I need middle C anyway so that’s handy (I googled the notes I needed for the tune).

Pretty straight forward after that. Drag and drop tones and then change the length of the beat appropriate to what you are trying to play. I started with half beats for twinkle twinkle.

So after making four notes I feel it’s time for a little preview on the simulator. Press button A. OK…the notes are entirely indistinguishable. I think I need to slow the tempo down!! I change it to 60 but it could still do with being slower so I go for 40.

music blog 2

Once I have programmed the whole tune and checked the preview I’m good to download.  Even though I shouldn’t be surprised that it works, can’t help but feel thrilled and creative to hear my little tune playing away on my micro:bit!

< Click here to go to the previous micro:bit rookie blog post

Subscribe to our mailing list by filling in the information below and be the first

to here about new micro:bit rookie blog posts

[lab_subscriber_download_form download_id=3]