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 × LEGO SPIKE App (Python)

Read SharpShot Vision with SPIKE App Python in three steps

The LEGO SPIKE App (Education) runs Python too, with no hub firmware change. In the App, SharpShot Vision is a color sensor, and the App cannot import your own files, so the order is: first paste the reading helper at the top, then create an object and name the camera, then call update() once per loop and call its functions with that name. Work down the steps on the left and watch the program grow on the right; drag the blob and change its colour and size in the simulated camera view to see what the program prints.

1

Paste the reading helper

A SPIKE App Python project is a single file and cannot import your own .py, so paste the whole "reading helper" at the very top (its first lines say so: copy it as is). Without it the hub does not know CamSchoolApp and stops with NameError.

  1. Open the LEGO SPIKE App (Education, yellow SPIKE Prime hub), create a project and choose "Python".
  2. Paste the program marked ① on the right at the top (only the first helper line shows; press "Show helper" to see it all, and "Copy program" always copies everything). The helper alone: MBC_cam_school_App_helper.py (open it in a text editor and copy all; the file has Chinese and English comments).
  3. Plug the camera into any port A–F; the hub powers it. Use the same port as in step 2. Set the colours on the camera first: "1: COLOR" picks the colour point and "2: TRACK" the colour to follow (the program cannot change them).

The helper splits the numbers the App reads for you (the same conversion as the SPIKE App blocks page):

What the App readsWhat it holdsHelper function
color_sensor.color() (color)hue at the colour point: −1, 0–100hue()
color_sensor.reflection() (reflection)motion (how much the picture changed) 0–100motion()
color_sensor.rgbi() item 1 (raw red)blob X: left 0 – right 98; 0 = not foundblob_x()
rgbi() item 2 (raw green)blob Y: bottom 1 – top 75; 0 = not foundblob_y()
rgbi() item 3 (raw blue)blob area 0–100, 0 = not foundarea(), found()
2

Create the object: name the sensor

A robot can have several sensors, so you "create an object": tell the helper which port the camera is on (port.C comes from from hub import port) and give it a name. You use that name for every reading.

Which port is the camera on?
3

update() every loop, then use a function

App programs go in async def main(): and runloop.run(main()) starts them; wait with await runloop.sleep_ms(100) (not Pybricks' wait()). Each loop first reads once with .update(), then uses "name + dot + function". Pick a function and the program and output switch to its example.

Pretend sensor (what the camera sees): drag the blob and watch the output on the right

The pretend picture is only a guide: the numbers are simplified, and a real sensor can be a few steps off because of the light. Cross = sample point (the spot you picked on the sensor in "Setup 1: COLOR"); hue, saturation and brightness are read at the cross. Green box = the blob the sensor is tracking (the colour you picked in "Setup 2: TRACK"). X: left 0, right 98. Y: bottom 1, top 75.

An example for every function

Every function has an example you can drop into main() (port C). "Try it" jumps to step 3 and the program and output on the right switch to it.

Full examples

Press "Copy" for the whole program (helper included).

Turn toward a blob (left wheel E, right wheel F)

        

!Choose the colour with "2: TRACK" on the camera first. Not seen: it spins to search; seen: it steers by how far X is from the middle. Swings too much: lower GAIN.

Values the SPIKE App cannot read

The App only reads the camera's "combined data" (hue, motion, blob X / Y / area), so the functions below are out of reach. Saturation, brightness and blob width / height are on the MBC Blocks website; everything is readable with Pybricks MicroPython or Pybricks blocks (both need the Pybricks firmware on the hub).

Function (Pybricks library)Why not / what to use
saturation(), brightness()Saturation and brightness at the colour point are not readable; the App only gets the hue.
blob_w(), blob_h()Blob width and height are not readable; for near / far use area() (0–100).
area() (Pybricks)Pybricks area is width × height (0–7500); the App gets a different 0–100 area, so the numbers do not compare directly.
blob_xya(), read_all()No "read several at once" functions; read blob_x(), blob_y(), area() one by one (all from the same update()).
device_id(), firmware_version(), sensor_ok()Device ID, firmware version and "is it connected" are not readable; what the App does when the cable is pulled is not yet tested, so the simulator has no unplug option.

Tips

  1. Call update() every loop. All helper functions split the 8 numbers from the last update(); without it the values never change (they start as all 0, the same as "not found").
  2. This is SPIKE App 3 style, not Pybricks. Ports are port.C from from hub import port (not Port.C), and waiting is await runloop.sleep_ms() (not wait()), so Pybricks programs cannot be pasted in. In the Robot Inventor (home) App the colour is only 0–10; this page is for the Education App.
  3. Do not compare with the App's colour constants. Here color_sensor.color() returns the camera's hue number, not a LEGO colour code; always compare the hue() number. Colours are set on the camera: without "1: COLOR" the hue stays 0, which looks like red.
  4. Check that a blob is found first. When found() is False (area 0), X and Y are 0 too, which looks like the bottom-left corner. This area is 0–100, a different unit from Pybricks area() (width × height).
  5. Directions: looking forward from behind the robot, X is left 0, right 98, middle about 50 (X − 50: left negative, right positive); Y is small at the bottom and big at the top (bottom 1, top 75). Motion is only reliable while the robot stands still. The App Python readings follow the firmware and the SPIKE App blocks page and are not yet checked one by one on a real hub.