This page has moved into the new guide: Controller PS4/PS5 › micro:bit › MakeCode

Gamepad Receiver PS4/PS5 × micro:bit (MakeCode extension)

Back to Gamepad Receiver PS4/PS5

The universal I2C edition of the Gamepad Receiver PS4/PS5 works with BBC micro:bit V1 / V2 through the MakeCode extension pxt-mbc-sensors v2 (which speaks MBC I2C protocol v2). Installation and hardware notes (3.3 V, power): micro:bit overview.

SPIKEEV3Arduino I2CmBlockMATRIXmicro:bit

Important

Extension v2 is not yet verified on hardware; block names follow the published release: https://github.com/contactmbcrobot/pxt-mbc-sensors

Wiring

Gamepad Receiver PS4/PS5 × micro:bit
Sensor micro:bit
SDA(RX) P20
SCL(TX) P19
VCC must use external 5 V (share GND with the micro:bit)
GND GND

Reporter blocks

Block Returns Id Meaning
gamepad buttons bit mask 0~65535 bit 01 all buttons in one 16-bit word (PSX layout): bit0 SELECT(SHARE), 1 L3, 2 R3, 3 START(OPTIONS), 4 up, 5 right, 6 down, 7 left, 8 L2, 9 R2, 10 L1, 11 R1, 12 triangle, 13 circle, 14 cross, 15 square; 1 = pressed; 0 when not connected
gamepad [d-pad] buttons (0-15) 0~15 bit 02 up 1, right 2, down 4, left 8, added when pressed together (0~15)
gamepad [shapes] buttons (0-15) 0~15 bit 03 triangle 1, circle 2, cross 4, square 8, added when pressed together (0~15)
gamepad [shoulders] buttons (0-15) 0~15 bit 04 L2 1, R2 2, L1 4, R1 8, added when pressed together (0~15)
gamepad [functions] buttons (0-15) 0~15 bit 05 SELECT(SHARE) 1, L3 2, R3 4, START(OPTIONS) 8, added when pressed together (0~15)
gamepad is connected 0~1 06 1 = gamepad connected and data seen within 300 ms, 0 = not connected (buttons 0, sticks centred while disconnected)
gamepad battery percent 0~100 % 07 gamepad battery 0~100 (always 0 on the PS2 receiver)
gamepad trigger [L2] analog 0~255 08 L2 trigger depth 0~255 (0 when not connected)
gamepad trigger [R2] analog 0~255 09 R2 trigger depth 0~255 (0 when not connected)
gamepad type 0~4 0B 0 none, 1 PS2 digital, 2 PS2 analog, 3 PS4, 4 PS5 (or other)
gamepad joystick [left X / left Y / right X / right Y] -100~+100 10~13 10 LX, 11 LY, 12 RX, 13 RY: −100 to +100, 0 = centre, right/up positive; 0 when not connected

More blocks (yes / no, events)

Block Related value
gamepad button [cross] is pressed 01
on gamepad button [cross] [pressed] 01

Command blocks

Block Id Meaning
gamepad rumble strength 200 E5 [strength 0~255], 0 = stop; 200 ms per call (ignored by PS2)
gamepad light bar colour #ff0000 E6 [R][G][B] each 0~255, exactly 3 bytes; remembered until connected; default blue (0,0,255) (ignored by PS2)

Status

bit Name Meaning
b0 ready (ready) always 1
b1 gamepad connected (connected) same as value 06 (linkActive)

JavaScript

if (!(mbc.waitReady(0x42, 3000))) {
    basic.showIcon(IconNames.No)   // nothing answers: check wiring and power
}
basic.forever(function () {
    basic.showNumber(mbc.padButtons())   // 16 buttons
    basic.pause(100)
})

Sources and assumptions

Generated by _build/gen-reference.mjs from _build/protocol/ps4.json (single source of truth, transcribed from the 2026-10-21 protocol decisions).

  • 值表、命令、旗標與 PS2 完全相同(mBlock 定案「兩款相同」+I2C 定案 §3/§4);只有 hw0 = 2、model = PS4、E5/E6 有作用。
  • D3:SPIKE 模式 0 教育版 byte 6~7、模式 6 v[2]、模式 9 v[6] 的 button16 都是 PSX 排列(#65 已把 PS4 改成 PSX,盤點檔寫的 Bluepad32 排列已過時)。
  • 0x22 命令 4 同時裝方向鍵(低 nibble)與形狀鍵(高 nibble)、命令 5 裝肩鍵(低)與功能鍵(高);JSON 只能把一個命令掛在一個值上,所以掛在 02/04,03/05 的 ch22 = null(內容寫在 02/04 的 note)。SPIKE 模式 0/1/2/9 的 nibble 也用同樣方式在 note 說明。
  • 搖桿:I2C/mBlock 送 ±100;EV3/0x22送 099(50 = 中間)、SPIKE 送 19(5 = 中間),不是線性 offset,主機端各自換算(網站範例已是這樣)。
  • EV3 模式 3 = 方向鍵 | 形狀鍵<<4 | 已連線<<8(#67 新增 bit8);模式 4 內容不變([方向鍵, LX, 形狀鍵, LY]);模式 5 改送裝置 ID 格式 B [0x42 | 2<<8, 韌體版]。
  • SPIKE 模式 3 改 [已連線, 電量, 0](3×int8)、模式 8 改 [0x42 | 2<<8, 協議版 2, 韌體版, 更新序號];其餘空模式 1、2、4、6 維持現狀。
  • ESP32 從機不能時脈延展:I2C v2 在 onReceive 就預載從該編號起 32 B;0x22照 MATRIX 定案 §5 #2 預載最新一包,待上機。
  • I2C 0A 系統鍵 b1 = 擷取鍵(v1 0x15 放在 b3,v2 改 b1,照 I2C 定案 §4)。
  • The extension reads Int16LE and pauses 2 ms after writing the id (D5); with no sensor answering, reporters return 0 and yes / no blocks return false.
Email for a quoteBuying Guide