case 01 Music Machine
4. case 01 Music Machine#
Get to know the ADKeypad.
Make something with ADKeypad.
Make something with Buzzer.
1 x BBC Micro:bit Board
1 x Micro USB cable
1 x ElecFreaks Micro:bit Breakout Board
1 x Octopus Passive buzzer Brick
1 x Octopus ADKeypad
Tips: If you want all components above, you may need ElecFreaks Micro:bit Tinker Kit
4.4. How to Make#
After connecting one end of the USB cable to your computer, connect the other end to the micro:bit as shown in the picture below.Then connect the side of the micro:bit where the pins are located to the breakout board.
Plug in the buzzer Brick to Pin 0. Plug in the ADKeypad to Pin 2. Make sure the colour of the wire of the buzzer and the ADKeypad follows the colour of the pins on the breakout board.
Click on Advanced in the Code Drawer to see more code sections.
To code for our extra kit components (the ADKeypad and the buzzer), we have to add a package of code.Look at the bottom of the Code Drawer for “Add Package” and click it. This will open up a dialogue box. Search for “tinker kit” and click on it to download this package.
Note: If you get a warning telling you some packages will be removed because of incompatibility issues, either follow the prompts or create a new project in the Projects file menu.
Next, let’s create a conditional statement as shown in the picture. This ‘if-then’ block of code is under the code section “Logic” of the code drawer.The code shown below means that when button A is pressed on the ADKeypad while the ADKeypad is plugged in at pin P2 of the breakout board, the buzzer will play a sound of 175 hertz.
Since there are 5 buttons, we need to code 5 similar conditional statements. Each button controls a sound of a particular pitch. So press each buttion, we will get sounds of different pitches.
If you don’t want to type these code by yourself, you can download it directly from the link below:
Or, you can download from the page below:
Success! Now you have your own Micro:bit Music Machine.