MBC SharpShot Vision × MATRIX Mini R4 (Arduino IDE)

Read SharpShot Vision with MATRIX Mini R4 in three steps

To the MATRIX Mini R4 this camera is an mVision camera: each packet has 10 cells (CamData[0]–CamData[9]), and the "decode helper" turns them into blob positions, hues and line values. This page writes text code in the Arduino IDE. In order: wire it, paste the helper and pick the camera mode; then start mVision in setup(); then read and decode a packet in loop().

v1 not yet hardware-verifiedThe value layout is final and passed computer tests; real-hardware numbers (fps, line thresholds, I2C pins) may change after hardware testing.

1

Wire it, paste the helper, pick the mode

mVision only sends 10 numbers, laid out differently in each mode, so paste the "decode helper" first: the first lines (CamData, structs) at the top, the functions at the bottom.

  1. Wiring: plug the camera into the Mini R4 serial port for the mVision camera (Serial1, 115200). Green hub name on the camera screen = connected.
  2. In the Arduino IDE install "Arduino UNO R4 Boards" and the "MatrixMiniR4" library, and pick the Arduino UNO R4 WiFi board.
  3. Paste the program marked ① on the right (the helper is at the bottom; "Show helper" shows it all; "Copy program" always copies everything). The helper is also in MBC_UniCam_v1_Host_Libraries.zip (matrix folder).
  4. Pick the camera mode: choose it in the camera's MODE menu, and click the same mode number below.
2

setup(): start mVision

setup() starts the Mini R4, the Serial Monitor (to see results) and the mVision serial port. MATRIX cannot read or switch the camera mode, so set the camera menu to the mode from step 1.

3

Read and decode a packet in loop()

Each loop reads one packet with SmartCamReader(CamData) (waits up to 0.5 s) and decodes it only if one arrived. Functions are grouped by camera mode; dashed ones belong to another mode (clicking switches it, MODE follows, and so must the camera menu).

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 an example for "after a packet arrived"; the badge shows which modes it works in. "Try it" jumps to step 3.

Full examples

More examples are on the MATRIX examples page (with notes for MATRIXblock blocks too).

Where are colors 1–3 (mode 13)

        

!Set the camera menu to mode 13 and teach targets 1–3 first. "Copy" gives the whole program.

Line values (mode 41 black line)

        

!Left = negative. A complete line-follower car (M1/M2 motors, stop at junctions) is on the MATRIX examples page.

Good to know

  1. When no packet arrives, CamStatus is negative (−1 timeout, −2 incomplete, −3 checksum), and CamData still holds the last packet, so always check CamStatus > 0. Tick "Unplug the sensor".
  2. The camera menu mode must match MODE. MATRIX cannot read or switch it; a mismatch gives meaningless numbers.
  3. What MATRIX gets: color tracking 16/10/5/3 colors, color at points 20/10/6 spots, color order 18 blocks, line 14 values. Mode 11 positions are 8×6 grid-cell centres (±10 px); mode 12 has positions only. Colors found exists in modes 11 and 14 only.
  4. Directions: X 0–159 left→right, Y 0–119 top→bottom (top = small), 0 = not seen. Line offset: left = negative. Red's hue code is 0, so use the total in color order.
  5. MATRIXblock blocks work too: "mVision data 0–9" are CamData[0]–CamData[9]; split them with divide / remainder blocks (see the MATRIX guide). Do not use "data 10".