MBC PS2 / PS4 receiver × EV3-G (EV3 Lab software)

Read the receiver with EV3-G in three steps

In the EV3 software (EV3-G), the PS2 / PS4 receiver shows up as a LEGO Infrared Sensor. So you do not import a library: you read it with the Infrared Sensor block in the right mode. Work through the steps on the left and the blocks on the right grow with you. These pictures were taken in EV3-G after opening each program (100% size, English interface), so they look exactly like the software.

1

Start: Start block + Loop

You need to read the sensor again and again. A new program already has the green Start block. Attach an orange Loop block after it and put a Wait block inside, so it reads every 0.1 seconds.

  1. Open the EV3 software (EV3-G) and make a new project.
  2. Drag a Loop from the orange Flow Control tab and attach it after the Start block (it repeats forever by default).
  3. Drag a Wait block into the loop, choose the Time mode and set it to 0.1 seconds.
2

Meet the reading blocks (Infrared Sensor)

On the EV3, the PS2 / PS4 receiver shows up as a LEGO Infrared Sensor. Drag the Infrared Sensor block from the yellow Sensors tab and choose the mode at the bottom left of the block; the number at the top right is the port: choose 1 (the sensor is in port 1). The product puts different values in different modes:

BlockWhat you getRange
Measure → ProximityD-pad0 to 15
Measure → Beacon, channel 2: HeadingShape buttons0 to 15
Measure → Beacon, channel 3: HeadingShoulder buttons0 to 15
Measure → Beacon, channel 4: HeadingFunction buttons0 to 15
Measure → Beacon, channel 1: ProximityLeft stick (#1: LX)0 to 99 (50 = centre)
Measure → Beacon, channel 2: ProximityLeft stick (#2: LY)0 to 99 (50 = centre)
Measure → Beacon, channel 3: ProximityRight stick (#1: RX)0 to 99 (50 = centre)
Measure → Beacon, channel 4: ProximityRight stick (#2: RY)0 to 99 (50 = centre)

Use blocks of only one mode in a program (Proximity, Beacon or Remote). Every mode change makes the EV3 pause for about 1.1 seconds.

3

Show it on the EV3 screen

Use the Text block from the red Data Operations tab to join a name (for example POS) and the reading, then feed it into the green Display block (mode Text → Grid, Y = the line). The yellow and orange lines are data wires: drag one from the sensor to the Text block, and one from the Text block to the Display block. Put a "Display → Reset Screen" block before the loop. Click a function and the blocks and result 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 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). On the EV3 the sticks go from 0 to 99, 50 = centre, bigger to the right and up.

Block example for each function

Every value EV3-G can read has a small program you can copy (sensor in port 1). Press "Try it" to jump to step 3.

What EV3-G cannot read: the 16-button number, whether the pad is connected (mode 3), battery, how far L2 / R2 are pressed, PS button and touch pad, pad type, device ID and firmware version. Rumble and light bar (PS4 only) are commands, and the EV3 port cannot send commands. The modes 3 to 6 added in firmware v4.0 (for example millimetre distances, bitmaps, connection state, device ID) cannot be read with EV3-G blocks either. For these, use Pybricks (the EV3 needs a different microSD card) or clev3r.

Things to know

  1. Plug the sensor into port 1. If you use another port, change the port number on the block. Switch the EV3 on first, then plug in the sensor; if the number never changes, unplug it and plug it in again.
  2. Use one mode per program. Each change between Proximity, Beacon and Remote makes the EV3 pause for about 1.1 seconds, and a racing robot can lose control.
  3. When the sensor is unplugged: the EV3 cannot read it, the number becomes "not a number" and the screen shows ----. Each reading also waits about 1.2 seconds. The program does not stop, and it works again when you plug the sensor back in.
  4. One mode is enough: Beacon mode has all the buttons and both sticks at once (heading = buttons, proximity = sticks). A driving program that only uses it never switches modes.
  5. When the pad is not connected: buttons are 0 and sticks are 50 (centre), so the robot does not run off. The PS2 and PS4 receivers give exactly the same numbers on the EV3.
  6. English interface: the block icons are the same in other languages; only the menu text differs.
  7. For complete projects (line following, avoiding obstacles, driving …) see the EV3 examples page; most examples have an EV3-G file to download.