Sound with micro:bit

Sound with micro:bit

MicroBlocks tarafından

Boards
Kartlar:

micro:bit

Component/s
Bileşenler:

Yok

Setup

Connect the micro:bit to MicroBlocks and add the Tone library.

Problems? See Get Started.

Play a note

Connect a piezo speaker or headphones to pin 0 using alligator clips or an extension board.

Click the play note block to play a note. Experiment with the note, octave, and duration to make different notes.

script

Put play note blocks together to make tunes.

script

Select open and choose the music folder to see more examples of songs!

Use a variable to control speed

Using a variable for note durations lets you change the speed. Click on the variables category to create a new variable.

-> ->

Add a copy of the beat variable to each note block.

script

Now you can change the playback speed by changing the value of beat. What happens when you set beat to 200?

Use the repeat block for parts of a song that repeat.

script

Make a Sound Effect

Want to make a cool sound effect? Try this!

script

How does this work?

The play midi key block plays the note for the given piano key. Piano keys are numbered from lowest to highest, counting both white and black keys. Middle C is always 60. The lowest key on an 88 key piano is 21 and the highest is 108. MIDI (musical instrument digital interface) is an industry standard created to control keyboards and other electronic instruments.