10 projects

mBot Projects

The mBot is a two-motor educational robot built around the mCore board. The mCore is compatible with the Arduino Uno, so you can program the mBot in C++ in the Arduino IDE and move on from block coding to real code.

These mBot projects use the standard kit with no extra parts. They start with lighting the onboard RGB LEDs and continue with buzzer melodies, changing colors with the button, driving forward and back, a robot that draws a square and a night light using the light sensor. Every project has commented Arduino C++ code and a step-by-step walkthrough.

The first 10 projects for beginners

Follow them in this order and each project adds one new skill on top of the last.

  1. 1First Program with mBot: Light Up the Onboard RGB LEDsFirst Program with mBot: Light Up the Onboard RGB LEDsUpload your first code to the mBot with the Arduino IDE. The two RGB LEDs on the robot's board (mCore) light up red, green and blue together, then the right one turns yellow, the left one purple, and both go off. No wires or extra parts are needed; just connect the mBot to the computer over USB. setColor picks the color and show sends it to the LEDs.Beginner
  2. 2Color Fade with mBot: A Rainbow on the RGB LEDsColor Fade with mBot: A Rainbow on the RGB LEDsThe two RGB LEDs on the mBot's board fade smoothly through the colors of the rainbow: from red to green, green to blue and blue back to red. The left LED runs a little ahead of the right one on the color wheel, so the two always show different shades. No extra parts. A single number (0-255) holds the place on the wheel, and the code turns it into red, green and blue values.Beginner
  3. 3First Melody with mBot: Play Notes on the BuzzerFirst Melody with mBot: Play Notes on the BuzzerThe buzzer on the mBot's board plays the first two lines of a well-known children's song (Twinkle Twinkle Little Star), waits 2 seconds and starts over. No extra parts are needed. Every note is a frequency (Hz) and a length; the melody lives in two lists, one with the notes and one with the beat counts. The tone command plays a note and waits until it is over.Beginner
  4. 4Change Colors with the mBot Button: A New Color on Every PressChange Colors with the mBot Button: A New Color on Every PressEvery press of the button on the mBot's board moves the two RGB LEDs to the next color: red, green, blue, yellow, purple, cyan, white and off. Holding the button does not change the color again; one press is one step. No extra parts are needed. The button is read as an analog value on pin A7: close to 0 while pressed, up at 1023 when released.Beginner
  5. 5mBot Melody Picker: Press the Button, Change the TunemBot Melody Picker: Press the Button, Change the TuneEvery press of the button on the mBot's board makes the buzzer play the next melody. There are three short melodies; after the third it goes back to the first. No extra parts are needed. The melodies live in one table: one melody per row, eight beats each. Pressing the button while a melody plays changes nothing, because tone holds the code until the note is over.Beginner
  6. 6mBot Drive Forward and Stop: First Move with the MotorsmBot Drive Forward and Stop: First Move with the MotorsPress the button on the mBot's board: the robot waits one second, drives straight forward for two seconds and stops. Every press repeats the move. No extra parts are needed. The two motors are plugged into M1 and M2; to go straight the left motor gets a negative speed and the right motor a positive one.Beginner
  7. 7mBot First Drive: Forward, Backward, Right and LeftmBot First Drive: Forward, Backward, Right and LeftPress the button on the mBot's board and the robot does the four basic moves in turn: it drives forward, comes back, turns right on the spot and turns left. Each move is a function of its own. No extra parts are needed. In a turn the two wheels spin in opposite directions; the TURN_MS time sets the angle.Beginner
  8. 8mBot Square Drawing Robot: Four Sides with a LoopmBot Square Drawing Robot: Four Sides with a LoopPress the button on the mBot's board and the robot draws a square on the floor: it drives along one side, makes a quarter turn to the right on the spot and repeats this four times. It ends where it started. No extra parts are needed. The SIDE_MS time sets the side length and the TURN_MS time sets the turning angle.Beginner
  9. 9mBot Speed Levels: Slow, Medium, FastmBot Speed Levels: Slow, Medium, FastPress the button on the mBot's board and the robot drives forward and back at three speeds: slow first, then medium, then fast. The time is always the same; the higher the speed, the farther the robot goes. No extra parts are needed. The speeds sit in the SPEEDS table: 100, 170 and 255.Beginner
  10. 10mBot Night Light: LEDs That Turn On in the Dark with the Light SensormBot Night Light: LEDs That Turn On in the Dark with the Light SensorThe light sensor on the mBot's board measures the ambient light. When it gets dark the two RGB LEDs light up warm white; when it gets bright they go off. No extra parts are needed. The on and off limits differ (300 and 450), so the lamp does not flicker at the edge. The reading is printed to the Serial port.Beginner

Projects by difficulty

Beginner10 projects

First Program with mBot: Light Up the Onboard RGB LEDs
MB-1Beginner

First Program with mBot: Light Up the Onboard RGB LEDs

Upload your first code to the mBot with the Arduino IDE. The two RGB LEDs on the robot's board (mCore) light up red, green and blue together, then the right one turns yellow, the left one purple, and both go off. No wires or extra parts are needed; just connect the mBot to the computer over USB. setColor picks the color and show sends it to the LEDs.

Color Fade with mBot: A Rainbow on the RGB LEDs
MB-2Beginner

Color Fade with mBot: A Rainbow on the RGB LEDs

The two RGB LEDs on the mBot's board fade smoothly through the colors of the rainbow: from red to green, green to blue and blue back to red. The left LED runs a little ahead of the right one on the color wheel, so the two always show different shades. No extra parts. A single number (0-255) holds the place on the wheel, and the code turns it into red, green and blue values.

First Melody with mBot: Play Notes on the Buzzer
MB-3Beginner

First Melody with mBot: Play Notes on the Buzzer

The buzzer on the mBot's board plays the first two lines of a well-known children's song (Twinkle Twinkle Little Star), waits 2 seconds and starts over. No extra parts are needed. Every note is a frequency (Hz) and a length; the melody lives in two lists, one with the notes and one with the beat counts. The tone command plays a note and waits until it is over.

Change Colors with the mBot Button: A New Color on Every Press
MB-4Beginner

Change Colors with the mBot Button: A New Color on Every Press

Every press of the button on the mBot's board moves the two RGB LEDs to the next color: red, green, blue, yellow, purple, cyan, white and off. Holding the button does not change the color again; one press is one step. No extra parts are needed. The button is read as an analog value on pin A7: close to 0 while pressed, up at 1023 when released.

mBot Melody Picker: Press the Button, Change the Tune
MB-5Beginner

mBot Melody Picker: Press the Button, Change the Tune

Every press of the button on the mBot's board makes the buzzer play the next melody. There are three short melodies; after the third it goes back to the first. No extra parts are needed. The melodies live in one table: one melody per row, eight beats each. Pressing the button while a melody plays changes nothing, because tone holds the code until the note is over.

mBot Drive Forward and Stop: First Move with the Motors
MB-6Beginner

mBot Drive Forward and Stop: First Move with the Motors

Press the button on the mBot's board: the robot waits one second, drives straight forward for two seconds and stops. Every press repeats the move. No extra parts are needed. The two motors are plugged into M1 and M2; to go straight the left motor gets a negative speed and the right motor a positive one.

mBot First Drive: Forward, Backward, Right and Left
MB-7Beginner

mBot First Drive: Forward, Backward, Right and Left

Press the button on the mBot's board and the robot does the four basic moves in turn: it drives forward, comes back, turns right on the spot and turns left. Each move is a function of its own. No extra parts are needed. In a turn the two wheels spin in opposite directions; the TURN_MS time sets the angle.

mBot Square Drawing Robot: Four Sides with a Loop
MB-8Beginner

mBot Square Drawing Robot: Four Sides with a Loop

Press the button on the mBot's board and the robot draws a square on the floor: it drives along one side, makes a quarter turn to the right on the spot and repeats this four times. It ends where it started. No extra parts are needed. The SIDE_MS time sets the side length and the TURN_MS time sets the turning angle.

mBot Speed Levels: Slow, Medium, Fast
MB-9Beginner

mBot Speed Levels: Slow, Medium, Fast

Press the button on the mBot's board and the robot drives forward and back at three speeds: slow first, then medium, then fast. The time is always the same; the higher the speed, the farther the robot goes. No extra parts are needed. The speeds sit in the SPEEDS table: 100, 170 and 255.

mBot Night Light: LEDs That Turn On in the Dark with the Light Sensor
MB-10Beginner

mBot Night Light: LEDs That Turn On in the Dark with the Light Sensor

The light sensor on the mBot's board measures the ambient light. When it gets dark the two RGB LEDs light up warm white; when it gets bright they go off. No extra parts are needed. The on and off limits differ (300 and 450), so the lamp does not flicker at the edge. The reading is printed to the Serial port.

Projects by category

Parts and tools

The parts used most often in these projects, calculators that help while you build, and step-by-step guides.

Frequently asked questions

Can the mBot be programmed with the Arduino IDE?

Yes. The mBot's mCore board is compatible with the Arduino Uno. Select Arduino Uno as the board in the Arduino IDE, install the library named in the project and upload the code over USB.

Do mBot projects need extra parts?

Not for the first projects. The RGB LEDs, buzzer, button, light sensor, ultrasonic distance sensor, line follower sensor and motors all come in the standard mBot kit.

What can you build with an mBot?

Light and sound experiments, driving forward, back and turning, drawing a square, a night light that turns on in the dark, distance measuring, obstacle avoidance and line following are the favorite mBot projects.

Other platforms