MBC PS2 / PS4 Controller receiver × mBlock 5(mBot)

Read the Controller in mBlock 5 in three steps

In mBlock 5 for PC, add the MBC Pro Sensors extension v2 and you can read the Controller on an mBot with blocks. First add the extension and plug into a port. Then, under "when mBot starts up", wait for the sensor to start and add "forever". Last, put the Controller blocks inside. Follow the steps on the left, and the blocks on the right grow with you. The mBot has no screen, so the examples use the buzzer, the LED and the wheels to show you what was read.

Extension v2.0.0 is under review on the Makeblock extension platform (being listed), so its blocks cannot be exported from mBlock yet. The block pictures on this page are drawn with scratchblocks from the extension's own block text and category colours, so they look about the same as in mBlock. On the right you can switch to "Arduino program". For every value's number and range, see PS2 / PS4 Controller receiver × mBlock 5 guide.

1

Add the extension and plug in

mBlock needs the MBC Pro Sensors extension v2 first; then a "Controller" category appears in the block palette. Every block has a port menu: pick the number the sensor is really plugged into, and the extension uses the right pins for your board.

Which mBot port is the Controller plugged into?
  1. Open mBlock 5 for PC, add mBot under "Devices" at the bottom left, and switch the mode toggle at the bottom right to Upload.
  2. Add the extension: once it is listed, search "MBC" in the "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), click "Download" to get a .mext, and drag it into the mBlock window.
  3. Six new categories appear: Pathfinder, Ranger, Controller, IMU gyro, Vision and MBC common.
  4. Controller → mBot adapter → mBot port 4; pick port 4 on the blocks too.
BoardUsable portsNotes
mBot (mCore)1, 2, 3, 4all four ports
mBot Ranger (Auriga)6 ~ 101 ~ 4 are red motor ports, 5 is the serial port
Orion3, 4, 61, 2 are red motor ports; 7, 8 are analog only
Ultimate 2.0 (MegaPi)6, 7, 8needs the RJ25 adapter board; 5 is the serial port
MegaPi Pro7, 8, 9, 10needs the RJ25 adapter board

The simulator here covers the mBot only (ports 1 ~ 4). For another board, swap "when mBot starts up" for that board's start block and use one of its usable ports. mBot2 (CyberPi) has no RJ25 port and is not supported.

2

Start-up: wait 1 s for the sensor

The program starts at "when mBot starts up". Under it, first put "wait 1 seconds" so the sensor can start; reading too early gives −32768. Then add "forever", because you read a sensor again and again.

  1. From "Events", drag out "when mBot starts up".
  2. From "Control", drag "wait (1) seconds" under it.
  3. From "Control", drag "forever" to the bottom.

In Upload mode the program is flashed into the mBot, so it also runs on battery with the USB cable unplugged. You do not need a wait inside "forever": every reading block waits for the sensor's answer (at most 0.01 s).

3

Use the Controller blocks

In the "Controller" category, the PS2 / PS4 Controller receiver uses 16 blocks (values, true/false and commands), and "MBC common" has 8 more. Every block's port must be the same number as in step 1 (4). Click a function, and the blocks, the Arduino program and what the mBot does on the right change to its example.

Gamepad simulator: click buttons and drag the sticks, and watch what the mBot does

The simulator is only a picture: click a button to hold it, click again to let go. Drag a stick's dot to move it (it stays where you let go; "Release all" centres it). Sticks are −100 ~ 100, 0 = centre, right and up are positive; L2 / R2 pressed = 255. The PS4 pad battery is shown as 80 and firmware version 100 is an example value.

An example for every block

24 blocks (including "MBC common"). Each one has an example you can copy (port 4). Press "Try it" to jump to step 3. The blocks and what the mBot does on the right change to that example.

Good to know

  1. Extension v2 is being listed: MBC Pro Sensors extension v2.0.0 is under review on the Makeblock extension platform. Once it is listed, search "MBC" in the mBlock 5 "Extension Center" to add it. The sensor must be the Makeblock edition with protocol v2 firmware (from 2026-10). Firmware from before 2026-10 needs the legacy extension v1.0.0, and the old and new blocks do not mix (read the "protocol version" block: 2 means new firmware). See MakeBlock extension.
  2. When nothing can be read: if the port cannot be used or the sensor is not connected, reading blocks give −32768 (never read since power-on) or the last value read, and the program keeps running. "MBC common → connected?" is false. Check the cable with it first, then look at the values.
  3. The matching Arduino program: switch the right panel to "Arduino program" to see an Arduino sketch that does the same as the blocks (the MBC_Sensors v2 library, the same one the extension uses, plus the Makeblock library). Every example has been compiled (board: Arduino Uno). See MakeBlock extension for how to install the libraries.
  4. PS2 or PS4: both receivers use the same blocks. Those marked "PS4 only" (battery, system buttons, rumble, light bar colour) give 0 or are ignored on PS2; gamepad types 3 and 4 also only appear with the PS4 receiver.
  5. Stick direction: right and up are positive (up to 100); let go and it returns to 0. There is a small dead zone around the centre, so a light touch reads 0.
  6. When the gamepad is not connected: the receiver still answers, but every button is 0 and the sticks are centred. To tell "gamepad not connected" from "receiver not plugged in", check "gamepad connected?" and "connected?" separately.