Legacy edition, no longer supported: SharpShot Vision units shipped before 2026-10 (School and WRO editions) are no longer supported; their guides and examples stay here for reference. To upgrade to the current SharpShot Vision, contact the distributor you bought it from and send it back: the firmware update is free, and the buyer pays shipping both ways.

SharpShot Vision (ESP32CAM) × mBlock × mBlock 5

Interactive tutorialmBlock

First time? Try the interactive tutorial in your browser first, then follow the steps below with your hub.

This page covers mBlock 5 (MBC Pro Sensors extension) only: how to set it up for the SharpShot Vision (ESP32CAM) on Makeblock (mBot) + mBlock 5, how to read every value, the commands it supports and examples. Use the switcher above to change product, host or software.

Which edition and how to connect

Get the MakeBlock edition (RJ25 plug) and plug it into an RJ25 port of mBot / Ranger / Orion / MegaPi; usable ports per board are listed in MakeBlock extension.

SharpShot Vision (ESP32CAM) × Makeblock (mBot) + mBlock 5

Setup

What you need

  • Sensor: SharpShot Vision (ESP32CAM) (MakeBlock edition, different factory firmware from the other editions), plus an mBot adapter (to plug into an RJ25 port). SPIKE, EV3 and I2C editions cannot connect to a Makeblock board directly.
  • Board: mBot (mCore), mBot Ranger (Auriga), Orion, Ultimate 2.0 (MegaPi), MegaPi Pro. mBot2 (CyberPi) has no RJ25 port and is not supported.
  • Software: mBlock 5 for PC (Upload mode: the program is flashed to the board).
  • Extension: MBC Pro Sensors v2.0.0 (for protocol v2 firmware shipped from 2026-10).

Install the software

  1. Install mBlock 5 for PC from the mBlock website.
  2. Open mBlock 5 and add your board (for example mBot) under "Devices" at the bottom left.
  3. Switch the mode toggle at the bottom right to Upload.

Make the software see the sensor

Add one extension and the MBC blocks appear:

  1. Get the v2.0.0 extension: once it is listed, search "MBC" in the mBlock 5 "Extension Center" and add it. Before it is listed (under review), advanced users can sign in to ext.mblock.cc with their own Makeblock account → My extensions → Import data, upload mbc_pro_sensors_2.0.0_import.mext (about 1 minute), then click "Download" to get a .mext.
  2. Drag the .mext file into the mBlock window. Six new categories appear: Pathfinder, Ranger, Controller, IMU gyro, Vision and MBC common.
  3. Start the program with the board's start block (for example "when mBot starts up") and click "Upload" to flash it to the board.
  4. To open an example: "File → Open from your computer" and pick the .mblock file.

Important

The new extension (v2) only works with new firmware, and the legacy extension (v1.0.0) only with firmware from before 2026-10; their blocks are not compatible. Not sure which firmware you have? Drag in the v2 extension and read the "MBC common → protocol version" block: 2 means new firmware. The legacy extension is in the Downloads.

Wiring

Sensor → mBot adapter → the board's RJ25 port (UART 38400). The blocks ask for a port number; the extension maps it to the right pins for your board.

Board Usable ports Notes
mBot (mCore) 1, 2, 3, 4 all four ports
mBot Ranger (Auriga) 6 ~ 10 1 ~ 4 are red motor ports, 5 is the serial port
Orion 3, 4, 6 1, 2 are red motor ports; 7, 8 are analog only
Ultimate 2.0 (MegaPi) 6, 7, 8 needs the RJ25 shield; 5 is the serial port
MegaPi Pro 7, 8, 9, 10 needs the RJ25 shield

The examples on this page use mBot port 1; to use another port, change the port number on the blocks. On another board, replace "when mBot starts up" with that board's start block.

Set the colour on the sensor first

All SharpShot settings are made on the colour screen and buttons on the back of the sensor, no computer needed: short-press the side button to open the settings menu, left / right to choose, OK to enter. Colour settings and camera parameters are saved automatically and used at the next power-on.

Note

The SharpShot MakeBlock edition is new in October 2026; before ordering, ask us on LINE to confirm the shipping version. On the mBot it uses the IO1 / IO3 serial pins, bench test in progress.

First test

  1. Start the program with "wait 1 second" so the sensor can boot; reading too early returns -32768.
  2. Check the wiring with the "MBC common → connection OK?" block, then look at the values.
  3. Upload example 1 on this page. If the number changes with the sensor, everything is connected.

FAQ

  • "connection OK?" is false? Wrong port, the sensor is not the MakeBlock edition, or the firmware is legacy (use the v1 extension with old firmware).
  • Reading -32768? Nothing has been read since power-on: check the wiring; or this product has no such value.
  • The value never changes? Make sure the adapter is firmly in and the sensor light is on; "protocol version" reading 2 means communication works.
  • Still stuck? Contact us on LINE with the board model, the port and the value of the "device ID" block.

Reading values (School edition)

After adding the MBC Pro Sensors extension, find the blocks in the "SharpShot Vision (legacy)" category and pick the port the sensor is plugged into.

hue hue

hue
Range Meaning
-1~100 hue of sample point S1, 0100 (hue ring 0240 scaled); −1 = black/white/grey (saturation < 10); 0 when S1 is not set
(SharpShot Vision (legacy) port [1 v] hue :: sensing)

Block returns hue(-1~100)。Host sends [01] → reply [lo][hi][01 ^ lo ^ hi], value = int16 little-endian.

saturation saturation

saturation
Range Meaning
0~100 saturation of sample point S1, 0~100
(SharpShot Vision (legacy) port [1 v] saturation :: sensing)

Block returns saturation(0~100)。Host sends [02] → reply [lo][hi][02 ^ lo ^ hi], value = int16 little-endian.

brightness value

brightness
Range Meaning
0~100 brightness (HSV value) of sample point S1, 0~100
(SharpShot Vision (legacy) port [1 v] brightness :: sensing)

Block returns brightness(0~100)。Host sends [03] → reply [lo][hi][03 ^ lo ^ hi], value = int16 little-endian.

motion motion

motion
Range Meaning
0~100 whole-frame motion 0~100 (more change = larger)
(SharpShot Vision (legacy) port [1 v] motion :: sensing)

Block returns motion(0~100)。Host sends [04] → reply [lo][hi][04 ^ lo ^ hi], value = int16 little-endian.

blob X blobX

blob X
Range Meaning
0~100 blob centre X 0~100, left = 0; 0 when not found
(SharpShot Vision (legacy) port [1 v] blob X :: sensing)

Block returns blob X(0~100)。Host sends [05] → reply [lo][hi][05 ^ lo ^ hi], value = int16 little-endian.

blob Y blobY

blob Y
Range Meaning
0~75 blob centre Y 0~75, bottom = 0, top = 75; 0 when not found
(SharpShot Vision (legacy) port [1 v] blob Y :: sensing)

Block returns blob Y(0~75)。Host sends [06] → reply [lo][hi][06 ^ lo ^ hi], value = int16 little-endian.

blob width blobW

blob width
Range Meaning
0~100 blob width W 0~100; 0 = not found
(SharpShot Vision (legacy) port [1 v] blob width :: sensing)

Block returns blob width(0~100)。Host sends [07] → reply [lo][hi][07 ^ lo ^ hi], value = int16 little-endian.

blob height blobH

blob height
Range Meaning
0~75 blob height H 0~75; 0 when not found
(SharpShot Vision (legacy) port [1 v] blob height :: sensing)

Block returns blob height(0~75)。Host sends [08] → reply [lo][hi][08 ^ lo ^ hi], value = int16 little-endian.

blob area blobArea

blob area
Range Meaning
0~7500 W×H (0~7500); 0 when not found
(SharpShot Vision (legacy) port [1 v] blob area :: sensing)

Block returns blob area(0~7500)。Host sends [09] → reply [lo][hi][09 ^ lo ^ hi], value = int16 little-endian.

blob found found

Range Meaning
0~1 1 = a blob of the target colour is in view (W > 0), 0 = none
(SharpShot Vision (legacy) port [1 v] blob found? :: sensing)

Block returns blob found(0~1)。Host sends [0A] → reply [lo][hi][0A ^ lo ^ hi], value = int16 little-endian.

Commands

update all values readAll

reads the whole value table into a cache (FD pack-all); reporter blocks within the next 10 ms use the cache instead of asking one by one

SharpShot Vision (legacy) port [1 v] update all values :: sensing

Reading values (WRO edition)

After adding the MBC Pro Sensors extension, find the blocks in the "SharpShot Vision WRO (legacy)" category and pick the port the sensor is plugged into.

spot 1~12 colour code spotColor

spot 1~12 colour code
Range Meaning
0~255 101B = colour code of spots S1S12: 0239 colour (hue 0255 scaled to 0239), 240245 white (saturation < 30, lower = larger), 246~250 black (value < 30, darker = larger), 255 = spot not enabled
(SharpShot Vision WRO (legacy) port [1 v] spot [1 v] colour code :: sensing)

Block returns spot 1~12 colour code(0~255)。Host sends [10] → reply [lo][hi][10 ^ lo ^ hi], value = int16 little-endian; channel N uses id 0x10 + (N − 1).

spot 1~12 vividness spotVivid

spot 1~12 vividness
Range Meaning
0~255 202B = vividness (saturation) of spots S1S12, 0~255: black = 1, white/colour = actual saturation; 0 when the spot is not enabled
(SharpShot Vision WRO (legacy) port [1 v] spot [1 v] vividness :: sensing)

Block returns spot 1~12 vividness(0~255)。Host sends [20] → reply [lo][hi][20 ^ lo ^ hi], value = int16 little-endian; channel N uses id 0x20 + (N − 1).

Commands (WRO edition)

update all values readAll

reads the whole value table into a cache (FD pack-all); reporter blocks within the next 10 ms use the cache instead of asking one by one

SharpShot Vision WRO (legacy) port [1 v] update all values :: sensing

Examples (School edition)

This page is for people who have never written a program: read the SharpShot (school edition) on an mBot with mBlock 5 blocks. The 5 examples start with "turn the number into a sound" and work up to a robot that drives itself. Every example has a block picture, a downloadable project file and an Arduino sketch that does the same thing.

Software Who it suits How to open the example file
🟧 mBlock 5 desktop (blocks, Upload mode) + MBC Pro Sensors extension v2 Schools, first time with an mBot Download the .mblock → open mBlock 5 → "File → Open from your computer" → switch to "Upload" at the bottom right → "Upload"
🔧 Arduino IDE (text code) People who want to see what is behind the blocks, or write their own code Download the .ino → install the Makeblock and MBC_Sensors libraries (see Makeblock extension) → board Arduino Uno → upload

Important

  • The sensor must be the Makeblock edition with the 2026-10 protocol v2 firmware, connected through the mBot socket board to an RJ25 port; use extension v2.0.0 (old firmware goes with the old v1 extension; they cannot be mixed).
  • The board is the mBot (mCore). mBot Ranger, Orion and MegaPi work too: swap "when mBot starts up" for that board's hat block and use a port that board allows (see supported boards and ports); the mBot2 (CyberPi) has no RJ25 port and is not supported.
  • mBlock 5 is shown here with its English block text; your copy may show the same blocks in another language.

Before you start

SharpShot (school edition) × mBot wiring

Sensor → mBot socket board → RJ25 port on the board (S1 = host TX, S2 = host RX, UART 38400).

  1. Install the extension: get the MBC Pro Sensors v2.0.0 .mext from Makeblock extension and drop it into the mBlock 5 window; add mBot under "Devices" (bottom left) and switch to "Upload" (bottom right).
  2. Wiring: SharpShot → mBot socket board → mBot port 1 (every example on this page uses this port; to use another, change the port number on the blocks).
  3. Let it boot first: every example starts with "wait 1 seconds" so the sensor can boot; reading too early gives -32768 (nothing received yet).
  4. Set the colour on the sensor itself (programs cannot change it): plug the sensor into the mBot, power on and hold the coloured brick in front of the camera. With RUN at the top of the screen, short-press the side button for the menu: SET 1:COLOR sets the sample point for "hue" (example 1: use left/right to move the red and green lines onto the brick, keep the default tolerances); SET 2:TRACK sets the blob to follow (examples 2~5: centre the cross on the brob, tune TOL_HUE / TOL_STA until only your brick is marked, raise MIN AREA to drop small specks). Settings are stored in the sensor.
  5. Leave the flash LED off (bricks reflect and turn white). Back on the RUN screen the top line keeps showing H… (hue) A… (area) X… Y…; those are the numbers the examples read.

Blocks used on this page

Each reporter block is one "value id" of the sensor's value table (the same ids as the Arduino I2C registers); the full block list is in Makeblock extension.

Block Returns Meaning
SharpShot Vision (legacy) port [1] hue -1~100 hue of sample point S1, 0100 (hue ring 0240 scaled); −1 = black/white/grey (saturation < 10); 0 when S1 is not set
SharpShot Vision (legacy) port [1] blob found? true / false 1 = a blob of the target colour is in view (W > 0), 0 = none
SharpShot Vision (legacy) port [1] blob X 0~100 blob centre X 0~100, left = 0; 0 when not found
SharpShot Vision (legacy) port [1] blob area 0~7500 W×H (0~7500); 0 when not found

Examples on this page

  1. Hear the colour
  2. Green when the blob is found
  3. One wheel turns toward the blob
  4. Follow the blob
  5. Follow, stop when close, with lights

Note

The .mblock files are generated in the mBlock 5 save format and have not yet been opened in mBlock 5 for verification (pending the extension v2 release). If one will not open or shows blank blocks, check that extension v2 is loaded and the device is mBot, or rebuild it from the block picture below (under 5 minutes); you can also tell us on LINE.


Example 1: Hear the colour

What this example does: The mBot has no screen, so this example turns the sample point "hue" (0 to 100: red 0, yellow ≈17, green ≈33, blue ≈67; black/white/grey = −1) into a buzzer pitch. Learn to "read the number" first.

What you need

  • mBot (mCore board) + mBlock 5 desktop
  • SharpShot (school edition) (Makeblock edition) + mBot socket board
  • A brightly coloured brick (red, green or blue)

Wiring: SharpShot → mBot socket board → mBot port 1. Camera facing forward on the front. First set the colour to look for on the sensor itself (see "Before you start").

Download

mBlock 5 project Equivalent Arduino sketch
ex01_hear_colour.mblock ex01_hear_colour.ino
mBlock blocks (just rebuild them like this)
when mBot starts up :: events hat
wait (1) seconds
forever
  play tone ((200) + ((SharpShot Vision \(legacy\) port [1 v] hue :: #C2255C) * (6))) Hz for (0.1) seconds :: sound
end
🔧 Equivalent Arduino sketch (mBot)
// SharpShot (school edition) × mBlock 5  Example 1: Hear the colour  (equivalent Arduino sketch for mBot)
// Wiring: SharpShot → mBot socket board → mBot port 1. Camera facing forward on the front. First set the colour to look for on the sensor itself (see "Before you start").
// Does exactly what the mBlock block example does, for people who want to see "what is behind the blocks" or use the Arduino IDE.
// Libraries needed:
//   1. Makeblock (Arduino IDE Library Manager, search "Makeblock", or the copy inside the mBlock 5 install folder)
//   2. MBC_Sensors v2: the four files in src/ of the extension .mext (MBC_Sensors.h/.cpp, mbc_proto.h, mbc_ids.h),
//      put them in Documents/Arduino/libraries/MBC_Sensors/ and #include <MBC_Sensors.h> (https://mbc-pro-sensors.github.io/en/makeblock.html)
// Board: Arduino Uno (the mBot mCore is an Uno). After uploading, unplug USB and run on battery.

#include <MeMCore.h>            // mBot (mCore): motors, LED, buzzer
#include <SoftwareSerial.h>
#include <MBC_Sensors.h>        // MBC sensors v2 (the same library the mBlock extension uses)

MBCPort mbc_port1(1);           // sensor on mBot port 1
MeDCMotor motorL(9);           // left wheel (M1)
MeDCMotor motorR(10);          // right wheel (M2)
MeRGBLed rgbled(7, 2);         // on-board RGB LED (2 pixels)
MeBuzzer buzzer;               // on-board buzzer

// left / right wheel power -100~100 (positive = forward): the mBot left wheel is mounted mirrored, so M1 gets the negative value; % becomes PWM 0~255
void wheels(int l, int r) {
  l = constrain(l, -100, 100); r = constrain(r, -100, 100);
  motorL.run(-l * 255 / 100);
  motorR.run(r * 255 / 100);
}

void setup() {   // everything runs inside setup(), just like the program mBlock generates
  mbc_port1.begin();
  delay(1000);   // Wait 1 s for the sensor to boot
  while (1) {   // Repeat forever
    buzzer.tone((200 + (mbcRead(mbc_port1, 0x01) * 6)), 100);   // Pitch = 200 + hue × 6 Hz, for 0.1 s
  }
}

void loop() {}   // nothing here: the blocks above never return

Step by step

  1. Wait 1 s for the sensor to boot
  2. Repeat forever
    • Pitch = 200 + hue × 6 Hz, for 0.1 s

What you should see: Red brick at the sample point: a low 200 Hz; green about 400 Hz; blue about 600 Hz; white paper or black gives the lowest note (194 Hz).

FAQ

  • No sound? → The buzzer is on the board and is not loud; listen closely, or change 0.1 s to 0.3 s.
  • The colour changes but the note does not? → The brick is not at the sample point (the cross on the sensor screen); use the COLOR setting to move the cross to where the brick will be.
  • Always "not found"? → The TRACK setting on the sensor is not done, or the tolerance is too small. Check the sensor screen: a tracking box means found.
  • Nothing happens, or the value stays at -32768? → Wrong port (every example on this page uses port 1), socket board not seated, or the sensor is not the Makeblock edition. Check with the "MBC common → connected?" block first; "protocol version" must read 2 for the new firmware (old firmware needs extension v1).
  • Upload fails, or the blocks are blank? → Make sure the switch at the bottom right is in "Upload" mode, extension v2 has been dropped into mBlock, and the USB cable goes to the mBot board.

Example 2: Green when the blob is found

What this example does: With the "blob found?" boolean and "if… then… else…": the set colour in view → green LED, not in view → red. The first decision of every blob-tracking program.

What you need

  • mBot (mCore board) + mBlock 5 desktop
  • SharpShot (school edition) (Makeblock edition) + mBot socket board
  • A brightly coloured brick (red, green or blue)

Wiring: SharpShot → mBot socket board → mBot port 1. Camera facing forward on the front. First set the colour to look for on the sensor itself (see "Before you start").

Download

mBlock 5 project Equivalent Arduino sketch
ex02_found_led.mblock ex02_found_led.ino
mBlock blocks (just rebuild them like this)
when mBot starts up :: events hat
wait (1) seconds
forever
  if <SharpShot Vision \(legacy\) port [1 v] blob found? :: #C2255C> then
    LED [all v] colour red (0) green (255) blue (0) :: looks
  else
    LED [all v] colour red (255) green (0) blue (0) :: looks
  end
end
🔧 Equivalent Arduino sketch (mBot)
// SharpShot (school edition) × mBlock 5  Example 2: Green when the blob is found  (equivalent Arduino sketch for mBot)
// Wiring: SharpShot → mBot socket board → mBot port 1. Camera facing forward on the front. First set the colour to look for on the sensor itself (see "Before you start").
// Does exactly what the mBlock block example does, for people who want to see "what is behind the blocks" or use the Arduino IDE.
// Libraries needed:
//   1. Makeblock (Arduino IDE Library Manager, search "Makeblock", or the copy inside the mBlock 5 install folder)
//   2. MBC_Sensors v2: the four files in src/ of the extension .mext (MBC_Sensors.h/.cpp, mbc_proto.h, mbc_ids.h),
//      put them in Documents/Arduino/libraries/MBC_Sensors/ and #include <MBC_Sensors.h> (https://mbc-pro-sensors.github.io/en/makeblock.html)
// Board: Arduino Uno (the mBot mCore is an Uno). After uploading, unplug USB and run on battery.

#include <MeMCore.h>            // mBot (mCore): motors, LED, buzzer
#include <SoftwareSerial.h>
#include <MBC_Sensors.h>        // MBC sensors v2 (the same library the mBlock extension uses)

MBCPort mbc_port1(1);           // sensor on mBot port 1
MeDCMotor motorL(9);           // left wheel (M1)
MeDCMotor motorR(10);          // right wheel (M2)
MeRGBLed rgbled(7, 2);         // on-board RGB LED (2 pixels)
MeBuzzer buzzer;               // on-board buzzer

// left / right wheel power -100~100 (positive = forward): the mBot left wheel is mounted mirrored, so M1 gets the negative value; % becomes PWM 0~255
void wheels(int l, int r) {
  l = constrain(l, -100, 100); r = constrain(r, -100, 100);
  motorL.run(-l * 255 / 100);
  motorR.run(r * 255 / 100);
}

void setup() {   // everything runs inside setup(), just like the program mBlock generates
  mbc_port1.begin();
  delay(1000);   // Wait 1 s for the sensor to boot
  while (1) {   // Repeat forever
    if ((mbcRead(mbc_port1, 0x0A) == 1)) {   // If a blob is found
      rgbled.setColor(0, 0, 255, 0); rgbled.show();   // Blob found: green
    } else {
      rgbled.setColor(0, 255, 0, 0); rgbled.show();   // Not found: red
    }
  }
}

void loop() {}   // nothing here: the blocks above never return

Step by step

  1. Wait 1 s for the sensor to boot
  2. Repeat forever
    • If a blob is found
      • Blob found: green
      • otherwise:
        • Not found: red

What you should see: Hold the brick in front of the camera: green (a tracking box also appears on the sensor screen); take it away: red.

FAQ

  • Always "not found"? → The TRACK setting on the sensor is not done, or the tolerance is too small. Check the sensor screen: a tracking box means found.
  • Nothing happens, or the value stays at -32768? → Wrong port (every example on this page uses port 1), socket board not seated, or the sensor is not the Makeblock edition. Check with the "MBC common → connected?" block first; "protocol version" must read 2 for the new firmware (old firmware needs extension v1).
  • Upload fails, or the blocks are blank? → Make sure the switch at the bottom right is in "Upload" mode, extension v2 has been dropped into mBlock, and the USB cable goes to the mBot board.

Example 3: One wheel turns toward the blob

What this example does: "Blob X" is where the blob is across the picture (0 far left, 50 centre, 100 far right). Left wheel only: power = (blob X − 50) × 0.8; blob on the right → wheel forward, nose turns right; on the left → reverse, nose turns left; centre → still. Not found → stop.

What you need

  • mBot (mCore board) + mBlock 5 desktop
  • mBot two-wheel robot (left wheel on M1, right wheel on M2, as shipped)
  • SharpShot (school edition) (Makeblock edition) + mBot socket board
  • A brightly coloured brick (red, green or blue)

Wiring: SharpShot → mBot socket board → mBot port 1. Camera facing forward on the front. First set the colour to look for on the sensor itself (see "Before you start").

Download

mBlock 5 project Equivalent Arduino sketch
ex03_one_wheel.mblock ex03_one_wheel.ino
mBlock blocks (just rebuild them like this)
when mBot starts up :: events hat
wait (1) seconds
forever
  if <SharpShot Vision \(legacy\) port [1 v] blob found? :: #C2255C> then
    left wheel power (((SharpShot Vision \(legacy\) port [1 v] blob X :: #C2255C) - (50)) * (0.8)) %, right wheel power (0) % :: motion
  else
    stop moving :: motion
  end
end
🔧 Equivalent Arduino sketch (mBot)
// SharpShot (school edition) × mBlock 5  Example 3: One wheel turns toward the blob  (equivalent Arduino sketch for mBot)
// Wiring: SharpShot → mBot socket board → mBot port 1. Camera facing forward on the front. First set the colour to look for on the sensor itself (see "Before you start").
// Does exactly what the mBlock block example does, for people who want to see "what is behind the blocks" or use the Arduino IDE.
// Libraries needed:
//   1. Makeblock (Arduino IDE Library Manager, search "Makeblock", or the copy inside the mBlock 5 install folder)
//   2. MBC_Sensors v2: the four files in src/ of the extension .mext (MBC_Sensors.h/.cpp, mbc_proto.h, mbc_ids.h),
//      put them in Documents/Arduino/libraries/MBC_Sensors/ and #include <MBC_Sensors.h> (https://mbc-pro-sensors.github.io/en/makeblock.html)
// Board: Arduino Uno (the mBot mCore is an Uno). After uploading, unplug USB and run on battery.

#include <MeMCore.h>            // mBot (mCore): motors, LED, buzzer
#include <SoftwareSerial.h>
#include <MBC_Sensors.h>        // MBC sensors v2 (the same library the mBlock extension uses)

MBCPort mbc_port1(1);           // sensor on mBot port 1
MeDCMotor motorL(9);           // left wheel (M1)
MeDCMotor motorR(10);          // right wheel (M2)
MeRGBLed rgbled(7, 2);         // on-board RGB LED (2 pixels)
MeBuzzer buzzer;               // on-board buzzer

// left / right wheel power -100~100 (positive = forward): the mBot left wheel is mounted mirrored, so M1 gets the negative value; % becomes PWM 0~255
void wheels(int l, int r) {
  l = constrain(l, -100, 100); r = constrain(r, -100, 100);
  motorL.run(-l * 255 / 100);
  motorR.run(r * 255 / 100);
}

void setup() {   // everything runs inside setup(), just like the program mBlock generates
  mbc_port1.begin();
  delay(1000);   // Wait 1 s for the sensor to boot
  while (1) {   // Repeat forever
    if ((mbcRead(mbc_port1, 0x0A) == 1)) {   // If a blob is found
      wheels(((mbcRead(mbc_port1, 0x05) - 50) * 0.8), 0);   // Left wheel power = (blob X − 50) × 0.8 (−40 to +40), right wheel 0
    } else {
      wheels(0, 0);   // Not found: stop
    }
  }
}

void loop() {}   // nothing here: the blocks above never return

Step by step

  1. Wait 1 s for the sensor to boot
  2. Repeat forever
    • If a blob is found
      • Left wheel power = (blob X − 50) × 0.8 (−40 to +40), right wheel 0
      • otherwise:
        • Not found: stop

What you should see: Hold the brick at the front right: the left wheel turns forward and the nose swings toward it, stopping when centred; move it left and the wheel reverses.

FAQ

  • The robot turns the wrong way and gets worse? → Swap the "+" and "−" (or swap the left and right wheel powers). The mBot ships with the left wheel on M1 and the right on M2; check your own wiring.
  • Left and right are mirrored? → H-Mirror is on in the camera settings; turn it off, or change 0.8 to -0.8.
  • Always "not found"? → The TRACK setting on the sensor is not done, or the tolerance is too small. Check the sensor screen: a tracking box means found.
  • Nothing happens, or the value stays at -32768? → Wrong port (every example on this page uses port 1), socket board not seated, or the sensor is not the Makeblock edition. Check with the "MBC common → connected?" block first; "protocol version" must read 2 for the new firmware (old firmware needs extension v1).
  • Upload fails, or the blocks are blank? → Make sure the switch at the bottom right is in "Upload" mode, extension v2 has been dropped into mBlock, and the USB cable goes to the mBot board.

Example 4: Follow the blob

What this example does: Example 3 with both wheels: turn = (blob X − 50) × 0.6, left wheel 35 + turn, right wheel 35 − turn, so the robot drives forward while keeping the blob centred, i.e. it follows the brick. Not found → stop.

What you need

  • mBot (mCore board) + mBlock 5 desktop
  • mBot two-wheel robot (left wheel on M1, right wheel on M2, as shipped)
  • SharpShot (school edition) (Makeblock edition) + mBot socket board
  • A brightly coloured brick (red, green or blue)

Wiring: SharpShot → mBot socket board → mBot port 1. Camera facing forward on the front. First set the colour to look for on the sensor itself (see "Before you start").

Download

mBlock 5 project Equivalent Arduino sketch
ex04_follow.mblock ex04_follow.ino
mBlock blocks (just rebuild them like this)
when mBot starts up :: events hat
wait (1) seconds
forever
  if <SharpShot Vision \(legacy\) port [1 v] blob found? :: #C2255C> then
    set [turn v] to (((SharpShot Vision \(legacy\) port [1 v] blob X :: #C2255C) - (50)) * (0.6))
    left wheel power ((35) + (turn)) %, right wheel power ((35) - (turn)) % :: motion
  else
    stop moving :: motion
  end
end
🔧 Equivalent Arduino sketch (mBot)
// SharpShot (school edition) × mBlock 5  Example 4: Follow the blob  (equivalent Arduino sketch for mBot)
// Wiring: SharpShot → mBot socket board → mBot port 1. Camera facing forward on the front. First set the colour to look for on the sensor itself (see "Before you start").
// Does exactly what the mBlock block example does, for people who want to see "what is behind the blocks" or use the Arduino IDE.
// Libraries needed:
//   1. Makeblock (Arduino IDE Library Manager, search "Makeblock", or the copy inside the mBlock 5 install folder)
//   2. MBC_Sensors v2: the four files in src/ of the extension .mext (MBC_Sensors.h/.cpp, mbc_proto.h, mbc_ids.h),
//      put them in Documents/Arduino/libraries/MBC_Sensors/ and #include <MBC_Sensors.h> (https://mbc-pro-sensors.github.io/en/makeblock.html)
// Board: Arduino Uno (the mBot mCore is an Uno). After uploading, unplug USB and run on battery.

#include <MeMCore.h>            // mBot (mCore): motors, LED, buzzer
#include <SoftwareSerial.h>
#include <MBC_Sensors.h>        // MBC sensors v2 (the same library the mBlock extension uses)

MBCPort mbc_port1(1);           // sensor on mBot port 1
MeDCMotor motorL(9);           // left wheel (M1)
MeDCMotor motorR(10);          // right wheel (M2)
MeRGBLed rgbled(7, 2);         // on-board RGB LED (2 pixels)
MeBuzzer buzzer;               // on-board buzzer
float turn = 0;               // variable:turn

// left / right wheel power -100~100 (positive = forward): the mBot left wheel is mounted mirrored, so M1 gets the negative value; % becomes PWM 0~255
void wheels(int l, int r) {
  l = constrain(l, -100, 100); r = constrain(r, -100, 100);
  motorL.run(-l * 255 / 100);
  motorR.run(r * 255 / 100);
}

void setup() {   // everything runs inside setup(), just like the program mBlock generates
  mbc_port1.begin();
  delay(1000);   // Wait 1 s for the sensor to boot
  while (1) {   // Repeat forever
    if ((mbcRead(mbc_port1, 0x0A) == 1)) {   // If a blob is found
      turn = ((mbcRead(mbc_port1, 0x05) - 50) * 0.6);   // turn = (blob X − 50) × 0.6 (−30 to +30)
      wheels((35 + turn), (35 - turn));   // Left = 35 + turn, right = 35 − turn: blob on the right (positive) → left wheel fast, turn right
    } else {
      wheels(0, 0);   // Not found: stop
    }
  }
}

void loop() {}   // nothing here: the blocks above never return

Step by step

  1. Wait 1 s for the sensor to boot
  2. Repeat forever
    • If a blob is found
      • turn = (blob X − 50) × 0.6 (−30 to +30)
      • Left = 35 + turn, right = 35 − turn: blob on the right (positive) → left wheel fast, turn right
      • otherwise:
        • Not found: stop

What you should see: Move the brick slowly in front of the robot and it follows; hide the brick and it stops.

FAQ

  • The robot turns the wrong way and gets worse? → Swap the "+" and "−" (or swap the left and right wheel powers). The mBot ships with the left wheel on M1 and the right on M2; check your own wiring.
  • The robot swings left and right? → Lower 0.6 (e.g. 0.4).
  • Always "not found"? → The TRACK setting on the sensor is not done, or the tolerance is too small. Check the sensor screen: a tracking box means found.
  • Nothing happens, or the value stays at -32768? → Wrong port (every example on this page uses port 1), socket board not seated, or the sensor is not the Makeblock edition. Check with the "MBC common → connected?" block first; "protocol version" must read 2 for the new firmware (old firmware needs extension v1).
  • Upload fails, or the blocks are blank? → Make sure the switch at the bottom right is in "Upload" mode, extension v2 has been dropped into mBlock, and the USB cable goes to the mBot board.

Example 5: Follow, stop when close, with lights

What this example does: Examples 2 and 4 combined, plus "blob area": not found → stop with red; area over 2500 (the brick is close) → stop with blue and a beep; otherwise follow with green. The full "find the target → drive to it → stop there" routine.

What you need

  • mBot (mCore board) + mBlock 5 desktop
  • mBot two-wheel robot (left wheel on M1, right wheel on M2, as shipped)
  • SharpShot (school edition) (Makeblock edition) + mBot socket board
  • A brightly coloured brick (red, green or blue)

Wiring: SharpShot → mBot socket board → mBot port 1. Camera facing forward on the front. First set the colour to look for on the sensor itself (see "Before you start").

Download

mBlock 5 project Equivalent Arduino sketch
ex05_follow_stop.mblock ex05_follow_stop.ino
mBlock blocks (just rebuild them like this)
when mBot starts up :: events hat
wait (1) seconds
forever
  if <SharpShot Vision \(legacy\) port [1 v] blob found? :: #C2255C> then
    if <(SharpShot Vision \(legacy\) port [1 v] blob area :: #C2255C) > (2500)> then
      stop moving :: motion
      LED [all v] colour red (0) green (0) blue (255) :: looks
      play tone (880) Hz for (0.3) seconds :: sound
    else
      LED [all v] colour red (0) green (255) blue (0) :: looks
      set [turn v] to (((SharpShot Vision \(legacy\) port [1 v] blob X :: #C2255C) - (50)) * (0.6))
      left wheel power ((35) + (turn)) %, right wheel power ((35) - (turn)) % :: motion
    end
  else
    stop moving :: motion
    LED [all v] colour red (255) green (0) blue (0) :: looks
  end
end
🔧 Equivalent Arduino sketch (mBot)
// SharpShot (school edition) × mBlock 5  Example 5: Follow, stop when close, with lights  (equivalent Arduino sketch for mBot)
// Wiring: SharpShot → mBot socket board → mBot port 1. Camera facing forward on the front. First set the colour to look for on the sensor itself (see "Before you start").
// Does exactly what the mBlock block example does, for people who want to see "what is behind the blocks" or use the Arduino IDE.
// Libraries needed:
//   1. Makeblock (Arduino IDE Library Manager, search "Makeblock", or the copy inside the mBlock 5 install folder)
//   2. MBC_Sensors v2: the four files in src/ of the extension .mext (MBC_Sensors.h/.cpp, mbc_proto.h, mbc_ids.h),
//      put them in Documents/Arduino/libraries/MBC_Sensors/ and #include <MBC_Sensors.h> (https://mbc-pro-sensors.github.io/en/makeblock.html)
// Board: Arduino Uno (the mBot mCore is an Uno). After uploading, unplug USB and run on battery.

#include <MeMCore.h>            // mBot (mCore): motors, LED, buzzer
#include <SoftwareSerial.h>
#include <MBC_Sensors.h>        // MBC sensors v2 (the same library the mBlock extension uses)

MBCPort mbc_port1(1);           // sensor on mBot port 1
MeDCMotor motorL(9);           // left wheel (M1)
MeDCMotor motorR(10);          // right wheel (M2)
MeRGBLed rgbled(7, 2);         // on-board RGB LED (2 pixels)
MeBuzzer buzzer;               // on-board buzzer
float turn = 0;               // variable:turn

// left / right wheel power -100~100 (positive = forward): the mBot left wheel is mounted mirrored, so M1 gets the negative value; % becomes PWM 0~255
void wheels(int l, int r) {
  l = constrain(l, -100, 100); r = constrain(r, -100, 100);
  motorL.run(-l * 255 / 100);
  motorR.run(r * 255 / 100);
}

void setup() {   // everything runs inside setup(), just like the program mBlock generates
  mbc_port1.begin();
  delay(1000);   // Wait 1 s for the sensor to boot
  while (1) {   // Repeat forever
    if ((mbcRead(mbc_port1, 0x0A) == 1)) {   // If a blob is found
      if ((mbcRead(mbc_port1, 0x09) > 2500)) {   // If the blob area is greater than 2500
        wheels(0, 0);   // Blob is large (close): stop
        rgbled.setColor(0, 0, 0, 255); rgbled.show();   // Blue LED
        buzzer.tone(880, 300);   // Beep
      } else {
        rgbled.setColor(0, 0, 255, 0); rgbled.show();   // Green LED
        turn = ((mbcRead(mbc_port1, 0x05) - 50) * 0.6);   // turn = (blob X − 50) × 0.6
        wheels((35 + turn), (35 - turn));   // Left = 35 + turn, right = 35 − turn
      }
    } else {
      wheels(0, 0);   // Not found: stop
      rgbled.setColor(0, 255, 0, 0); rgbled.show();   // Red LED
    }
  }
}

void loop() {}   // nothing here: the blocks above never return

Step by step

  1. Wait 1 s for the sensor to boot
  2. Repeat forever
    • If a blob is found
      • If the blob area is greater than 2500
        • Blob is large (close): stop
        • Blue LED
        • Beep
        • otherwise:
          • Green LED
          • turn = (blob X − 50) × 0.6
          • Left = 35 + turn, right = 35 − turn
      • otherwise:
        • Not found: stop
        • Red LED

What you should see: Brick 1 m ahead: the robot drives to it with a green LED, turns blue and beeps as it stops in front; remove the brick and it goes red.

FAQ

  • It stops too early, or only after bumping the brick? → Area depends on brick size: read A (area) on the sensor screen at the distance where you want it to stop, then change 2500.
  • The robot turns the wrong way and gets worse? → Swap the "+" and "−" (or swap the left and right wheel powers). The mBot ships with the left wheel on M1 and the right on M2; check your own wiring.
  • Always "not found"? → The TRACK setting on the sensor is not done, or the tolerance is too small. Check the sensor screen: a tracking box means found.
  • Nothing happens, or the value stays at -32768? → Wrong port (every example on this page uses port 1), socket board not seated, or the sensor is not the Makeblock edition. Check with the "MBC common → connected?" block first; "protocol version" must read 2 for the new firmware (old firmware needs extension v1).
  • Upload fails, or the blocks are blank? → Make sure the switch at the bottom right is in "Upload" mode, extension v2 has been dropped into mBlock, and the USB cable goes to the mBot board.

Next steps

More questions

  • Blocks keep returning 0? Check the port in the block matches the real port and that the program was uploaded to the board.
  • Does the old extension still work? Sensors shipped before 2026-10 use the legacy v1.0.0 extension; old and new blocks are not compatible.

Still stuck? Contact us with your software and a screenshot of the program.

Downloads

Sources

  • Host and software list:_build/guides.json
  • Values and commands:_build/protocol/cam_school.json、_build/protocol/cam_wro.json (single source of truth)
  • Setup:_build/guides/software/mblock-mblock5.en.md、_build/guides/product/esp32cam/mblock-mblock5.en.md
  • Examples:sensors/esp32cam/mblock-examples(-wro).md
Email for a quoteBuying Guide