BBC Microbit
Objective of the lesson Use Block Editor to make a Beatbox All of you will: Make Pin 0 produce a beating sound Most of you will: Make a button control the tempo Some of you will: Use light to control the beatbox
Beatbox We will use the Pins on the Microbit to make a sound when we touch them Add an ‘on P0 pressed’ block Add a ‘while True’ block so that the code will continue to play (once the P0 pin is pressed the condition stays true)
Add in a note a beat length and a pause between notes Add an on button A pressed and change the tempo
Challenge Can you program P1 and P2 to play different notes Can you program button B to slow down the temp
Using light to control the music Add an ‘on buttonA pressed do’ loop Add a variable and call it sound. Set this variable to equal the ‘light level’
Add an ‘if do’ loop. Make it so that if the light level is less than 25 Make it then play a ring tone C
Challenge Add in ‘else if’ statements and make it so that if the light variable is less than 50, it plays note D Carry on so that if the light variable is less than 100, it plays note E; if the light variable is less than 150, it plays note F; if the light variable is less than 180, it plays note G; else it plays note A. Changing the light level should now make the microbit play a tune
Answers