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.

SharpShot Vision (ESP32CAM) × EV3 × Pybricks

Interactive tutorialEV3

First time? Try the interactive tutorial in your browser first, then follow the steps below with your hub.

This page covers Pybricks v4 / EV3 MicroPython v2 only: how to set it up for the SharpShot Vision (ESP32CAM) on MINDSTORMS EV3, how to read every value, the commands it supports and examples. Use the switcher above to change product, host or software.

Setup

What you need

  • Sensor: SharpShot Vision (ESP32CAM) (EV3 edition, RJ12 plug).
  • Brick: LEGO MINDSTORMS EV3.
  • Software (pick one):
    • Pybricks v4: open code.pybricks.com in Chrome; the EV3 needs the Pybricks firmware first (the stable release now includes EV3 firmware, v4.1.1 as of 2026-10).
    • EV3 MicroPython v2.0: the official LEGO "EV3 MicroPython" microSD boot card + the "LEGO MINDSTORMS EV3 MicroPython" extension for VS Code. Pick this if you already use it.

Install the software

Pybricks v4

  1. Open code.pybricks.com in Chrome.
  2. Follow the website to switch the EV3 to Pybricks firmware. The stable code.pybricks.com now includes EV3 firmware (v4.1.1 as of 2026-10). The examples on this site were first bench-tested on v4.0.0b10; v4.1.1 uses the same code.
  3. To open an example: drag the .py file into the editor and press Run.

EV3 MicroPython v2.0

  1. Boot the EV3 from the official LEGO EV3 MicroPython microSD card.
  2. Install the "LEGO MINDSTORMS EV3 MicroPython" extension in VS Code.
  3. To open an example: paste the program into main.py and press F5 to download and run.

Make the software see the sensor

The beginner examples need no library; they read the sensor data directly:

  • Pybricks v4 uses LUMPDevice(Port.S1); sensor.read(mode) returns that mode's values.
  • EV3 MicroPython v2.0: always read with Ev3devSensor. For products that show up as an infrared sensor, do not use InfraredSensor: every mode change waits about 1.1 s, and buttons() / beacon() / keypad() raise errors or change the values.
  • Both can read modes that EV3-G and Classroom cannot, so examples marked "Pybricks / EV3 MicroPython / clev3r only" run here too.

Important

Do not switch modes often inside the main loop. The EV3 hardware adds a communication wait every time a sensor mode changes. Pick one mode for the task and keep it for the whole run.

Wiring

  1. Plug the sensor into EV3 port 1 with the cable (any of 14 works; use the same port as Port.S1Port.S4 in the program).
  2. Turn the EV3 on first, then plug in the sensor.
  3. Latch up, push the plug in gently.

Set the colour on the sensor first

All SharpShot settings are made on the colour screen and buttons on the back of the sensor; no computer needed:

  1. The sensor only starts when plugged into a hub that is already on (the screen first shows "LEGO Sync..."); once the camera image appears it is ready.
  2. Short-press the side button to open the settings menu; left / right to choose, OK to enter. In the menu, hold the side button for 1 s to clear that colour set.
  3. Colour settings and camera parameters (brightness, contrast, saturation, exposure, white balance, flip, mirror) are saved automatically and used at the next power-on.

Two EV3 firmwares

Firmware Shows up on the EV3 as Software that works
School teacher creative-contest edition (colour pick + blob tracking + motion) Infrared sensor EV3-G, EV3 Classroom, Pybricks, clev3r
WRO 2026 edition (HUE12, 12 colour spots) Third-party sensor (type 95) EV3-G (MBC My Blocks), clev3r, Pybricks; EV3 Classroom cannot read it

First test

  1. Open example 1 on this page and run it (F5 for the MicroPython version).
  2. If the number on the EV3 screen changes with what is in front of the sensor, everything is connected.

FAQ

  • Cannot find Pybricks firmware for the EV3? Use the stable code.pybricks.com (EV3 v4.1.1 built in since 2026-10); the old ev3dev-based Pybricks (microSD card) is a different system and does not apply here.
  • The number never changes? Unplug the sensor and plug it back in (the EV3 must be on first).
  • The program reacts unevenly? The main loop reads different modes in turn and waits at every switch. Use one mode only.
  • Error when importing a library? The library file must be imported into the same Pybricks project, and its file name must match the import name exactly.

Reading values (School edition)

Code assumes port 1 and reads raw modes with LUMPDevice; EV3 MicroPython v2 works the same way.

hue hue

hue
Range Meaning
-1~100 hue of sample point S1, 0100 (hue ring 0240 scaled); −1 = black/white/grey (saturation < 10); 0 when S1 is not set
from pybricks.iodevices import LUMPDevice
from pybricks.parameters import Port

sensor = LUMPDevice(Port.S1)   # sensor on port 1

hue = sensor.read(0)[0]   # hue:-1~100
hue = sensor.read(1)[0]   # hue:-1~100
hue = sensor.read(2)[0]   # hue:-1~100
hue = sensor.read(3)[0]   # hue:-1~100
hue = sensor.read(5)[0]   # hue:-1~100

mode 0 · int8 · IR-PROX 1×int8; mode 1 · int8 · IR-SEEK [色相, 飽和, 明度, 動態, X, Y, W, H]; mode 2 · int8 · IR-REMOTE [色相, 飽和, 明度, 動態]; mode 3 · int16 · IR-REM-A 1×int16(#65 已修成正確符號延伸,−1 = 0xFFFF); mode 5 · int16 · IR-CAL [色相, 飽和] 2×int16 (locked mode: firmware and hosts will not change it)

saturation saturation

saturation
Range Meaning
0~100 saturation of sample point S1, 0~100
from pybricks.iodevices import LUMPDevice
from pybricks.parameters import Port

sensor = LUMPDevice(Port.S1)   # sensor on port 1

saturation = sensor.read(1)[1]   # saturation:0~100
saturation = sensor.read(2)[1]   # saturation:0~100
saturation = sensor.read(5)[1]   # saturation:0~100

mode 1 · int8; mode 2 · int8; mode 5 · int16 (locked mode: firmware and hosts will not change it)

brightness value

brightness
Range Meaning
0~100 brightness (HSV value) of sample point S1, 0~100
from pybricks.iodevices import LUMPDevice
from pybricks.parameters import Port

sensor = LUMPDevice(Port.S1)   # sensor on port 1

value = sensor.read(1)[2]   # brightness:0~100
value = sensor.read(2)[2]   # brightness:0~100

mode 1 · int8; mode 2 · int8 (locked mode: firmware and hosts will not change it)

motion motion

motion
Range Meaning
0~100 whole-frame motion 0~100 (more change = larger)
from pybricks.iodevices import LUMPDevice
from pybricks.parameters import Port

sensor = LUMPDevice(Port.S1)   # sensor on port 1

motion = sensor.read(1)[3]   # motion:0~100
motion = sensor.read(2)[3]   # motion:0~100

mode 1 · int8; mode 2 · int8 (locked mode: firmware and hosts will not change it)

blob X blobX

blob X
Range Meaning
0~100 blob centre X 0~100, left = 0; 0 when not found
from pybricks.iodevices import LUMPDevice
from pybricks.parameters import Port

sensor = LUMPDevice(Port.S1)   # sensor on port 1

blobX = sensor.read(1)[4]   # blob X:0~100
blobX = sensor.read(4)[0]   # blob X:0~100

mode 1 · int8; mode 4 · int8 · IR-S-ALT [X, Y, W, H] (locked mode: firmware and hosts will not change it)

blob Y blobY

blob Y
Range Meaning
0~75 blob centre Y 0~75, bottom = 0, top = 75; 0 when not found
from pybricks.iodevices import LUMPDevice
from pybricks.parameters import Port

sensor = LUMPDevice(Port.S1)   # sensor on port 1

blobY = sensor.read(1)[5]   # blob Y:0~75
blobY = sensor.read(4)[1]   # blob Y:0~75

mode 1 · int8; mode 4 · int8 (locked mode: firmware and hosts will not change it)

blob width blobW

blob width
Range Meaning
0~100 blob width W 0~100; 0 = not found
from pybricks.iodevices import LUMPDevice
from pybricks.parameters import Port

sensor = LUMPDevice(Port.S1)   # sensor on port 1

blobW = sensor.read(1)[6]   # blob width:0~100
blobW = sensor.read(4)[2]   # blob width:0~100

mode 1 · int8; mode 4 · int8 (locked mode: firmware and hosts will not change it)

blob height blobH

blob height
Range Meaning
0~75 blob height H 0~75; 0 when not found
from pybricks.iodevices import LUMPDevice
from pybricks.parameters import Port

sensor = LUMPDevice(Port.S1)   # sensor on port 1

blobH = sensor.read(1)[7]   # blob height:0~75
blobH = sensor.read(4)[3]   # blob height:0~75

mode 1 · int8; mode 4 · int8 (locked mode: firmware and hosts will not change it)

Not readable here:blob area, blob found. Use Arduino / mBlock / micro:bit for these.

Reading values (WRO edition)

Code assumes port 1 and reads raw modes with LUMPDevice; EV3 MicroPython v2 works the same way.

spot 1~12 colour code spotColor

spot 1~12 colour code
Range Meaning
0~255 101B = colour code of spots S1S12: 0239 colour (hue 0255 scaled to 0239), 240245 white (saturation < 30, lower = larger), 246~250 black (value < 30, darker = larger), 255 = spot not enabled
from pybricks.iodevices import LUMPDevice
from pybricks.parameters import Port

sensor = LUMPDevice(Port.S1)   # sensor on port 1

spotColor = sensor.read(0)[0:12]   # spot 1~12 colour code

mode 0 · int32×8 · HUE12 8×int32 LE(32 B):24 byte = [色相, 鮮豔度]×12,每 3 byte 塞一個 int32(byte3 = 0);格 n 色相 = byte 2(n−1) → int32 k = idx/3、byte = idx%3;鎖住 (locked mode: firmware and hosts will not change it)

spot 1~12 vividness spotVivid

spot 1~12 vividness
Range Meaning
0~255 202B = vividness (saturation) of spots S1S12, 0~255: black = 1, white/colour = actual saturation; 0 when the spot is not enabled
from pybricks.iodevices import LUMPDevice
from pybricks.parameters import Port

sensor = LUMPDevice(Port.S1)   # sensor on port 1

spotVivid = sensor.read(0)[0:12]   # spot 1~12 vividness

mode 0 · int32×8 · 同 10~1B:格 n 鮮豔度 = byte 2(n−1)+1;鎖住 (locked mode: firmware and hosts will not change it)

Examples (School edition)

Example 1: What does the camera see? All 8 numbers at once

What this example does: Mode 1 sends 8 numbers at once: colour, saturation, brightness, motion, and the X, Y, width and height of the colour blob. Show them all on the EV3 screen and compare with the camera picture to understand each one.

What you need:

  • SharpShot (school edition) (EV3 edition)
  • EV3 brick

How to connect: SharpShot (school edition) in port 1. Camera setup: short-press the side button for the menu → left/right to "2:TRACK" → confirm → aim the crosshair at the ball, set the position, tolerance and minimum area in turn → confirm to save.

Download the program (pick your software):

⬇ Pybricks v4 | ⬇ EV3 MicroPython v2.0

Pybricks v4 code
# ============================================================
# 神攝手 ESP32CAM 視覺感應器(學校老師創意賽版) EV3 新手範例 01:相機看到了什麼?8 個數字一次看
# 軟體:Pybricks v4(用 Chrome 打開 https://code.pybricks.com ,EV3 版目前是 Beta)
# 接法:神攝手(學校版)插 1 號孔
# 這個範例會做什麼:模式 1 一次送出 8 個數字:顏色、鮮豔度、亮度、動態、色塊的 X、Y、寬、高。全部顯示在 EV3 螢幕上,對照相機畫面就能看懂每個數字的意思。
# ============================================================

from pybricks.hubs import EV3Brick
from pybricks.iodevices import LUMPDevice
from pybricks.parameters import Port, Color
from pybricks.tools import wait

ev3 = EV3Brick()
sensor = LUMPDevice(Port.S1)       # 神攝手(學校版)插 1 號孔


def read_hue1():
    # 顏色(色相):0 ~ 100,-1=黑白灰
    return sensor.read(1)[0]


def read_sta():
    # 顏色鮮豔度:0 ~ 100
    return sensor.read(1)[1]


def read_val():
    # 亮度:0 ~ 100
    return sensor.read(1)[2]


def read_motion():
    # 畫面動了多少:0 ~ 100
    return sensor.read(1)[3]


def read_x():
    # 色塊左右位置:0 ~ 100(左 → 右),沒找到=0
    return sensor.read(1)[4]


def read_y():
    # 色塊上下位置:0 ~ 75(下 → 上),沒找到=0
    return sensor.read(1)[5]


def read_w():
    # 色塊寬度:0 ~ 100,0=沒找到
    return sensor.read(1)[6]


def read_h():
    # 色塊高度(越近越大):0 ~ 75,0=沒找到
    return sensor.read(1)[7]


# ---------- 程式從這裡開始 ----------
# 清除螢幕
ev3.screen.clear()
# 一直重複
while True:
    # 顏色:紅 0 或 100、黃約 17、綠約 33、藍約 67,-1=黑白灰
    ev3.screen.draw_text(0, 0, "HUE " + str(read_hue1()) + "      ", Color.BLACK, Color.WHITE)
    # 鮮豔度 0~100
    ev3.screen.draw_text(0, 16, "STA " + str(read_sta()) + "      ", Color.BLACK, Color.WHITE)
    # 亮度 0~100
    ev3.screen.draw_text(0, 32, "VAL " + str(read_val()) + "      ", Color.BLACK, Color.WHITE)
    # 畫面動了多少 0~100
    ev3.screen.draw_text(0, 48, "MOTION " + str(read_motion()) + "      ", Color.BLACK, Color.WHITE)
    # 色塊左右位置 0~100
    ev3.screen.draw_text(0, 64, "X " + str(read_x()) + "      ", Color.BLACK, Color.WHITE)
    # 色塊上下位置 0~75
    ev3.screen.draw_text(0, 80, "Y " + str(read_y()) + "      ", Color.BLACK, Color.WHITE)
    # 色塊寬度,0=沒找到
    ev3.screen.draw_text(0, 96, "W " + str(read_w()) + "      ", Color.BLACK, Color.WHITE)
    # 色塊高度,越近越大
    ev3.screen.draw_text(0, 112, "H " + str(read_h()) + "      ", Color.BLACK, Color.WHITE)
    # 等 0.1 秒
    wait(100)
EV3 MicroPython v2.0 code
#!/usr/bin/env pybricks-micropython
# ============================================================
# 神攝手 ESP32CAM 視覺感應器(學校老師創意賽版) EV3 新手範例 01:相機看到了什麼?8 個數字一次看
# 軟體:樂高官方 EV3 MicroPython v2.0(microSD 開機卡+VS Code「LEGO MINDSTORMS EV3 MicroPython」擴充套件)
# 接法:神攝手(學校版)插 1 號孔
# 這個範例會做什麼:模式 1 一次送出 8 個數字:顏色、鮮豔度、亮度、動態、色塊的 X、Y、寬、高。全部顯示在 EV3 螢幕上,對照相機畫面就能看懂每個數字的意思。
# ============================================================

from pybricks.hubs import EV3Brick
from pybricks.iodevices import Ev3devSensor
from pybricks.parameters import Port, Color
from pybricks.tools import wait

ev3 = EV3Brick()
sensor = Ev3devSensor(Port.S1)     # 神攝手(學校版)插 1 號孔


def read_hue1():
    # 顏色(色相):0 ~ 100,-1=黑白灰
    return sensor.read('IR-SEEK')[0]


def read_sta():
    # 顏色鮮豔度:0 ~ 100
    return sensor.read('IR-SEEK')[1]


def read_val():
    # 亮度:0 ~ 100
    return sensor.read('IR-SEEK')[2]


def read_motion():
    # 畫面動了多少:0 ~ 100
    return sensor.read('IR-SEEK')[3]


def read_x():
    # 色塊左右位置:0 ~ 100(左 → 右),沒找到=0
    return sensor.read('IR-SEEK')[4]


def read_y():
    # 色塊上下位置:0 ~ 75(下 → 上),沒找到=0
    return sensor.read('IR-SEEK')[5]


def read_w():
    # 色塊寬度:0 ~ 100,0=沒找到
    return sensor.read('IR-SEEK')[6]


def read_h():
    # 色塊高度(越近越大):0 ~ 75,0=沒找到
    return sensor.read('IR-SEEK')[7]


# ---------- 程式從這裡開始 ----------
# 清除螢幕
ev3.screen.clear()
# 一直重複
while True:
    # 顏色:紅 0 或 100、黃約 17、綠約 33、藍約 67,-1=黑白灰
    ev3.screen.draw_text(0, 0, "HUE " + str(read_hue1()) + "      ", Color.BLACK, Color.WHITE)
    # 鮮豔度 0~100
    ev3.screen.draw_text(0, 16, "STA " + str(read_sta()) + "      ", Color.BLACK, Color.WHITE)
    # 亮度 0~100
    ev3.screen.draw_text(0, 32, "VAL " + str(read_val()) + "      ", Color.BLACK, Color.WHITE)
    # 畫面動了多少 0~100
    ev3.screen.draw_text(0, 48, "MOTION " + str(read_motion()) + "      ", Color.BLACK, Color.WHITE)
    # 色塊左右位置 0~100
    ev3.screen.draw_text(0, 64, "X " + str(read_x()) + "      ", Color.BLACK, Color.WHITE)
    # 色塊上下位置 0~75
    ev3.screen.draw_text(0, 80, "Y " + str(read_y()) + "      ", Color.BLACK, Color.WHITE)
    # 色塊寬度,0=沒找到
    ev3.screen.draw_text(0, 96, "W " + str(read_w()) + "      ", Color.BLACK, Color.WHITE)
    # 色塊高度,越近越大
    ev3.screen.draw_text(0, 112, "H " + str(read_h()) + "      ", Color.BLACK, Color.WHITE)
    # 等 0.1 秒
    wait(100)

Step by step:

  1. Clear the screen
  2. Repeat forever
    • Colour: red 0 or 100, yellow ≈17, green ≈33, blue ≈67, -1 = black/white/grey
    • Saturation 0~100
    • Brightness 0~100
    • How much the picture moved 0~100
    • Blob horizontal position 0~100
    • Blob vertical position 0~75
    • Blob width, 0 = not found
    • Blob height, bigger when closer
    • Wait 0.1 s

What you should see: Move the ball left and right in front of the lens and X follows; bring it closer and W and H grow; take it away and X, Y, W, H all read 0.

FAQ:

  • The camera screen stays on "LEGO Sync..."? The camera only starts when plugged into an EV3 that is already on. Turn the EV3 on first, then plug in the camera.
  • X, Y, W, H always read 0? 2:TRACK has not been set up, or the ball colour is outside the tolerance.

Example 2: Traffic-light robot: go on green only

What this example does: Mode 0 reads only the "colour". Drive forward on green, stop on anything else (red).

What you need:

  • EV3 brick + Education base robot (left wheel on B, right wheel on C)
  • SharpShot (school edition) (EV3 edition)
  • One red and one green card

How to connect: SharpShot (school edition) in port 1, mounted at the front with the lens facing forward.Camera setup: short-press the side button for the menu → left/right to "1:COLOR" → confirm → aim the crosshair at the colour to learn, set the position and tolerance in turn → confirm to save.

Download the program (pick your software):

⬇ Pybricks v4 | ⬇ EV3 MicroPython v2.0

Pybricks v4 code
# ============================================================
# 神攝手 ESP32CAM 視覺感應器(學校老師創意賽版) EV3 新手範例 02:紅綠燈車:看到綠色才走
# 軟體:Pybricks v4(用 Chrome 打開 https://code.pybricks.com ,EV3 版目前是 Beta)
# 接法:神攝手(學校版)插 1 號孔;左輪馬達接 B、右輪馬達接 C
# 這個範例會做什麼:用模式 0 只讀「顏色」。看到綠色就往前開,其他顏色(紅色)就停。
# ============================================================

from pybricks.hubs import EV3Brick
from pybricks.ev3devices import Motor
from pybricks.iodevices import LUMPDevice
from pybricks.parameters import Port
from pybricks.tools import wait

ev3 = EV3Brick()
sensor = LUMPDevice(Port.S1)       # 神攝手(學校版)插 1 號孔
left_motor = Motor(Port.B)        # 左輪
right_motor = Motor(Port.C)       # 右輪


def read_hue():
    # 顏色(色相):0 ~ 100(紅 0 或 100、黃約 17、綠約 33、藍約 67),-1=黑白灰
    return sensor.read(0)[0]


# ---------- 程式從這裡開始 ----------
# 一直重複
while True:
    # 如果顏色在 25~45 之間(綠色)
    if read_hue() >= 25 and read_hue() <= 45:
        # 是綠色:往前開
        left_motor.dc(30)
        right_motor.dc(30)
    else:
        # 不是綠色:停車
        left_motor.brake()
        right_motor.brake()
EV3 MicroPython v2.0 code
#!/usr/bin/env pybricks-micropython
# ============================================================
# 神攝手 ESP32CAM 視覺感應器(學校老師創意賽版) EV3 新手範例 02:紅綠燈車:看到綠色才走
# 軟體:樂高官方 EV3 MicroPython v2.0(microSD 開機卡+VS Code「LEGO MINDSTORMS EV3 MicroPython」擴充套件)
# 接法:神攝手(學校版)插 1 號孔;左輪馬達接 B、右輪馬達接 C
# 這個範例會做什麼:用模式 0 只讀「顏色」。看到綠色就往前開,其他顏色(紅色)就停。
# ============================================================

from pybricks.hubs import EV3Brick
from pybricks.ev3devices import Motor
from pybricks.iodevices import Ev3devSensor
from pybricks.parameters import Port
from pybricks.tools import wait

ev3 = EV3Brick()
sensor = Ev3devSensor(Port.S1)     # 神攝手(學校版)插 1 號孔
left_motor = Motor(Port.B)        # 左輪
right_motor = Motor(Port.C)       # 右輪


def read_hue():
    # 顏色(色相):0 ~ 100(紅 0 或 100、黃約 17、綠約 33、藍約 67),-1=黑白灰
    return sensor.read('IR-PROX')[0]


# ---------- 程式從這裡開始 ----------
# 一直重複
while True:
    # 如果顏色在 25~45 之間(綠色)
    if read_hue() >= 25 and read_hue() <= 45:
        # 是綠色:往前開
        left_motor.dc(30)
        right_motor.dc(30)
    else:
        # 不是綠色:停車
        left_motor.brake()
        right_motor.brake()

Step by step:

  1. Repeat forever
    • If the colour is between 25 and 45 (green)
      • Green: drive forward
      • Otherwise:
        • Not green: stop

What you should see: Hold the green card in front of the lens and the robot drives; swap to the red card and it stops.

FAQ:

  • The camera screen stays on "LEGO Sync..."? The camera only starts when plugged into an EV3 that is already on. Turn the EV3 on first, then plug in the camera.
  • It does not go on green either? Run example 1 to see the real HUE of your green card, then change 25 and 45 in the program.

Example 3: Burglar alarm: beep when something moves

What this example does: The 4th number of mode 1 is "how much the picture moved". Point the camera at a doorway; when someone walks past the number jumps, and above 20 the EV3 beeps. No camera setup needed.

What you need:

  • SharpShot (school edition) (EV3 edition)
  • EV3 brick

How to connect: SharpShot (school edition) in port 1, lens pointing at the area to watch, held steady.

Download the program (pick your software):

⬇ Pybricks v4 | ⬇ EV3 MicroPython v2.0

Pybricks v4 code
# ============================================================
# 神攝手 ESP32CAM 視覺感應器(學校老師創意賽版) EV3 新手範例 03:防盜警報:有東西動就叫
# 軟體:Pybricks v4(用 Chrome 打開 https://code.pybricks.com ,EV3 版目前是 Beta)
# 接法:神攝手(學校版)插 1 號孔
# 這個範例會做什麼:模式 1 的第 4 個數字是「畫面動了多少」。相機對著門口,有人經過數字就會變大,超過 20 就嗶嗶叫。這個範例相機不用做任何設定。
# ============================================================

from pybricks.hubs import EV3Brick
from pybricks.iodevices import LUMPDevice
from pybricks.parameters import Port, Color
from pybricks.tools import wait

ev3 = EV3Brick()
sensor = LUMPDevice(Port.S1)       # 神攝手(學校版)插 1 號孔


def read_motion():
    # 畫面動了多少:0 ~ 100
    return sensor.read(1)[3]


# ---------- 程式從這裡開始 ----------
# 一直重複
while True:
    # 螢幕顯示動態值
    ev3.screen.draw_text(0, 0, "MOTION " + str(read_motion()) + "      ", Color.BLACK, Color.WHITE)
    # 如果動態值大於 20
    if read_motion() > 20:
        # 有東西在動:嗶!
        ev3.speaker.beep()
EV3 MicroPython v2.0 code
#!/usr/bin/env pybricks-micropython
# ============================================================
# 神攝手 ESP32CAM 視覺感應器(學校老師創意賽版) EV3 新手範例 03:防盜警報:有東西動就叫
# 軟體:樂高官方 EV3 MicroPython v2.0(microSD 開機卡+VS Code「LEGO MINDSTORMS EV3 MicroPython」擴充套件)
# 接法:神攝手(學校版)插 1 號孔
# 這個範例會做什麼:模式 1 的第 4 個數字是「畫面動了多少」。相機對著門口,有人經過數字就會變大,超過 20 就嗶嗶叫。這個範例相機不用做任何設定。
# ============================================================

from pybricks.hubs import EV3Brick
from pybricks.iodevices import Ev3devSensor
from pybricks.parameters import Port, Color
from pybricks.tools import wait

ev3 = EV3Brick()
sensor = Ev3devSensor(Port.S1)     # 神攝手(學校版)插 1 號孔


def read_motion():
    # 畫面動了多少:0 ~ 100
    return sensor.read('IR-SEEK')[3]


# ---------- 程式從這裡開始 ----------
# 一直重複
while True:
    # 螢幕顯示動態值
    ev3.screen.draw_text(0, 0, "MOTION " + str(read_motion()) + "      ", Color.BLACK, Color.WHITE)
    # 如果動態值大於 20
    if read_motion() > 20:
        # 有東西在動:嗶!
        ev3.speaker.beep()

Step by step:

  1. Repeat forever
    • Show the motion value on screen
    • If the motion value is greater than 20
      • Something is moving: beep!

What you should see: Quiet when the picture is still; wave a hand in front of the lens and the EV3 beeps.

FAQ:

  • The camera screen stays on "LEGO Sync..."? The camera only starts when plugged into an EV3 that is already on. Turn the EV3 on first, then plug in the camera.
  • It beeps even when nobody is there? Flickering lights or a shaking camera. Raise 20 (for example 35).

Example 4: Turn to look at the ball

What this example does: The robot spins on the spot to keep the ball in the middle of the picture: ball on the left means turn left, on the right means turn right, in the middle means stop; no ball means spin to search.

What you need:

  • EV3 brick + Education base robot (left wheel on B, right wheel on C)
  • SharpShot (school edition) (EV3 edition)
  • A brightly coloured ball

How to connect: SharpShot (school edition) in port 1, mounted at the front with the lens facing forward.Camera setup: short-press the side button for the menu → left/right to "2:TRACK" → confirm → aim the crosshair at the ball, set the position, tolerance and minimum area in turn → confirm to save.

Download the program (pick your software):

⬇ Pybricks v4 | ⬇ EV3 MicroPython v2.0

Pybricks v4 code
# ============================================================
# 神攝手 ESP32CAM 視覺感應器(學校老師創意賽版) EV3 新手範例 04:看球轉頭
# 軟體:Pybricks v4(用 Chrome 打開 https://code.pybricks.com ,EV3 版目前是 Beta)
# 接法:神攝手(學校版)插 1 號孔;左輪馬達接 B、右輪馬達接 C
# 這個範例會做什麼:車子原地轉,讓球一直保持在畫面中間:球在左邊就往左轉、在右邊就往右轉、在中間就停;看不到球就原地轉圈找。
# ============================================================

from pybricks.hubs import EV3Brick
from pybricks.ev3devices import Motor
from pybricks.iodevices import LUMPDevice
from pybricks.parameters import Port
from pybricks.tools import wait

ev3 = EV3Brick()
sensor = LUMPDevice(Port.S1)       # 神攝手(學校版)插 1 號孔
left_motor = Motor(Port.B)        # 左輪
right_motor = Motor(Port.C)       # 右輪


def read_w():
    # 色塊寬度:0 ~ 100,0=沒找到
    return sensor.read(1)[6]


def read_x():
    # 色塊左右位置:0 ~ 100(左 → 右),沒找到=0
    return sensor.read(1)[4]


# ---------- 程式從這裡開始 ----------
# 一直重複
while True:
    # 如果色塊寬度=0(沒找到球)
    if read_w() == 0:
        # 看不到球(寬度=0):原地慢慢轉圈找
        left_motor.dc(15)
        right_motor.dc(-15)
    # 如果 X 小於 40(左邊)
    elif read_x() < 40:
        # 球在左邊:往左轉
        left_motor.dc(-15)
        right_motor.dc(15)
    # 否則,如果 X 大於 60(右邊)
    elif read_x() > 60:
        # 球在右邊:往右轉
        left_motor.dc(15)
        right_motor.dc(-15)
    else:
        # 球在中間:停住
        left_motor.brake()
        right_motor.brake()
EV3 MicroPython v2.0 code
#!/usr/bin/env pybricks-micropython
# ============================================================
# 神攝手 ESP32CAM 視覺感應器(學校老師創意賽版) EV3 新手範例 04:看球轉頭
# 軟體:樂高官方 EV3 MicroPython v2.0(microSD 開機卡+VS Code「LEGO MINDSTORMS EV3 MicroPython」擴充套件)
# 接法:神攝手(學校版)插 1 號孔;左輪馬達接 B、右輪馬達接 C
# 這個範例會做什麼:車子原地轉,讓球一直保持在畫面中間:球在左邊就往左轉、在右邊就往右轉、在中間就停;看不到球就原地轉圈找。
# ============================================================

from pybricks.hubs import EV3Brick
from pybricks.ev3devices import Motor
from pybricks.iodevices import Ev3devSensor
from pybricks.parameters import Port
from pybricks.tools import wait

ev3 = EV3Brick()
sensor = Ev3devSensor(Port.S1)     # 神攝手(學校版)插 1 號孔
left_motor = Motor(Port.B)        # 左輪
right_motor = Motor(Port.C)       # 右輪


def read_w():
    # 色塊寬度:0 ~ 100,0=沒找到
    return sensor.read('IR-SEEK')[6]


def read_x():
    # 色塊左右位置:0 ~ 100(左 → 右),沒找到=0
    return sensor.read('IR-SEEK')[4]


# ---------- 程式從這裡開始 ----------
# 一直重複
while True:
    # 如果色塊寬度=0(沒找到球)
    if read_w() == 0:
        # 看不到球(寬度=0):原地慢慢轉圈找
        left_motor.dc(15)
        right_motor.dc(-15)
    # 如果 X 小於 40(左邊)
    elif read_x() < 40:
        # 球在左邊:往左轉
        left_motor.dc(-15)
        right_motor.dc(15)
    # 否則,如果 X 大於 60(右邊)
    elif read_x() > 60:
        # 球在右邊:往右轉
        left_motor.dc(15)
        right_motor.dc(-15)
    else:
        # 球在中間:停住
        left_motor.brake()
        right_motor.brake()

Step by step:

  1. Repeat forever
    • If the blob width = 0 (ball not found)
      • Cannot see the ball (width = 0): spin slowly on the spot to look for it
      • Otherwise:
        • If X is less than 40 (left)
          • Ball on the left: turn left
          • Otherwise:
            • Otherwise, if X is greater than 60 (right)
              • Ball on the right: turn right
              • Otherwise:
                • Ball in the centre: stop

What you should see: Move the ball left and right in front of the robot and its nose follows the ball.

FAQ:

  • The camera screen stays on "LEGO Sync..."? The camera only starts when plugged into an EV3 that is already on. Turn the EV3 on first, then plug in the camera.
  • Left and right are swapped? Swap -15 and 15 in the two tank steps.

Example 5: Chase the ball: stop when close enough

What this example does: Example 4 made to drive: aim at the ball while driving forward, and stop when the ball height H is big enough (close enough).

What you need:

  • EV3 brick + Education base robot (left wheel on B, right wheel on C)
  • SharpShot (school edition) (EV3 edition)
  • A brightly coloured ball

How to connect: SharpShot (school edition) in port 1, mounted at the front with the lens facing forward.Camera setup: short-press the side button for the menu → left/right to "2:TRACK" → confirm → aim the crosshair at the ball, set the position, tolerance and minimum area in turn → confirm to save.

Download the program (pick your software):

⬇ Pybricks v4 | ⬇ EV3 MicroPython v2.0

Pybricks v4 code
# ============================================================
# 神攝手 ESP32CAM 視覺感應器(學校老師創意賽版) EV3 新手範例 05:追球:靠近到一定距離就停
# 軟體:Pybricks v4(用 Chrome 打開 https://code.pybricks.com ,EV3 版目前是 Beta)
# 接法:神攝手(學校版)插 1 號孔;左輪馬達接 B、右輪馬達接 C
# 這個範例會做什麼:把範例 4 改成會往前開:一邊對準球一邊前進,球的高度 H 夠大(夠近)就停下來。
# ============================================================

from pybricks.hubs import EV3Brick
from pybricks.ev3devices import Motor
from pybricks.iodevices import LUMPDevice
from pybricks.parameters import Port
from pybricks.tools import wait

ev3 = EV3Brick()
sensor = LUMPDevice(Port.S1)       # 神攝手(學校版)插 1 號孔
left_motor = Motor(Port.B)        # 左輪
right_motor = Motor(Port.C)       # 右輪


def read_w():
    # 色塊寬度:0 ~ 100,0=沒找到
    return sensor.read(1)[6]


def read_h():
    # 色塊高度(越近越大):0 ~ 75,0=沒找到
    return sensor.read(1)[7]


def read_x():
    # 色塊左右位置:0 ~ 100(左 → 右),沒找到=0
    return sensor.read(1)[4]


# ---------- 程式從這裡開始 ----------
# 一直重複
while True:
    # 如果寬度=0(沒找到球)
    if read_w() == 0:
        # 看不到球:原地轉圈找
        left_motor.dc(15)
        right_motor.dc(-15)
    # 否則,如果 H 大於 30
    elif read_h() > 30:
        # 球的高度大於 30(夠近了):停車
        left_motor.brake()
        right_motor.brake()
    else:
        # 轉彎力量 turn =(X − 50)× 0.6:球偏右是正數
        turn = (read_x() - 50) * 0.6
        # 左輪=25+turn、右輪=25-turn:邊對準邊前進
        left_motor.dc(25 + turn)
        right_motor.dc(25 - turn)
EV3 MicroPython v2.0 code
#!/usr/bin/env pybricks-micropython
# ============================================================
# 神攝手 ESP32CAM 視覺感應器(學校老師創意賽版) EV3 新手範例 05:追球:靠近到一定距離就停
# 軟體:樂高官方 EV3 MicroPython v2.0(microSD 開機卡+VS Code「LEGO MINDSTORMS EV3 MicroPython」擴充套件)
# 接法:神攝手(學校版)插 1 號孔;左輪馬達接 B、右輪馬達接 C
# 這個範例會做什麼:把範例 4 改成會往前開:一邊對準球一邊前進,球的高度 H 夠大(夠近)就停下來。
# ============================================================

from pybricks.hubs import EV3Brick
from pybricks.ev3devices import Motor
from pybricks.iodevices import Ev3devSensor
from pybricks.parameters import Port
from pybricks.tools import wait

ev3 = EV3Brick()
sensor = Ev3devSensor(Port.S1)     # 神攝手(學校版)插 1 號孔
left_motor = Motor(Port.B)        # 左輪
right_motor = Motor(Port.C)       # 右輪


def read_w():
    # 色塊寬度:0 ~ 100,0=沒找到
    return sensor.read('IR-SEEK')[6]


def read_h():
    # 色塊高度(越近越大):0 ~ 75,0=沒找到
    return sensor.read('IR-SEEK')[7]


def read_x():
    # 色塊左右位置:0 ~ 100(左 → 右),沒找到=0
    return sensor.read('IR-SEEK')[4]


# ---------- 程式從這裡開始 ----------
# 一直重複
while True:
    # 如果寬度=0(沒找到球)
    if read_w() == 0:
        # 看不到球:原地轉圈找
        left_motor.dc(15)
        right_motor.dc(-15)
    # 否則,如果 H 大於 30
    elif read_h() > 30:
        # 球的高度大於 30(夠近了):停車
        left_motor.brake()
        right_motor.brake()
    else:
        # 轉彎力量 turn =(X − 50)× 0.6:球偏右是正數
        turn = (read_x() - 50) * 0.6
        # 左輪=25+turn、右輪=25-turn:邊對準邊前進
        left_motor.dc(25 + turn)
        right_motor.dc(25 - turn)

Step by step:

  1. Repeat forever
    • If width = 0 (ball not found)
      • Cannot see the ball: spin on the spot to look for it
      • Otherwise:
        • Otherwise, if H is greater than 30
          • Ball height greater than 30 (close enough): stop
          • Otherwise:
            • Steering power turn = (X − 50) × 0.6: positive when the ball is to the right
            • Left wheel = 25 + turn, right wheel = 25 − turn: aim at the ball while driving forward

What you should see: Put the ball on the floor: the robot turns to it, drives over and stops in front of it.

FAQ:

  • The camera screen stays on "LEGO Sync..."? The camera only starts when plugged into an EV3 that is already on. Turn the EV3 on first, then plug in the camera.
  • It stops while still far away? Raise 30.

Still stuck? Leave a message on Contact us with the software you use and a screenshot of your program, and we will help.

Examples (WRO edition)

Example 1: What colour does spot S1 see?

What this example does: The WRO edition has 12 colour spots; each reports "the colour at that position right now". Set up S1 and show its colour code and saturation on the screen.

What you need:

  • SharpShot (WRO edition) (EV3 edition)
  • EV3 brick
  • Bricks of various colours

How to connect: SharpShot (WRO edition) in port 1, mounted at the front with the lens facing forward. Camera setup: short-press the side button for the menu → left/right to S1 → confirm → move the crosshair to the spot to watch (X, Y) → set the tolerance → confirm to save.

Download the program (pick your software):

⬇ Pybricks v4 | ⬇ EV3 MicroPython v2.0

Pybricks v4 code
# ============================================================
# 神攝手 ESP32CAM 視覺感應器(WRO 2026 版 HUE12) EV3 新手範例 01:色點 S1 看到什麼顏色?
# 軟體:Pybricks v4(用 Chrome 打開 https://code.pybricks.com ,EV3 版目前是 Beta)
# 接法:神攝手(WRO 版)插 1 號孔
# 這個範例會做什麼:WRO 版有 12 個色點,每個色點回報「那一個位置現在的顏色」。先設定 S1,把它的顏色碼和鮮豔度顯示在螢幕上。
# ============================================================

from pybricks.hubs import EV3Brick
from pybricks.iodevices import LUMPDevice
from pybricks.parameters import Port, Color
from pybricks.tools import wait

ev3 = EV3Brick()
sensor = LUMPDevice(Port.S1)       # 神攝手(WRO 版)插 1 號孔


def slot_byte(n):
    # 神攝手 WRO 版每 3 個 byte 打包成一個數字,這裡把第 n 個 byte 拆出來
    data = sensor.read(0)
    return (data[n // 3] >> (8 * (n % 3))) & 255


def read_hue1():
    # 色點 S1 的顏色碼:0 ~ 239 彩色(紅 0/239、黃 40、綠 80、青 120、藍 160、紫 200);240~245 白;246~250 黑;255=色點沒開
    return slot_byte(0)


def read_sta1():
    # 色點 S1 的鮮豔度:0 ~ 255(黑色固定 1)
    return slot_byte(1)


# ---------- 程式從這裡開始 ----------
# 清除螢幕
ev3.screen.clear()
# 一直重複
while True:
    # 第 1 行:S1 的顏色碼
    ev3.screen.draw_text(0, 0, "S1 " + str(read_hue1()) + "      ", Color.BLACK, Color.WHITE)
    # 第 2 行:S1 的鮮豔度
    ev3.screen.draw_text(0, 16, "T1 " + str(read_sta1()) + "      ", Color.BLACK, Color.WHITE)
    # 等 0.1 秒
    wait(100)
EV3 MicroPython v2.0 code
#!/usr/bin/env pybricks-micropython
# ============================================================
# 神攝手 ESP32CAM 視覺感應器(WRO 2026 版 HUE12) EV3 新手範例 01:色點 S1 看到什麼顏色?
# 軟體:樂高官方 EV3 MicroPython v2.0(microSD 開機卡+VS Code「LEGO MINDSTORMS EV3 MicroPython」擴充套件)
# 接法:神攝手(WRO 版)插 1 號孔
# 這個範例會做什麼:WRO 版有 12 個色點,每個色點回報「那一個位置現在的顏色」。先設定 S1,把它的顏色碼和鮮豔度顯示在螢幕上。
# ============================================================

from pybricks.hubs import EV3Brick
from pybricks.iodevices import Ev3devSensor
from pybricks.parameters import Port, Color
from pybricks.tools import wait

ev3 = EV3Brick()
sensor = Ev3devSensor(Port.S1)     # 神攝手(WRO 版)插 1 號孔


def slot_byte(n):
    # 神攝手 WRO 版每 3 個 byte 打包成一個數字,這裡把第 n 個 byte 拆出來
    data = sensor.read('HUE12')
    return (data[n // 3] >> (8 * (n % 3))) & 255


def read_hue1():
    # 色點 S1 的顏色碼:0 ~ 239 彩色(紅 0/239、黃 40、綠 80、青 120、藍 160、紫 200);240~245 白;246~250 黑;255=色點沒開
    return slot_byte(0)


def read_sta1():
    # 色點 S1 的鮮豔度:0 ~ 255(黑色固定 1)
    return slot_byte(1)


# ---------- 程式從這裡開始 ----------
# 清除螢幕
ev3.screen.clear()
# 一直重複
while True:
    # 第 1 行:S1 的顏色碼
    ev3.screen.draw_text(0, 0, "S1 " + str(read_hue1()) + "      ", Color.BLACK, Color.WHITE)
    # 第 2 行:S1 的鮮豔度
    ev3.screen.draw_text(0, 16, "T1 " + str(read_sta1()) + "      ", Color.BLACK, Color.WHITE)
    # 等 0.1 秒
    wait(100)

Step by step:

  1. Clear the screen
  2. Repeat forever
    • Row 1: colour code of S1
    • Row 2: saturation of S1
    • Wait 0.1 s

What you should see: Put bricks of different colours at the S1 position and the colour code changes: red ≈0, yellow ≈40, green ≈80, blue ≈160.

FAQ:

  • The camera screen stays on "LEGO Sync..."? The camera only starts when plugged into an EV3 that is already on. Turn the EV3 on first, then plug in the camera.
  • The number is always 255? That colour spot is not set up (not enabled). Set up S1 as described above.
  • What do the colour numbers mean? 0239 are colours: red 0 (or 239), yellow 40, green 80, cyan 120, blue 160, purple 200; 240245 white; 246~250 black.
  • The camera picture is upside down? Turn V-Flip on in the menu. After changing the orientation, set up the colour spots again.
  • Flashed the school edition first, now the WRO edition spots act strangely? Both editions store settings in the same place: do a Reset Default in the menu first, then set up the spots again.

Example 2: Colour announcer: show the colour name on screen

What this example does: Split the colour code into ranges to decide red, green, blue, white or black, show the English name on the screen and beep.

What you need:

  • SharpShot (WRO edition) (EV3 edition)
  • EV3 brick
  • Red, green and blue bricks

How to connect: SharpShot (WRO edition) in port 1, mounted at the front with the lens facing forward. Camera setup: short-press the side button for the menu → left/right to S1 → confirm → move the crosshair to the spot to watch (X, Y) → set the tolerance → confirm to save.

Download the program (pick your software):

⬇ Pybricks v4 | ⬇ EV3 MicroPython v2.0

Pybricks v4 code
# ============================================================
# 神攝手 ESP32CAM 視覺感應器(WRO 2026 版 HUE12) EV3 新手範例 02:顏色播報:螢幕顯示顏色名稱
# 軟體:Pybricks v4(用 Chrome 打開 https://code.pybricks.com ,EV3 版目前是 Beta)
# 接法:神攝手(WRO 版)插 1 號孔
# 這個範例會做什麼:把顏色碼分成幾段,判斷是紅、綠、藍、白、黑,在螢幕上顯示英文名稱並嗶一聲。
# ============================================================

from pybricks.hubs import EV3Brick
from pybricks.iodevices import LUMPDevice
from pybricks.parameters import Port, Color
from pybricks.tools import wait

ev3 = EV3Brick()
sensor = LUMPDevice(Port.S1)       # 神攝手(WRO 版)插 1 號孔


def slot_byte(n):
    # 神攝手 WRO 版每 3 個 byte 打包成一個數字,這裡把第 n 個 byte 拆出來
    data = sensor.read(0)
    return (data[n // 3] >> (8 * (n % 3))) & 255


def read_hue1():
    # 色點 S1 的顏色碼:0 ~ 239 彩色(紅 0/239、黃 40、綠 80、青 120、藍 160、紫 200);240~245 白;246~250 黑;255=色點沒開
    return slot_byte(0)


# ---------- 程式從這裡開始 ----------
# 一直重複
while True:
    # 把 S1 的顏色碼存進 hue
    hue = read_hue1()
    # 清除螢幕
    ev3.screen.clear()
    # 如果是紅色
    if hue < 15 or (hue > 225 and hue < 240):
        # 0~14 或 226~239:紅色
        ev3.screen.draw_text(0, 0, "RED      ", Color.BLACK, Color.WHITE)
    # 否則,如果是綠色
    elif hue >= 60 and hue <= 100:
        # 60~100:綠色
        ev3.screen.draw_text(0, 0, "GREEN      ", Color.BLACK, Color.WHITE)
    # 否則,如果是藍色
    elif hue >= 140 and hue <= 180:
        # 140~180:藍色
        ev3.screen.draw_text(0, 0, "BLUE      ", Color.BLACK, Color.WHITE)
    # 否則,如果是白色
    elif hue >= 240 and hue <= 245:
        # 240~245:白色
        ev3.screen.draw_text(0, 0, "WHITE      ", Color.BLACK, Color.WHITE)
    # 否則,如果是黑色
    elif hue >= 246 and hue <= 250:
        # 246~250:黑色
        ev3.screen.draw_text(0, 0, "BLACK      ", Color.BLACK, Color.WHITE)
    else:
        # 其他顏色
        ev3.screen.draw_text(0, 0, "OTHER      ", Color.BLACK, Color.WHITE)
    # 等 0.3 秒
    wait(300)
EV3 MicroPython v2.0 code
#!/usr/bin/env pybricks-micropython
# ============================================================
# 神攝手 ESP32CAM 視覺感應器(WRO 2026 版 HUE12) EV3 新手範例 02:顏色播報:螢幕顯示顏色名稱
# 軟體:樂高官方 EV3 MicroPython v2.0(microSD 開機卡+VS Code「LEGO MINDSTORMS EV3 MicroPython」擴充套件)
# 接法:神攝手(WRO 版)插 1 號孔
# 這個範例會做什麼:把顏色碼分成幾段,判斷是紅、綠、藍、白、黑,在螢幕上顯示英文名稱並嗶一聲。
# ============================================================

from pybricks.hubs import EV3Brick
from pybricks.iodevices import Ev3devSensor
from pybricks.parameters import Port, Color
from pybricks.tools import wait

ev3 = EV3Brick()
sensor = Ev3devSensor(Port.S1)     # 神攝手(WRO 版)插 1 號孔


def slot_byte(n):
    # 神攝手 WRO 版每 3 個 byte 打包成一個數字,這裡把第 n 個 byte 拆出來
    data = sensor.read('HUE12')
    return (data[n // 3] >> (8 * (n % 3))) & 255


def read_hue1():
    # 色點 S1 的顏色碼:0 ~ 239 彩色(紅 0/239、黃 40、綠 80、青 120、藍 160、紫 200);240~245 白;246~250 黑;255=色點沒開
    return slot_byte(0)


# ---------- 程式從這裡開始 ----------
# 一直重複
while True:
    # 把 S1 的顏色碼存進 hue
    hue = read_hue1()
    # 清除螢幕
    ev3.screen.clear()
    # 如果是紅色
    if hue < 15 or (hue > 225 and hue < 240):
        # 0~14 或 226~239:紅色
        ev3.screen.draw_text(0, 0, "RED      ", Color.BLACK, Color.WHITE)
    # 否則,如果是綠色
    elif hue >= 60 and hue <= 100:
        # 60~100:綠色
        ev3.screen.draw_text(0, 0, "GREEN      ", Color.BLACK, Color.WHITE)
    # 否則,如果是藍色
    elif hue >= 140 and hue <= 180:
        # 140~180:藍色
        ev3.screen.draw_text(0, 0, "BLUE      ", Color.BLACK, Color.WHITE)
    # 否則,如果是白色
    elif hue >= 240 and hue <= 245:
        # 240~245:白色
        ev3.screen.draw_text(0, 0, "WHITE      ", Color.BLACK, Color.WHITE)
    # 否則,如果是黑色
    elif hue >= 246 and hue <= 250:
        # 246~250:黑色
        ev3.screen.draw_text(0, 0, "BLACK      ", Color.BLACK, Color.WHITE)
    else:
        # 其他顏色
        ev3.screen.draw_text(0, 0, "OTHER      ", Color.BLACK, Color.WHITE)
    # 等 0.3 秒
    wait(300)

Step by step:

  1. Repeat forever
    • Store the colour code of S1 in hue
    • Clear the screen
    • If it is red
      • 014 or 226239: red
      • Otherwise:
        • Otherwise, if it is green
          • 60~100: green
          • Otherwise:
            • Otherwise, if it is blue
              • 140~180: blue
              • Otherwise:
                • Otherwise, if it is white
                  • 240~245: white
                  • Otherwise:
                    • Otherwise, if it is black
                      • 246~250: black
                      • Otherwise:
                        • Any other colour
    • Wait 0.3 s

What you should see: Put red, green and blue bricks at the S1 position and the screen shows RED, GREEN, BLUE.

FAQ:

  • The camera screen stays on "LEGO Sync..."? The camera only starts when plugged into an EV3 that is already on. Turn the EV3 on first, then plug in the camera.
  • The number is always 255? That colour spot is not set up (not enabled). Set up S1 as described above.
  • What do the colour numbers mean? 0239 are colours: red 0 (or 239), yellow 40, green 80, cyan 120, blue 160, purple 200; 240245 white; 246~250 black.
  • The camera picture is upside down? Turn V-Flip on in the menu. After changing the orientation, set up the colour spots again.
  • Flashed the school edition first, now the WRO edition spots act strangely? Both editions store settings in the same place: do a Reset Default in the menu first, then set up the spots again.

Example 3: Traffic pillar: stop on red, go on green

What this example does: The red/green pillars common in WRO Future Engineers: S1 looks ahead, stop on red, drive forward on green.

What you need:

  • EV3 brick + Education base robot (left wheel on B, right wheel on C)
  • SharpShot (WRO edition) (EV3 edition)
  • Red and green pillars or bricks

How to connect: SharpShot (WRO edition) in port 1, mounted at the front with the lens facing forward. Camera setup: short-press the side button for the menu → left/right to S1 → confirm → move the crosshair to the spot to watch (X, Y) → set the tolerance → confirm to save.

Download the program (pick your software):

⬇ Pybricks v4 | ⬇ EV3 MicroPython v2.0

Pybricks v4 code
# ============================================================
# 神攝手 ESP32CAM 視覺感應器(WRO 2026 版 HUE12) EV3 新手範例 03:交通號誌柱:紅停綠走
# 軟體:Pybricks v4(用 Chrome 打開 https://code.pybricks.com ,EV3 版目前是 Beta)
# 接法:神攝手(WRO 版)插 1 號孔;左輪馬達接 B、右輪馬達接 C
# 這個範例會做什麼:WRO 未來工程師常見的紅綠柱子:S1 對準前方,看到紅色就停車、看到綠色就往前開。
# ============================================================

from pybricks.hubs import EV3Brick
from pybricks.ev3devices import Motor
from pybricks.iodevices import LUMPDevice
from pybricks.parameters import Port
from pybricks.tools import wait

ev3 = EV3Brick()
sensor = LUMPDevice(Port.S1)       # 神攝手(WRO 版)插 1 號孔
left_motor = Motor(Port.B)        # 左輪
right_motor = Motor(Port.C)       # 右輪


def slot_byte(n):
    # 神攝手 WRO 版每 3 個 byte 打包成一個數字,這裡把第 n 個 byte 拆出來
    data = sensor.read(0)
    return (data[n // 3] >> (8 * (n % 3))) & 255


def read_hue1():
    # 色點 S1 的顏色碼:0 ~ 239 彩色(紅 0/239、黃 40、綠 80、青 120、藍 160、紫 200);240~245 白;246~250 黑;255=色點沒開
    return slot_byte(0)


# ---------- 程式從這裡開始 ----------
# 一直重複
while True:
    # 把 S1 的顏色碼存進 hue
    hue = read_hue1()
    # 如果是綠色(60~100)
    if hue >= 60 and hue <= 100:
        # 綠色:往前開
        left_motor.dc(30)
        right_motor.dc(30)
    # 否則,如果是紅色
    elif hue < 15 or (hue > 225 and hue < 240):
        # 紅色:停車
        left_motor.brake()
        right_motor.brake()
EV3 MicroPython v2.0 code
#!/usr/bin/env pybricks-micropython
# ============================================================
# 神攝手 ESP32CAM 視覺感應器(WRO 2026 版 HUE12) EV3 新手範例 03:交通號誌柱:紅停綠走
# 軟體:樂高官方 EV3 MicroPython v2.0(microSD 開機卡+VS Code「LEGO MINDSTORMS EV3 MicroPython」擴充套件)
# 接法:神攝手(WRO 版)插 1 號孔;左輪馬達接 B、右輪馬達接 C
# 這個範例會做什麼:WRO 未來工程師常見的紅綠柱子:S1 對準前方,看到紅色就停車、看到綠色就往前開。
# ============================================================

from pybricks.hubs import EV3Brick
from pybricks.ev3devices import Motor
from pybricks.iodevices import Ev3devSensor
from pybricks.parameters import Port
from pybricks.tools import wait

ev3 = EV3Brick()
sensor = Ev3devSensor(Port.S1)     # 神攝手(WRO 版)插 1 號孔
left_motor = Motor(Port.B)        # 左輪
right_motor = Motor(Port.C)       # 右輪


def slot_byte(n):
    # 神攝手 WRO 版每 3 個 byte 打包成一個數字,這裡把第 n 個 byte 拆出來
    data = sensor.read('HUE12')
    return (data[n // 3] >> (8 * (n % 3))) & 255


def read_hue1():
    # 色點 S1 的顏色碼:0 ~ 239 彩色(紅 0/239、黃 40、綠 80、青 120、藍 160、紫 200);240~245 白;246~250 黑;255=色點沒開
    return slot_byte(0)


# ---------- 程式從這裡開始 ----------
# 一直重複
while True:
    # 把 S1 的顏色碼存進 hue
    hue = read_hue1()
    # 如果是綠色(60~100)
    if hue >= 60 and hue <= 100:
        # 綠色:往前開
        left_motor.dc(30)
        right_motor.dc(30)
    # 否則,如果是紅色
    elif hue < 15 or (hue > 225 and hue < 240):
        # 紅色:停車
        left_motor.brake()
        right_motor.brake()

Step by step:

  1. Repeat forever
    • Store the colour code of S1 in hue
    • If it is green (60~100)
      • Green: drive forward
      • Otherwise:
        • Otherwise, if it is red
          • Red: stop

What you should see: Put a green pillar ahead and the robot drives; swap to red and it stops. Other colours keep the current action.

FAQ:

  • The camera screen stays on "LEGO Sync..."? The camera only starts when plugged into an EV3 that is already on. Turn the EV3 on first, then plug in the camera.
  • The number is always 255? That colour spot is not set up (not enabled). Set up S1 as described above.
  • What do the colour numbers mean? 0239 are colours: red 0 (or 239), yellow 40, green 80, cyan 120, blue 160, purple 200; 240245 white; 246~250 black.
  • The camera picture is upside down? Turn V-Flip on in the menu. After changing the orientation, set up the colour spots again.
  • Flashed the school edition first, now the WRO edition spots act strangely? Both editions store settings in the same place: do a Reset Default in the menu first, then set up the spots again.

Example 4: Stop at the black line

What this example does: Set S1 at the bottom of the picture looking at the floor; the robot drives forward and stops when S1 sees black (246~250).

What you need:

  • EV3 brick + Education base robot (left wheel on B, right wheel on C)
  • SharpShot (WRO edition) (EV3 edition)
  • A strip of black tape on a white floor

How to connect: SharpShot (WRO edition) in port 1, mounted at the front with the lens facing forward. Camera setup: short-press the side button for the menu → left/right to S1 → confirm → move the crosshair to the bottom of the picture (looking at the floor) → set the tolerance → confirm to save.

Download the program (pick your software):

⬇ Pybricks v4 | ⬇ EV3 MicroPython v2.0

Pybricks v4 code
# ============================================================
# 神攝手 ESP32CAM 視覺感應器(WRO 2026 版 HUE12) EV3 新手範例 04:看到黑線就停車
# 軟體:Pybricks v4(用 Chrome 打開 https://code.pybricks.com ,EV3 版目前是 Beta)
# 接法:神攝手(WRO 版)插 1 號孔;左輪馬達接 B、右輪馬達接 C
# 這個範例會做什麼:把 S1 設在畫面下方對著地面,車子往前開,S1 看到黑色(246~250)就停。
# ============================================================

from pybricks.hubs import EV3Brick
from pybricks.ev3devices import Motor
from pybricks.iodevices import LUMPDevice
from pybricks.parameters import Port
from pybricks.tools import wait

ev3 = EV3Brick()
sensor = LUMPDevice(Port.S1)       # 神攝手(WRO 版)插 1 號孔
left_motor = Motor(Port.B)        # 左輪
right_motor = Motor(Port.C)       # 右輪


def slot_byte(n):
    # 神攝手 WRO 版每 3 個 byte 打包成一個數字,這裡把第 n 個 byte 拆出來
    data = sensor.read(0)
    return (data[n // 3] >> (8 * (n % 3))) & 255


def read_hue1():
    # 色點 S1 的顏色碼:0 ~ 239 彩色(紅 0/239、黃 40、綠 80、青 120、藍 160、紫 200);240~245 白;246~250 黑;255=色點沒開
    return slot_byte(0)


# ---------- 程式從這裡開始 ----------
# 往前開
left_motor.dc(25)
right_motor.dc(25)
# 等到 S1 的顏色碼在 246~250(黑色)
while not (read_hue1() >= 246 and read_hue1() <= 250):
    wait(10)
# 停車
left_motor.brake()
right_motor.brake()
# 嗶一聲
ev3.speaker.beep()
EV3 MicroPython v2.0 code
#!/usr/bin/env pybricks-micropython
# ============================================================
# 神攝手 ESP32CAM 視覺感應器(WRO 2026 版 HUE12) EV3 新手範例 04:看到黑線就停車
# 軟體:樂高官方 EV3 MicroPython v2.0(microSD 開機卡+VS Code「LEGO MINDSTORMS EV3 MicroPython」擴充套件)
# 接法:神攝手(WRO 版)插 1 號孔;左輪馬達接 B、右輪馬達接 C
# 這個範例會做什麼:把 S1 設在畫面下方對著地面,車子往前開,S1 看到黑色(246~250)就停。
# ============================================================

from pybricks.hubs import EV3Brick
from pybricks.ev3devices import Motor
from pybricks.iodevices import Ev3devSensor
from pybricks.parameters import Port
from pybricks.tools import wait

ev3 = EV3Brick()
sensor = Ev3devSensor(Port.S1)     # 神攝手(WRO 版)插 1 號孔
left_motor = Motor(Port.B)        # 左輪
right_motor = Motor(Port.C)       # 右輪


def slot_byte(n):
    # 神攝手 WRO 版每 3 個 byte 打包成一個數字,這裡把第 n 個 byte 拆出來
    data = sensor.read('HUE12')
    return (data[n // 3] >> (8 * (n % 3))) & 255


def read_hue1():
    # 色點 S1 的顏色碼:0 ~ 239 彩色(紅 0/239、黃 40、綠 80、青 120、藍 160、紫 200);240~245 白;246~250 黑;255=色點沒開
    return slot_byte(0)


# ---------- 程式從這裡開始 ----------
# 往前開
left_motor.dc(25)
right_motor.dc(25)
# 等到 S1 的顏色碼在 246~250(黑色)
while not (read_hue1() >= 246 and read_hue1() <= 250):
    wait(10)
# 停車
left_motor.brake()
right_motor.brake()
# 嗶一聲
ev3.speaker.beep()

Step by step:

  1. Drive forward
  2. Wait until the colour code of S1 is 246~250 (black)
  3. Stop
  4. Beep

What you should see: The robot drives forward and stops with a beep when it reaches the black line.

FAQ:

  • The camera screen stays on "LEGO Sync..."? The camera only starts when plugged into an EV3 that is already on. Turn the EV3 on first, then plug in the camera.
  • The number is always 255? That colour spot is not set up (not enabled). Set up S1 as described above.
  • What do the colour numbers mean? 0239 are colours: red 0 (or 239), yellow 40, green 80, cyan 120, blue 160, purple 200; 240245 white; 246~250 black.
  • The camera picture is upside down? Turn V-Flip on in the menu. After changing the orientation, set up the colour spots again.
  • Flashed the school edition first, now the WRO edition spots act strangely? Both editions store settings in the same place: do a Reset Default in the menu first, then set up the spots again.

Example 5: Three spots left, middle, right: where is the red?

What this example does: Set up S1, S2, S3 as left, middle, right. Whichever spot sees red, the robot turns that way; no red means stop.

What you need:

  • EV3 brick + Education base robot (left wheel on B, right wheel on C)
  • SharpShot (WRO edition) (EV3 edition)
  • A red brick

How to connect: SharpShot (WRO edition) in port 1, mounted at the front with the lens facing forward. Camera setup: put S1 on the left of the picture, S2 in the middle and S3 on the right, all three at the same height.

Download the program (pick your software):

⬇ Pybricks v4 | ⬇ EV3 MicroPython v2.0

Pybricks v4 code
# ============================================================
# 神攝手 ESP32CAM 視覺感應器(WRO 2026 版 HUE12) EV3 新手範例 05:左中右三個色點:紅色在哪邊?
# 軟體:Pybricks v4(用 Chrome 打開 https://code.pybricks.com ,EV3 版目前是 Beta)
# 接法:神攝手(WRO 版)插 1 號孔;左輪馬達接 B、右輪馬達接 C
# 這個範例會做什麼:設定 S1(左)、S2(中)、S3(右)三個色點,看紅色出現在哪一個,車子就往那邊轉。
# ============================================================

from pybricks.hubs import EV3Brick
from pybricks.ev3devices import Motor
from pybricks.iodevices import LUMPDevice
from pybricks.parameters import Port
from pybricks.tools import wait

ev3 = EV3Brick()
sensor = LUMPDevice(Port.S1)       # 神攝手(WRO 版)插 1 號孔
left_motor = Motor(Port.B)        # 左輪
right_motor = Motor(Port.C)       # 右輪


def slot_byte(n):
    # 神攝手 WRO 版每 3 個 byte 打包成一個數字,這裡把第 n 個 byte 拆出來
    data = sensor.read(0)
    return (data[n // 3] >> (8 * (n % 3))) & 255


def read_hue1():
    # 色點 S1 的顏色碼:0 ~ 239 彩色(紅 0/239、黃 40、綠 80、青 120、藍 160、紫 200);240~245 白;246~250 黑;255=色點沒開
    return slot_byte(0)


def read_hue3():
    # 色點 S3 的顏色碼:0 ~ 239 彩色(紅 0/239、黃 40、綠 80、青 120、藍 160、紫 200);240~245 白;246~250 黑;255=色點沒開
    return slot_byte(4)


def read_hue2():
    # 色點 S2 的顏色碼:0 ~ 239 彩色(紅 0/239、黃 40、綠 80、青 120、藍 160、紫 200);240~245 白;246~250 黑;255=色點沒開
    return slot_byte(2)


# ---------- 程式從這裡開始 ----------
# 一直重複
while True:
    # 如果 S1 是紅色
    if read_hue1() < 15 or (read_hue1() > 225 and read_hue1() < 240):
        # 紅色在左邊(S1):往左轉
        left_motor.dc(-15)
        right_motor.dc(15)
    # 否則,如果 S3 是紅色
    elif read_hue3() < 15 or (read_hue3() > 225 and read_hue3() < 240):
        # 紅色在右邊(S3):往右轉
        left_motor.dc(15)
        right_motor.dc(-15)
    # 否則,如果 S2 是紅色
    elif read_hue2() < 15 or (read_hue2() > 225 and read_hue2() < 240):
        # 紅色在中間(S2):往前開
        left_motor.dc(25)
        right_motor.dc(25)
    else:
        # 沒看到紅色:停住
        left_motor.brake()
        right_motor.brake()
EV3 MicroPython v2.0 code
#!/usr/bin/env pybricks-micropython
# ============================================================
# 神攝手 ESP32CAM 視覺感應器(WRO 2026 版 HUE12) EV3 新手範例 05:左中右三個色點:紅色在哪邊?
# 軟體:樂高官方 EV3 MicroPython v2.0(microSD 開機卡+VS Code「LEGO MINDSTORMS EV3 MicroPython」擴充套件)
# 接法:神攝手(WRO 版)插 1 號孔;左輪馬達接 B、右輪馬達接 C
# 這個範例會做什麼:設定 S1(左)、S2(中)、S3(右)三個色點,看紅色出現在哪一個,車子就往那邊轉。
# ============================================================

from pybricks.hubs import EV3Brick
from pybricks.ev3devices import Motor
from pybricks.iodevices import Ev3devSensor
from pybricks.parameters import Port
from pybricks.tools import wait

ev3 = EV3Brick()
sensor = Ev3devSensor(Port.S1)     # 神攝手(WRO 版)插 1 號孔
left_motor = Motor(Port.B)        # 左輪
right_motor = Motor(Port.C)       # 右輪


def slot_byte(n):
    # 神攝手 WRO 版每 3 個 byte 打包成一個數字,這裡把第 n 個 byte 拆出來
    data = sensor.read('HUE12')
    return (data[n // 3] >> (8 * (n % 3))) & 255


def read_hue1():
    # 色點 S1 的顏色碼:0 ~ 239 彩色(紅 0/239、黃 40、綠 80、青 120、藍 160、紫 200);240~245 白;246~250 黑;255=色點沒開
    return slot_byte(0)


def read_hue3():
    # 色點 S3 的顏色碼:0 ~ 239 彩色(紅 0/239、黃 40、綠 80、青 120、藍 160、紫 200);240~245 白;246~250 黑;255=色點沒開
    return slot_byte(4)


def read_hue2():
    # 色點 S2 的顏色碼:0 ~ 239 彩色(紅 0/239、黃 40、綠 80、青 120、藍 160、紫 200);240~245 白;246~250 黑;255=色點沒開
    return slot_byte(2)


# ---------- 程式從這裡開始 ----------
# 一直重複
while True:
    # 如果 S1 是紅色
    if read_hue1() < 15 or (read_hue1() > 225 and read_hue1() < 240):
        # 紅色在左邊(S1):往左轉
        left_motor.dc(-15)
        right_motor.dc(15)
    # 否則,如果 S3 是紅色
    elif read_hue3() < 15 or (read_hue3() > 225 and read_hue3() < 240):
        # 紅色在右邊(S3):往右轉
        left_motor.dc(15)
        right_motor.dc(-15)
    # 否則,如果 S2 是紅色
    elif read_hue2() < 15 or (read_hue2() > 225 and read_hue2() < 240):
        # 紅色在中間(S2):往前開
        left_motor.dc(25)
        right_motor.dc(25)
    else:
        # 沒看到紅色:停住
        left_motor.brake()
        right_motor.brake()

Step by step:

  1. Repeat forever
    • If S1 is red
      • Red on the left (S1): turn left
      • Otherwise:
        • Otherwise, if S3 is red
          • Red on the right (S3): turn right
          • Otherwise:
            • Otherwise, if S2 is red
              • Red in the middle (S2): drive forward
              • Otherwise:
                • No red seen: stop

What you should see: Move the red brick left, centre and right in front of the camera and the robot turns left, drives forward or turns right.

FAQ:

  • The camera screen stays on "LEGO Sync..."? The camera only starts when plugged into an EV3 that is already on. Turn the EV3 on first, then plug in the camera.
  • The number is always 255? That colour spot is not set up (not enabled). Set up S1 as described above.
  • What do the colour numbers mean? 0239 are colours: red 0 (or 239), yellow 40, green 80, cyan 120, blue 160, purple 200; 240245 white; 246~250 black.
  • The camera picture is upside down? Turn V-Flip on in the menu. After changing the orientation, set up the colour spots again.
  • Flashed the school edition first, now the WRO edition spots act strangely? Both editions store settings in the same place: do a Reset Default in the menu first, then set up the spots again.

Still stuck? Leave a message on Contact us with the software you use and a screenshot of your program, and we will help.

More questions

  • The EV3 shows an infrared sensor? Expected: the sensor emulates a LEGO sensor so the stock blocks can read it.
  • A short freeze when switching modes? The EV3 needs about 1 s per mode change. Stick to one mode during a run.

Still stuck? Contact us with your software and a screenshot of the program.

Downloads

Sources

  • Host and software list:_build/guides.json
  • Values and commands:_build/protocol/cam_school.json、_build/protocol/cam_wro.json (single source of truth)
  • Setup:_build/guides/software/ev3-pybricks.en.md、_build/guides/product/esp32cam/ev3-pybricks.en.md
  • Examples:sensors/esp32cam/ev3-examples(-wro).md
Email for a quoteBuying Guide