MBC PS2 / PS4 Controller receiver × MBC SPIKE Blocks website

Read the PS2 / PS4 Controller receiver with the MBC Blocks website in three steps

On the MBC SPIKE Blocks website you do not import a library for the Controller receiver. First, inside "run once at start", tell the website which port the receiver is on; then add the main loop; finally put value blocks into the main loop. Work through the steps on the left and the blocks on the right grow with you. These block pictures were built and exported straight from the website, so they look the same as on the website.

The website is in Chinese. The blocks on the website are in Chinese, so every block below comes with an English explanation: the Chinese block name first, then what it means in English in brackets. Match the Chinese words with what you see on screen.

The website is free and needs no login. The hub needs the Pybricks firmware (the "SPIKE 主機" (SPIKE Hub) menu on the website can install it for you).

1

Set up: which port has the Controller receiver

The first thing in the program is a "○ 埠 接 MBC PS2/PS4遙控" (port ○ has the MBC PS2 / PS4 controller) block under the yellow "開機時執行一次" (run once at start). Then the website knows that this port has the receiver.

Which port is the receiver plugged into?
  1. Open the MBC SPIKE Blocks website and press "+" to start a new program.
  2. In the block categories on the left, click "MBC 感應器" (MBC sensors) → "PS2/PS4遙控" (PS2 / PS4 controller). The first block is "○ 埠 接 MBC PS2/PS4遙控".
  3. Attach it under "開機時執行一次" (run once at start) and pick C in its dropdown.
2

Add the main loop

The gamepad must be read again and again, so you need the yellow "主迴圈(一直重複)" (main loop, repeat forever). Put one "等待 100 毫秒" (wait 100 ms) block inside first, so it reads every 0.1 s and not too fast.

  1. From "控制" (Control), drag out "主迴圈(一直重複)" (main loop) and drop it in an empty space under the setup blocks (it does not need to snap on).
  2. Drag one "等待 100 毫秒" (wait 100 ms) into the main loop.

The Python that the website makes goes into a multitasking structure (async) by itself. You do not choose it, and you do not write await.

3

Use the value blocks

"MBC 感應器 → PS2/PS4遙控" has 13 more value blocks (every function in the Pybricks library is there). Each one has a port dropdown in the middle; pick the same port as in step 1 (C). Which button or which stick is also picked from a dropdown. Every value block gets the newest data, so you do not need update like in Pybricks. Click a function and the blocks and output change to its example.

Gamepad simulator: click the buttons, drag the sticks, and watch the output on the right

The simulator is only a sketch: click a button once to hold it, click it again to let go. Drag the dot on a stick to move it (it stays where you let go; press "Release all" to centre it). Sticks go from 1 to 9, 5 = centre, and the number gets bigger to the right and up. Tick "Unplug the sensor" to see the values stay at the last reading while the program keeps running. The PS4 gamepad battery is fixed at 80 in this demo.

An example for every value block

13 value blocks, each with a set of blocks you can copy (port C). Press "Try it" to jump to step 3; the blocks and output on the right change to that example.

Tips

  1. You need only one setup block. Each port can be set up only once. The port on every value block must match the setup block; if you pick the wrong port, the website warns you before it downloads.
  2. No library to download, and no update. When the website downloads your program, it sends the code that reads the gamepad to the hub too. Every value block gets the newest data (reads within 10 ms share the same data, so several blocks in one loop are fine).
  3. Same as the Pybricks library: every function in MBC_gamepad.py has a block here (connected = "手把有連上", battery = "手把電量", kind = "接收器種類", buttons_psx / pressed_psx = the two "PSX 排列" blocks), and you read the same values. Unplugging does not stop the program: when the receiver cannot be read, you get the last value, the terminal prints one warning line, and it works again by itself when you plug it back in. Use "感應器有接好" (sensor plugged in properly) to check the connection. If you unplug while driving with a stick, the robot keeps driving with the last stick position. (The warning line is in Chinese and English.)
  4. Read the status blocks only now and then. "手把有連上" (connected) and "手把電量" (battery) are one set of data; "接收器種類" (receiver type), "感應器身分" (sensor ID) and "感應器韌體版本" (firmware version) are another set, separate from the buttons and sticks. Each time you switch sets, the receiver has to switch once (a few tens of ms more). "手把有連上" and "手把電量" need receiver firmware from 2026-10 or later. Put "接收器種類", "感應器身分" and "感應器韌體版本" inside "開機時執行一次" (run once at start).
  5. Sticks and buttons: sticks go from 1 to 9, 5 = centre, and the number gets bigger to the right and up. When you use a stick as a switch, use 7 or more and 3 or less, so both sides feel the same. In the dropdown, SELECT = SHARE on PS4 (Create on PS5) and START = OPTIONS. The PS button and the touchpad cannot be read.