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. Looking for the current SharpShot Vision? →
MBC SharpShot Vision WRO edition (HUE12) × Pybricks blocks

Read the SharpShot WRO edition with Pybricks blocks in three steps

Blocks follow the same order as MicroPython: first import the library under "set up", then create an object and give the sensor a name, and finally use that name under "program" to call a function. 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 Pybricks Code, so they look the same as on your screen.

Check first: Pybricks block mode needs a licence code or a Patreon membership. Without one you can type MicroPython instead; it works exactly the same (switch the right panel to "Matching MicroPython" to see it).

1

Import the library

The first thing in a block program is a red "from … import …" block under the yellow "set up". It tells Pybricks to use the WRO edition library.

Pick one library (the blocks are the same; only the name after from is different):

  1. Download the library (save the file and keep its name): MBC_hue12.py (only this sensor) or MBC_sensors.py (the all-in-one library). You picked MBC_hue12.py.
  2. In Pybricks Code, press "Import a file" in the file panel on the left and import it into the same project. Do not rename the file.
  3. Press "+" to add a new file and choose blocks.
  4. Drag the red "from … import …" block from the block list, attach it under "set up" and pick the two names.

The hub needs Pybricks firmware v4.0.0b5 or newer. Older firmware cannot read the WRO edition (all 12 points stay at 255).

2

Create an object: give the sensor a name

Drag a red "… is a …" block and attach it under the import block. On the far left is the name you give the sensor; after it come the port and whether to multitask. Every time you want a reading, you pick this name. When the program starts, the computer screen prints Connected to ID: 95. 95 means the sensor is the WRO edition.

Which port is the sensor on?

Give it a name (in Pybricks you can use any English name; here are three to try):

Turn on multitasking? (the green true / false on the block)

The port box takes a number: SPIKE 1~6 = A~F, so 3 is port C.

3

Use the functions

Put red function blocks under "program": pick the name hue12 in the first box, await in the middle and the function in the last box. The WRO edition needs an update block first (it reads the latest 12 points), then get_slot gives you the colour of one point. Click a function and the blocks and output change to its example.

Simulated camera picture (12 points in a row): click a box to change its colour and watch the output on the right
Colour to paint (pick a colour, then click a box above):

This picture is only an illustration: each colour uses one sample number. Real hue and saturation change with the light and the object. You set the positions of the 12 points on the sensor; here they sit in a row so they are easy to see (point 1 is on the far left). The red frame = point 1, which the examples read. The number under each box is the hue the program reads.

Block examples for every function

5 functions, each with a set of blocks you can copy (name hue12, multitasking true). Press "Try it" to jump to step 3; the blocks and output on the right change to that example.

Good to know

  1. Import the library file into the project first. Without MBC_hue12.py in the project, you cannot pick MBC_HUE12 in the red blocks.
  2. await and call must match multitasking: multitasking true = pick await; multitasking false = pick call. If you mix them, the program fails on the hub.
  3. Always update first: get_slot does not read the sensor by itself. It only gives you what update saved. Without an update block first, all 12 points stay at ('NONE', 255, 0). One update block per loop is enough.
  4. Unplugging does not stop the program: when the sensor cannot be read, update returns False and get_slot returns the last reading. The computer screen prints one warning line that starts with MBC: Port (in Chinese and English). Use the sensor_ok function to check the connection. device_id and firmware_version are not available on this sensor (they give a ValueError). To check that the WRO edition is connected, look for Connected to ID: 95 at the start.
  5. Behind the blocks is MicroPython. The code pane on the right of Pybricks Code is the program the blocks make. It is the same as "Matching MicroPython" on this page (the multitasking version has one extra line await wait(0), which Pybricks adds by itself). Hue 0 to 239 = a colour, 240 to 245 = white, 246 to 250 = black, 255 = this point is not set.