MBC SharpShot Vision × LEGO SPIKE App

Read SharpShot Vision with the LEGO SPIKE App in three steps

In the LEGO SPIKE App, SharpShot Vision shows up as a color sensor, so there is no library to import: read it with the five color sensor blocks (color, reflected light, raw red/green/blue). Each camera mode puts different things in them, and some slots hold two values that you split apart (step 2 has the table). Work down the steps on the left and watch the blocks grow on the right; the pictures are exported from the web App (spike.legoeducation.com).

Verified on SPIKE hardwareRun on real hubs on 2026-11-01 with shipping firmware v1.0-261101 (Pybricks library and blocks, Pybricks built-in blocks, the official app Education and home edition, MBC Blocks website).

1

Start: when program starts + forever, pick the mode

A sensor is read again and again. Start with the yellow "when program starts", attach "forever" below it and put "wait 0.1 seconds" inside, reading every 0.1 s.

  1. Open the LEGO SPIKE App (Education), create a project and choose "Word Blocks".
  2. Drag "when program starts" from Events and "forever" from Control below it, then put "wait 1 seconds" inside and change it to 0.1.
  3. Pick the camera mode in the camera's MODE menu and click the same mode number below. The App cannot read the camera's mode, so how you split the numbers depends on it.
2

Meet the five reading blocks, pick the port

The App reads SharpShot Vision with the five color sensor blocks; each starts with a port menu, so pick the port the camera is on. The table shows what each block gives in the mode you picked in step 1 (it changes with the mode):

Which port is the camera on?

"x100" slots are A×100 + B: A = floor(÷100), B = remainder of ÷100. "b256" slots are A + B×256: A = remainder of ÷256, B = floor(÷256) (use mod and floor of from Operators). Raw red/green/blue are in the "More Sensors" extension: add it with the button at the bottom left. Full layouts per mode are in the value reference.

3

Store in a variable, use it

Make a variable in "Variables" and store the reading (or the split value) with "set … to …"; that names it, and you show or test the variable afterwards. Functions are grouped by camera mode; dashed ones belong to another mode (clicking one switches it for you).

Simulated camera view: drag things in the picture and watch the output change

The view is a sketch: values come straight from where things are on screen (X 0–159 left→right, Y 0–119 top→bottom, area % = width × height ÷ whole picture); a hue code is the color the paper or block really has (red 0, yellow 40, green 80, blue 160, purple 200, white table 244, black tape 252). It is not the camera's own algorithm, and real numbers vary with the light. Color tracking assumes 4 colors were taught on the camera: color 1 red, 2 green, 3 blue, 4 yellow. In object detection you pick each shape yourself (the camera does not judge it here); objects 1, 2… are sorted by area, largest first; X, Y is the shape's centroid (white dot), the dashed box is its bounding box, and the angle is the rotation you set.

An example for every function

Every function has a set of blocks to copy (port C); the badge shows which modes it works in. "Try it" jumps to step 3 (and switches the mode if needed).

Full examples

Values the App blocks cannot read (bytes 8–15 of each mode, device ID, connection state…) are all in Pybricks blocks and MicroPython (the hub needs the Pybricks firmware).

Good to know

  1. The App reads only the first 8 bytes of the combined data. Bytes 8–15 of each mode (e.g. areas and counts in mode 13; mid offset, flags and junction distance in line following) are out of reach for blocks; they are listed under the step 2 table. Use Pybricks blocks or MicroPython for them.
  2. The "color" block turns 5 into 6. The Education app's "color" block and dashboard change a 5 sent by the camera into 6 (LEGO's green code); other numbers are shown as sent and "reflected light" is not affected. So 5 and 6 in the "color" slot cannot be told apart (e.g. color 1's X cell, colors found, junction type 5 dead end, object count, total blocks), and blocks have no way around it; to tell them apart use App Python and read device.data(port.C)[0].
  3. Do not use "color is [red]?" blocks. They compare LEGO's own color numbers. Always store the number in a variable and compare numbers.
  4. The mode must match the camera menu. The App cannot read the camera's mode; with the wrong mode the split numbers mean nothing.
  5. Robot Inventor (home) is different. Its App gives color 0–10 and raw RGB 0–255, so the camera switches to another layout (one value per slot, fewer values); the tables here are for the Education App (yellow SPIKE Prime hub). For the home layout see the Robot Inventor column of the value reference.
  6. Directions: cell X left→right, Y top→bottom (top = small); line offset: left = negative, right = positive (looking forward from behind the robot). Colors are taught on the camera.