Hack Your Headphones - Micro:Bit
by Aidan-Corrales in Circuits > Electronics
3884 Views, 18 Favorites, 0 Comments
Hack Your Headphones - Micro:Bit

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

Make sure you have all of your supplies!
Ground



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



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

Use the micro USB to connect your Micro:bit to your computer.
Let's Code!

Go to the Micro:bit compiler website.
Forever Loop

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

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

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


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

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


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


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

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!


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! :)
