micro:bit MakeCode Tutorials: Project 1 of 5

ages 11+ ages 7+ ages 8+ ages 9+ BBC micro:bit BBC microbit BBC microbit v2 Classroom coding digital technologies display educational electronics light sensors makecode microbit tutorials wireless

This is a series of projects that grew from an introductory set of group workshops that we wrote for a local school's open day to promote their Code Club. Projects 1 to 3 ran for about 20 minutes each, and projects 4 and 5 became workshops at the Code Club where I volunteer (these can each be completed within an hour). These projects were easily completed by kids from ages 7-11. The projects that use multiple micro:bits are scaleable and can work well with any number of micro:bits from 2 to class sets; with the option for kids to collaborate in pairs or larger groups.

Project 1: Tilt and Point

This project requires no prior experience with writing code or the micro:bit. You will need some basic computer skills, such as knowing how to launch programs, use a web browser, and plugging in a USB cable.

Although this tutorial talks about saving a .hex file onto your micro:bit, you can also send the code to your micro:bit directly from the browser or by using a bluetooth connection. Here is a tutorial to help with these other methods of getting your code onto your micro:bit

In this project, you will learn:

  • How to use the micro:bit’s built-in accelerometer sensor to detect when it is being tilted left and right (input)
  • How to use the if..then (conditional) block to display image on the micro:bit’s LED matrix display
  • Use a forever loop to repeat this (iteration)

You will need:

  • A micro:bit (V1 or V2 is fine) and matching USB cable
  • A computer with an Internet connection and a modern web browser

Step 1: Launch your browser, and got to the MakeCode website

  • Launch your web browser by clicking on its icon
  • Once your web browser loads, click in the address bar at the top and, in the address bar, type in: https://makecode.microbit.org

Step 2: Write your code

  • Create a new project by clicking on New Project

  • Create your code by dragging blocks into the forever block

    Hint: for the clear screen and show blocks, click on Basic and go to the ..more menu.
    makecode to clear the microbit LED matrix, check if it being tilted and display an appropriate arrow on the display, repeat this forever

What the code does:

  • Clear the micro:bit screen (made up of red lights known as light-emitting diodes or LEDs, for short)
  • Check if the micro:bit is being tilted and display and arrow pointing left or right, depending on which direction it is being tilted
  • Repeat this forever

Step 3: Copy your code to the mciro:bit and see it run

  • Hold your micro:bit carefully by the edges only, and connect it to your computer using the USB cable. Ask for help if you don’t know how to do this. Click the Download button in the bottom left corner of your browser window
    The MakeCode download button image that needs to be clicked to send your code to the microbit over USB or bluetooth
  • Find the MICROBIT folder and save the hex file in there. You’ll see a light on the micro:bit flashing. When it stops, your code will run. Try tilting the mciro:bit left and right to see the arrows change. Make sure that the correct arrow is displayed, compared to the direction of the tilt.

    Congratulations! You’ve written a program on the micro:bit!
    microbit simulator image
Continue to the next project in the series here..

    Creative Commons Licence
    This tutorial is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.


    Older Post Newer Post