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

Read the SharpShot WRO edition with MicroPython in three steps

A Pybricks program always goes in this order: first import the library, then create an object and give the sensor a name, and only then use that name to call a function. Work through the steps on the left and the program on the right grows with you. Click the boxes in the simulated camera picture to change colours and see what the program prints.

Your hub:
1

Import the library

The first thing in the program tells Pybricks "I want to use the WRO edition library". Without this line the hub does not know what MBC_HUE12 means, and you get a NameError.

Pick one library (both work the same; only the import line 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.
  3. Do not rename the file, and do not put it in a sub-folder.
  4. Go back to the main program and type the lines below at the very top (marked ① in the program on the right).

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

A robot can have several sensors, so you "create an object": you tell the program which port the sensor is on and give it a name. Every time you want a reading, you use this name. When the object is created, the computer screen prints Connected to ID: 95. 95 means the sensor is the WRO edition.

Which port is the sensor on?

Turn on multitasking?

The 3 in the program is the port number: SPIKE 1~6 = A~F. You can also write Port.C, but then you also need from pybricks.parameters import Port.

3

Use the functions

You always write "hue12.function_name()": the name, a dot, then the function. The WRO edition needs update() first to read the latest 12 points, then get_slot() gives you the colour of one point. Click a function and the program 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.

An example for every function

5 functions, each with a short example you can put straight into your program. Press "Try it" to jump to step 3; the program and output on the right change to that example.

Full examples

Turn by colour (SPIKE, left wheel E, right wheel F)

        

!Only change the "things to change" part at the top. Point 1 sees red: the robot turns right on the spot. Green: it turns left on the spot. Any other colour: it stops. Nothing happens on green? Use get_slot() to see your green's hue first, then change 60 to 110. The robot turns the wrong way? Move Direction.COUNTERCLOCKWISE to the other motor.

All 12 points at once

        

!Call update() only once per loop. Reading the 12 points after that uses the data you just read, so it does not slow down. It prints something like ['Red', 'Grn', 'Wht', …].

Multitasking (advanced)

        

!Write True as the 2nd value when you create the object, and create the object outside run_task(). Put await in front of every function, even get_slot().

Use it with other MBC sensors

        

!Switch to the all-in-one library: change only the import line and import MBC_sensors.py. Do not import both libraries at the same time.

Good to know

  1. Always call update() first. get_slot() does not read the sensor by itself. It only gives you what update() saved. Without update(), all 12 points stay at ('NONE', 255, 0). Call it once per loop; reading many points after that does not slow down.
  2. Unplugging does not stop the program. When the sensor cannot be read, update() returns False and get_slot() returns the last reading (('NONE', 255, 0) if it never got one). The computer screen prints one warning line that starts with MBC: Port (in Chinese and English). Plug it back in and it works again by itself. Use sensor_ok() to check the connection. Tick "Unplug the sensor" on the right to see this.
  3. How to read the hue: 0 to 239 = a colour (red is at both ends: 0 to 9 and 230 to 239); 240 to 245 = white; 246 to 250 = black; 255 = this point is not set (while the sensor is in its menu, all 12 points are 255 too). Colour names: Red red, Org orange, Yel yellow, Lim lime, Grn green, Mnt mint, Cyn cyan, Azr azure, Blu blue, Prp purple, Mag magenta, Pnk pink, Wht white, Blk black, NONE not set.
  4. No ID data: this sensor cannot give device_id() or firmware_version(). Both SPIKE and EV3 show a ValueError. To check that the WRO edition is connected, look for Connected to ID: 95 when the object is created. If it is not 95, it is the wrong sensor, or the hub's Pybricks firmware is too old.
  5. Advanced: all 12 points at once. hue12.slots is a list of the 12 points (call update() first here too). Each point is (hue, saturation, name). The order is different from get_slot(), and you do not put await in front of it. SPIKE and EV3 read the same data, so you use it the same way on both.