Hack Your Headphones - Micro:Bit

by Aidan-Corrales in Circuits > Electronics

3732 Views, 18 Favorites, 0 Comments

Hack Your Headphones - Micro:Bit

IMG_1100.png

Use your Micro:Bit to play music through your headphones!

Supplies

- Yourself

- Micro:Bit

- Battery Pack (Optional)

- Mirco USB

- Alligator Clips x2

- Headphones

- Computer

Inventory

IMG_1097.JPG

Make sure you have all of your supplies!

Ground

IMG_1092.JPG
IMG_1089.JPG
IMG_1098.png

Use one of your alligator clips to connect the ground pin on the Micro:Bit to the ground pin on the headphones.

Pin 0

IMG_1087.JPG
IMG_1086.JPG
IMG_1098.png

Use your other alligator clip to connect the pin 0 on the Micro:Bit to both the left and right pins on the headphones.

Connect

IMG_1090.JPG

Use the micro USB to connect your Micro:bit to your computer.

Let's Code!

lets code.png

Go to the Micro:bit compiler website.

https://makecode.microbit.org/#editor

Forever Loop

forever.png

Insert a forever loop. The code that goes in this loop will execute forever on repeat as long as the Micro:Bit is on.

If Statement

If.png

Insert an if statement inside of the forever loop. The code that goes inside an if statement only executes if the condition is met.

Example: If it is rainy, then I will use an umbrella.

In the example above, I only use an umbrella if the condition "it is rainy" has been met.

Condition

input.png

Next we will add the condition: "button A is pressed." I want the music to play whenever I press the button, so this is the condition I set.

Music

then.png
nyan.png

Now we will add the code to make music play. The music will play once our condition of pressing the button is met.

I personally like the Nyan Cat song, so I am going to change the melody to nyan.

Download

download.png

Click the download button. This downloads the program to your computer as a .hex file.

Find File

show.png
file.png

Click the arrow next your downloaded file, then click show in finder. This will show where your program saved on your computer.

Flash

flash.png
100.png

Next you will flash the file to your Micro:Bit. Click and drag the file to your Micro:Bit in the navigation bar. A loading bar will pop up while it is flashing to the Micro:Bit. Wait until it finishes.

Test

IMG_1093.png

Press the A button on your Micro:Bit to play your music!

If the music does not play, go ahead and review the previous steps to make sure you didn't miss anything.

Unplug & Play!

IMG_1094.JPG
IMG_1095.JPG

Unplug your Micro:Bit from the computer and plug in your battery pack. Congratulations! You just made your own mp3 player!!!

Go ahead and try the project again! Play around a bit!

What happens if you change the wires around?

What happens if you change the button code?

What happens if you change the music code?

Can you make a music note show on the screen?

Here Are Video Instructions If You Prefer That! :)

Microbit - Headphone Hacks