Getting Started with micro:bit

Updated 20 April 2022

Check out our micro:bit in the classroom video if you'd like to see how micro:bit integrates into classrooms, years 7-12.

After a quick review of the hardware, we'll fire up a micro:bit and write our first program. All you'll need for this tutorial is a micro:bit and a micro-USB lead. There's no software to download because we write code from within the web browser!

For this tutorial we'll look at the graphical/javascript editor for micro:bit. Head over to the micro:bit code menu and run the PXT editor.

Code for this tutorial

If you want a copy of the compass script, you can copy-and-paste the following into the javascript editor. Once the code is pasted in, you can change back to the Blocks editor if you like!

let heading = 0
basic.forever(() => {
    heading = input.compassHeading()
    if (heading <= 45) {
        basic.showString("N")
    } else if (heading <= 135) {
        basic.showString("E")
    } else if (heading <= 225) {
        basic.showString("S")
    } else if (heading <= 315) {
        basic.showString("W")
    } else {
        basic.showString("N")
    }
})

If you want to roll-back your micro:bit to the default demo program, you can download the attached .hex file.

Refrences

The compass program for this tutorial was sourced from the BBC: Compass lesson.

Attachment - BBC-MicroBit-First-Experience.hex

Have a question? Ask the Author of this guide today!

Please enter minimum 20 characters

Your comment will be posted (automatically) on our Support Forum which is publicly accessible. Don't enter private information, such as your phone number.

Expect a quick reply during business hours, many of us check-in over the weekend as well.

Comments


Loading...
Feedback

Please continue if you would like to leave feedback for any of these topics:

  • Website features/issues
  • Content errors/improvements
  • Missing products/categories
  • Product assignments to categories
  • Search results relevance

For all other inquiries (orders status, stock levels, etc), please contact our support team for quick assistance.

Note: click continue and a draft email will be opened to edit. If you don't have an email client on your device, then send a message via the chat icon on the bottom left of our website.

Makers love reviews as much as you do, please follow this link to review the products you have purchased.