Project: Ardiono Immersion
Required project to learn to use Arduino Robot


Arduino is the main processor board on many many hobby, experimental, robotics and IoT devices. It is also the one that powers our little mBot robots.

Learning Objectives

  • Understand the difference between software that runs on a screen and software that controls the real world
  • Understand the Arduino hardware and software architecture, the basic event loop and the libraries
  • Install arduino necessary software and learn how to write some simple programs
  • Demonstrate profficiency by writing and demoing a fun example


  1. Download Arduino IDE for Windows/Linux/MacOS, and follow the installation instructions in Getting Started. * Notice that Linux requires an extra step of setting serial port permission at the end.
  2. Set up arduino libraries for mBots. See Background section below.
  3. Learn examples in File->Examples->MakeBloackDrive for e.g. motors, sensors, buzzers, etc
  4. Connect mBot with your device by USB cable, turn on your mBot, choose your mBot in Tools->Port. Notice it is not the bluetooth one.
  5. Upload your own program or test on the examples.

Background - arduino language and libraries

The basic Arduino programming language reference(structure, variables and functions), check Language Reference.

The following are the useful libraries you might want to include in the heading of your code to help you with your mBot programming.

Built-in Arduino Libraries

  • Arduino (built-in)
    • insert code: #include <Arduino.h>
  • Wire (built-in)
    • insert code: #include <Wire.h>
    • or go: Sketch->Include Library->Wire
    • reference:
  • SoftwareSerial (built-in)
    • insert code: #include <SoftwareSerial.h>
    • or go: Sketch->Include Library->SoftwareSerial
    • reference:


This is the official library from MakeBlock, include most useful functions that enable interacting with mBot, such as its motor, sensors, LED, etc.

  1. Download the ZIP file here: * MeMCore

  2. Next follow ‘How to Use’ on the front page for library setup. * see more instructions for Arduino library management

  3. After adding library to your Arduino application successfully, you should see ‘MakeBlockDrive’ option in Files->Examples and Sketch->Include Library.

  4. Now you can use functions in the library by first including the library in your headings as: #include <MeMCore.h>`

  5. An example is provided in Sketch->Include Library->MakeBlockDrive for every function in the library. Check the examples if you have questions about its features, and run the example script if you have questions with what the function does to the mBot.

For example we use MeDCMotor class to control mBot motors:

  • Check out Sketch->Include Library->MakeBlockDrive->Me_DCMotor->DCMotorDriverTest
  • In this example, to see how to declare this object, its function list, and subsequently, which to use to make the motor ‘run’, ’stop’, etc.

Ultrasonic (MUST INSTALL)

The ultrasonic-HC-SR04 Library for Arduino. This library enables you to interact with the two HC-SR04 sensors on the left and right hand side of your mBot. Notice that these are separate from your front Makeblock sensor.

  1. download the Zip file at: *Ultrasonic-HC-SR04

  2. Add downloaded library to your Arduino application.
  3. After successfully added to application, you should see option ‘Ultrasonic’ in Files ->Examples and Sketch->Include Library.

  4. Include the library in your headings before using as : #include <Ultrasonic.h>`

  5. When declaring the Ultrasonic object, be sure to first check the pin (trigger / echo) of the HC sensor is connecting with which analog/digital pin respectively on the mBot board.