element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
microbit
  • Learn
  • Learning Center
  • STEM Academy
  • microbit
  • More
  • Cancel
microbit
micro:bit Blog 10 BBC micro:bit Projects in 10 Days: Day Three - Making Music
  • Blog
  • Forum
  • Documents
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join microbit to participate - click to join for free!
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: jlucas
  • Date Created: 3 Jun 2016 11:34 AM Date Created
  • Views 5930 views
  • Likes 20 likes
  • Comments 9 comments
  • intermediate micro:bit projects
  • micro:bit
  • bbc micro:bit
  • microbit
  • intermediate_microbit_projects
  • bbc microbit
  • ten bbc micro:bit projects
  • bbc_micro:bit
  • 10projects10days
Related
Recommended

10 BBC micro:bit Projects in 10 Days: Day Three - Making Music

jlucas
jlucas
3 Jun 2016

About this project

 

This project shows pupils how to introduce music and sound effects into their BBC micro:bit projects by teaching them how to write the tune 'Happy Birthday' using blocks of code.

 

What you'll need

 

1 x BBC micro:bit

1 x Micro USB

1 x Computer or tablet

2 x AAA Batteries & Battery Holder

1 x mini speaker or similar (optional)

2 x sets of crocodile clips (optional)

 

 

Project walkthrough

 

  • Go to the BBC micro:bit website, click 'create code' and begin a new Microsoft Block Editor project.

 

  • Click 'Music' in the left-hand command menu and select the tile that reads 'Play tone (Hz) [C] for (ms) [1] beat (ms)'. This tile tells your BBC micro:bit to play a specific note, for anything from 1/16 to a full beat.

 

  • Right click on this cool and select 'duplicate' to clone the tile. Repeat until you have six identical tiles. This saves you from dragging and dropping a new tile from the command menu for every individual note.

 

  • Attach the six tiles together, and change the notes until they form the first stanza of 'Happy Birthday', like so...

image

  • You may also want to change the '[1] beat (ms)' to [1/4] beat (ms) as indicated to speed up the song.

 

  • Add a 'pause' tile from the basic commands menu, and set it to 500 milliseconds.

 

  • Duplicate a further six 'play tone (Hz)...' tiles and connect them to the 'Pause' tile to create the second part of the song.

 

  • The notes for this stanza are: C, C, D, C, G, F

image

  • Add another 500 millisecond pause tile, then duplicate another seven 'Plat tone (Hz)...' tiles for the third part of the song.

 

  • The notes for this section should be: C, C, C, A, F, E, D.

image

  • Add another 500 millisecond pause tile followed by six 'play tone (Hz)...' tiles for the final part of the song.

 

  • The last set of notes should be: A, A, B, F, G, F

image

  • You've now mastered the basics of writing songs for the BBC micro:bit! Click 'run' to test the tune out on the emulator.

 

  • To play the song on your BBC micro:bit, you'll need to connect the device to a suitable speaker system. A simple general purpose mini speaker should be sufficient.

 

  • Before attaching the BBC micro:bit to the speaker, you might want to wrap your code in a function telling the device to only play the tune when button A is pressed, like so:

 

image

 

  • When you're satisfied, click 'compile' to download your script and transfer to your device.

 

  • To connect your BBC micro:bit to a speaker, use your crocodile clips to attach the positive and negative inputs on the speaker to the 0 and GND pins on the device. It doesn't matter which way round they're connected.

 

image

 

  • Finally, push the A button, and your newly composed jingle should start playing!

 

Once your pupils understand how to create simple songs, encourage them to apply their new skills to previous projects. Can they figure out how to add a sound effect when their countdown timer reaches zero, for example? Let us know how your pupils get on in the comments section below...

  • Sign in to reply

Top Comments

  • jlucas
    jlucas over 9 years ago in reply to shabaz +5
    Hi shabaz The BBC micro:bit doesn't contain onboard audio components, so you'd have to connect it to something. A general-purpose mini speaker should suffice for this kind of project. I've amended the…
  • shabaz
    shabaz over 9 years ago +3
    That's awesome - I had no idea it had this music/tones capability in the editor. Did you have to connect up earphones (I noticed on some website it is possible to connect earphones using croc clips to…
  • NigelB
    NigelB over 7 years ago +3
    This is great - the links, especially to the BBC website in jlucas comment above are really useful, and reveals some interesting extra information (such as built-in tunes, and the use of keys other than…
Parents
  • vandia
    vandia over 8 years ago

    I might look at getting one of these, just to make a video of it doing the Mario Bros theme!
    ...if you do a TestDrive thing of this, please let me know? I have a few ideas for videos to post lol!

    • Cancel
    • Vote Up +2 Vote Down
    • Sign in to reply
    • More
    • Cancel
Comment
  • vandia
    vandia over 8 years ago

    I might look at getting one of these, just to make a video of it doing the Mario Bros theme!
    ...if you do a TestDrive thing of this, please let me know? I have a few ideas for videos to post lol!

    • Cancel
    • Vote Up +2 Vote Down
    • Sign in to reply
    • More
    • Cancel
Children
No Data
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube