The BBC micro:bit is a neat tool used to help kids around the world code. It was designed by the BBC to help UK improve its computer science education in 2015. It has multiple features, such as processors, LEDs, sensors, and a compass. You can code with this credit-card-sized device on the official Microsoft Makecode website . If you want to learn how to code using the micro:bit, here are some ways on doing that.

Part 1
Part 1 of 3:

Intro to the micro:bit

  1. 1
    Open up your micro:bit box. Open up the cardboard box by cutting open the packaging. Then, lift up the flaps of the cardboard box to open it up. There will be a few bags of items you will need with your micro:bit. You will see the following items in your micro:bit kit:
    • Your BBC micro:bit
    • A micro:bit USB cable to connect it to your device
    • A micro:bit battery pack
    • An instruction manual
  2. 2
    Check which micro:bit version you have. There are currently two versions of the micro:bit. The first version was created in 2015, and the second version in 2020. The second version has a couple more new features than the first version. Both versions have LEDs, the micro:bit processor, two small black buttons, an accelerometer, a temperature sensor, a light sensor, a compass, a radio, pins, and USB ports. [1] [2]
    • If you have the second version, your micro:bit will have a touch logo and speakers. The logo can act as an extra button on version 2 of the microbit. You can input into the micro:bit by pressing or lightly touching the logo. There is also a built-in microphone on the 2nd version of the micro:bit.
    Advertisement
Part 2
Part 2 of 3:

Coding Using the micro:bit with MakeCode

  1. 1
    Open up a web browser. You need either a computer with a web browser and internet access or a phone/tablet that has the micro:bit app. If you're using a computer, open up a browser and use a website that can run micro:bit code. Microsoft MakeCode , Scratch , and Micropython are popular websites to run micro:bit code, although there are others too.
    • If you're using a mobile device, make sure to install the free micro:bit app to start coding!
    • If you're using the MakeCode website, go down to the section that says, "Write programs for the micro:bit" and click on it. This will lead you to the Microsoft MakeCode micro:bit website .
  2. 2
    Name your project. Click on Create to save the name of your project. You'll need to name your project before proceeding to the next steps, or else the system won't allow you to continue. Choose a name that best fits your project.
    • Don't name many of your projects with the same name, as you might get mixed up.
    • Try to name each of your projects with a descriptive name, such as, "Starter Combat Game" or "Flashing Lights".
  3. 3
    Explore the tools. Try each option to add detail to your project. Each section has code blocks that help you code your micro:bit. There are multiple tools that can add unique features to your project, such as help the micro:bit light up, allow it to send signals to other micro:bits, and allowing it to produce sounds and music.
    • The blue "Basic" button contains code for lighting up the leds on the micro:bit.
    • The magenta "Input" button contains code to let the micro:bit do something when inputted. There are many code blocks that allow your LEDs to light up and for the buttons to output something.
    • The red "Music" button contains code for music or sound effects in the game. Your micro:bit can produce numerous sounds and music effects.
    • The purple "Led" button contains code for plotting points on the micro:bit.
    • The pink "Radio" button contains code for sending radio messages to other micro:bits. This way, multiple micro:bits can communicate and synchronize with each other.
    • The green "Loops" button allows you to add loops to your code. This repeats your code multiple times.
    • The light blue "Logic" button has code for if-else statements. "If (something) happens, then you do this. If something else happens, the sprite/game will do this command."
    • The "Variables" button allows you to create and set variables in your game.
    • The light purple "Math" button lets you put math operators and comparisons in your code.
    • The black "Advanced" button has advanced operators if you want to create complex code.
  4. 4
    Switch between JavaScript, Python, or block coding. There are three different coding languages you can use for coding the micro:bit: JavaScript, Python, or block code. If you are coding using JavaScript or Python, the code menu will still contain block code. But when you drag the blocks over, they will convert to text code.
    • Block coding is recommended if you are brand-new to coding, and JavaScript or Python if you're somewhat familiar with coding.
    • You can program assets into your code later.
  5. 5
    Make a prototype (optional). This can help you learn some basic coding. Don't try your hardest on making the art like the way you want it. In the prototype, let loose on art!
  6. 6
    Release a demo (optional). A demo can get people excited for the game's release! Make sure to not add to much though- it can ruin the surprise!
  7. 7
    Download your project if you want to save it permanently on your computer by clicking on the purple "Download" button. If you want to test out your code on your real micro:bit, you should download it. The file downloads as a .hex file, so only micro:bits and certain types of hardware can run it. Then, you can drag the file to the micro:bit drive to test it out.
    • If you have the hardware to run your project offline, you can download it.
    Advertisement
Part 3
Part 3 of 3:

Using the micro:bit with MakeCode

  1. 1
    Put the code onto your micro:bit. You'll need to use your USB cable and a computer to do this. Plug in the small end of the USB cable into the small slot on the top of your micro:bit. Next, plug the large end of the cable into your computer. It may be located on the left or right side of your computer depending on the type. Then, you should see an added drive on your computer that says, "MICROBIT drive" or something similar to that.
    • Drag your downloaded code (a .hex file) onto the drive, and your code should run. [3]
  2. 2
    Code the micro:bit to make its LEDs flash. This is a very simple project you can make with only a few blocks or lines of code. You will mostly need blocks/text from the "Basic" section of the code menu, as they contain the code you'll need to make the LEDs shine. You will only need a couple blocks for this, and you can easily customize it.
    • First, drag out an "on start" block from the "Basic" section. Next, drag out a "show leds" block. To make your own pattern, click on each of the boxes for them to turn white. White boxes will light up on your micro:bit. You can also choose a default pattern.
    • If you want to make the micro:bit show more than 1 image, drag out a "pause (ms)" block (ms stands for milliseconds) and another "show leds" block. Put both of these right below the 1st "show leds" block. Then, you can set the 2nd image by clicking on the boxes to turn them white.
  3. 3
    Code the micro:bit to perform an action using an input. You can input into the micro:bit with a variety of different ways. You can shake the micro:bit, press either of its buttons, press on its pins, the logo if you have version 2 of the micro:bit, and making a loud or quiet sound. All of these functions can be used by dragging out the corresponding blocks from the "Input" category.
    • Drag out one of the buttons from the "Input" section. There are a lot of them, such as the "on button A pressed" block, the "on shake" block, and the "on pin P0" block. Each of them tells the micro:bit to do something when you do any of these actions (by pressing the buttons, shaking the whole thing, etc.)
    • On the real micro:bit and the micro:bit simulator, the leds flash red. The simulator is almost identical to your real micro:bit, except that it has function of both versions 1 and 2 of the micro:bit.
    • Then, add something, such as the "show leds" blocks.
  4. 4
    Code your micro:bit for it to play music. The micro:bit can also produce a wide range of music and sounds. All of the code for music is in the red "Music" section. You can play melodies, certain tones, set and change the tempos for the music, start and stop melodies, and play some ringtones. You can also make a custom noise by editing the music. Use the "play sound" block and click on the gray music bubble to edit and customize the music to your liking.
    • Drag one of the blocks from the red "Music section" and put it in the blue "on start" block or one of the green "Loops" blocks. Putting the code in a loop makes it repeat a certain number of times. You can also make it loop forever.
    Advertisement


Expert Q&A

Ask a Question

      Advertisement

      About this article

      Thanks to all authors for creating a page that has been read 371 times.

      Is this article up to date?

      Advertisement