Make a Music Machine with ElecFreaks Micro:bit Tinker Kit

Goals
•    Get to know the ADKeypad.
•    Make something with ADKeypad.
•    Make something with Buzzer.
Materials
1 x Micro USB cable

Tips: If you want all components above, you may need ElecFreaks Micro:bit Tinker Kit.
Step 1
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.

Step 2
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.


Step 3
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.Copy and paste this link into "Add Package" text field:
https://pxt.microbit.org/50544-64675-33322-24641
Click on the search icon  or press enter.

Then, click on the Tinkercademy button.

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.
Click on Tinkercademy inside the Code Drawer to find our custom blocks for the various components in your kit.

Step 4
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.

Success! You now have your own Micro:bit Music Machine.
Relative Readings:
Note: This article is from Tinkercademy “Make a Music Machine” .
If you want to read the latest elecfreaks  blogs, please like our Facebook PAGE.

评论

此博客中的热门博文

Getting started with the micro:bit and MicroPython

How to Send Temperature Threshold Value Alarm Email via IFTTT

Snake on the BBC micro:bit