micro:bot Kit Experiment Guide

Contributors: D___Run___, TheDarkSaint
Favorited Favorite 1

Experiment 1: Driving and Turning


The “Hello World” for the robotics world is getting your robot moving! Driving forwards, backwards and steering is goal #1 when you are dealing with wheeled / moving robots. This experiment will cover just that: getting your robot moving using our moto:bit software package for Microsoft MakeCode. Once you get through this first experiment you will be golden!

Parts Needed

  • 1x micro:bit board (Not Included)
  • 1x Micro B USB Cable (Not Included)
  • 1x moto:bit carrier board
  • 2x Wheels
  • 1x Assembled shadow chassis
  • 2x Hobby Gear Motors
  • 1x 4xAA Battery Holder
  • 4x AA Batteries (Not Included)

Didn’t get the kit? Have no fear! Here are the parts you will need to complete this experiment…

micro:bit Board

micro:bit Board

Battery Holder - 4xAA to Barrel Jack Connector

Battery Holder - 4xAA to Barrel Jack Connector

SparkFun moto:bit

SparkFun moto:bit

Hobby Gearmotor - 140 RPM (Pair)

Hobby Gearmotor - 140 RPM (Pair)

Wheel - 65mm (Rubber Tire, Pair)

Wheel - 65mm (Rubber Tire, Pair)

Shadow Chassis

Shadow Chassis

1500 mAh Alkaline Battery - AA

1500 mAh Alkaline Battery - AA


Suggested Reading

Motors and Selecting the Right One

Learn all about different kinds of motors and how they operate.

Getting Started with the micro:bit

The micro:bit is a compact, powerful programming tool that requires no software installation. Read on to learn how to use it YOUR way!

Introduction to the Motors and Controlling Them

motor pair

Motors take electrical energy and turn it into mechanical energy through putting a current through a coil of wire that creates a magnetic field. This then interacts with magnets in the motor, causing a push / pull effect. If you do that in a proper spacing and timing then you can spin a shaft.

These motors operate in a similar was as mentioned above, but they have a bit of help; a gear box. The ratio of the gearbox is 120:1, which means that for every 120 rotations of the motor shaft you get one rotation at the end of the gear box. This is a good thing because it gives our robot enough strength (torque) to turn wheels. In this case our gearbox also changes the axis of the shaft so that we can easily use them to drive our robot.

Hardware Hookup

You should have already hooked up the motors during the assembly process of putting the robot together. But, we have a couple of things that we would like you to double check!

Initial Motor Assembly

First of all make sure that your red and black wires are plugged into your moto:bit and that they are in the correct ports. If you look closely the right and left ports are opposite from one another.

Wires Plugged In

Why is that? Well, in robotics the right and left motors are mirrors of one another, which means they go in opposite directions from one another to go forward, hence the ports being backwards. If you plug them in as the same direction your robot would spin in a circle rather than drive forward! Weird, but true.

Running Your Script

We are going to use Microsoft MakeCode to program the micro:bit. Please open a browser window and navigate to makecode.microbit.org. This should open the MakeCode environment that you used to install the moto:bit package in.

Did you install the moto:bit package? To add the moto:bit package as instructed in the Installing the moto:bit Package in MakeCode section of this tutorial.

makecode screen shot

Note: If this is your first time programming a micro:bit please be sure to see our Getting Started with the micro:bit tutorial on how to get your MakeCode program onto your micro:bit.

Now, you can either download the following example script below and drag and drop it onto your micro:bit, or use it as an example and build it from scratch in MakeCode.

Code to Note

exp_1 code

On Button Pressed

The On Button Press is an event function. Any code blocks that are placed inside of the block will only execute when that event happens. In this block when the A button is pressed on your micro:bit your robot will start moving. When it gets to the end of the program it will stop again until you press the A button again.

Turn Motors

The Turn Motors block gives you the ability to turn the motors ON or OFF in software. They are naturally OFF, so anytime you want to drive motors, you need to set them to ON. A good practice is to turn them OFF when your robot completes its task or should not be moving for long periods of time, this saves batteries and wasted power consumption.

Move Motors At

The Move Motors block is the basis of the moto:bit software package. You use this block by selecting which motor you want to control (RIGHT or LEFT), its direction (FORWARD or REVERSE) and the throttle / power percentage you would like the motor to spin at (0-100%). For your bot to move forward you need to have both motors drive in the same direction. To turn, or pivot, you set the motor directions in an opposite configuration.


The pause block is like a code stop sign. It tells the micro:bit to wait for a given amount of time in milliseconds. While it is waiting whatever you told before the pause will keep happening. So, if you want your robot to drive forward for 2 seconds, you set the robots motors to drive forward and then pause for 2000 milliseconds and then have the motors do something else, like stop.

What You Should See

Once your script uploads to your micro:bit make sure the motors switch is changed from “STOP MOTORS” to “RUN MOTORS.” Press the A button on your micro:bit and your robot will drive forward for 1 second, pivot and the drive forward for another second then stop.

Pressing Button A

Go Further: Now that you have a moving robot, can you write a program that would tell your robot to drive in a square? How about a star? What about having it dance?


  • Robot not moving - Make sure your motors are hooked up correctly in the motor ports and your motor power switch is set to “run”, the battery pack is plugged in and you have fresh batteries

  • Moving in reverse?! - You can flip the wiring of your motor or use the Set Motor Invert block in your On Start block to change what is forward vs. reverse.

  • moto:bit package is not showing up - Try installing it again from the add package option in MakeCode