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.

This page has moved into the new guide: SharpShot Vision › EV3

EV3 beginner examples: SharpShot (WRO edition)

Back to the SharpShot (WRO edition) product page

This page has 5 examples for people who have never written a program: every example comes with a ready-made program file you can download and run, plus a plain-language step-by-step explanation. Start with example 1 and work through in order.

Before you start

  1. Use the EV3 edition of the sensor (RJ12 plug), plugged into port 1 of the EV3.
  2. Turn the EV3 on first, then plug in the sensor. If the number never changes, unplug the sensor and plug it back in.
  3. Examples that drive use the LEGO Education base robot: left wheel motor on B, right wheel motor on C.
  4. This edition works with EV3-G, clev3r and Pybricks only; EV3 Classroom cannot read it.
  5. For EV3-G, first download the MBC custom block MBC_Hue12Sensor.ev3b and import it once with "Tools → Block Import" (once per computer), otherwise the example projects will not open.

Every example comes in 4 software versions; pick the one you use:

Software Who it suits How to open the example file
EV3-G (official software) School computer labs, WRO teams (the most common in Taiwan) Download the .ev3 file, choose "File → Open Project" in the EV3 software, then "Download and Run" at the bottom right.
Pybricks v4 Want to learn typed code, works in the browser Open code.pybricks.com in Chrome; the EV3 needs the Pybricks firmware first (currently Beta). Drag the .py file into the editor and press Run.
EV3 MicroPython v2.0 Already using the official LEGO EV3 MicroPython Use the official LEGO "EV3 MicroPython" microSD boot card + the VS Code extension; paste the program into main.py and press F5 to download and run.
clev3r Already using clev3r (EV3 Basic) Open the .bp file in clev3r, press "Compile and download", then run it from the MBC_ folder in the EV3 file browser.

The 4 values used on this page

Name Range Where it comes from
Colour code of spot S1 0 ~ 239 colour (red 0/239, yellow 40, green 80, cyan 120, blue 160, purple 200); 240245 white; 246250 black; 255 = spot disabled Spot S1
Saturation of spot S1 0 ~ 255 (black is always 1) Spot S1
Colour code of spot S3 0 ~ 239 colour (red 0/239, yellow 40, green 80, cyan 120, blue 160, purple 200); 240245 white; 246250 black; 255 = spot disabled Spot S3
Colour code of spot S2 0 ~ 239 colour (red 0/239, yellow 40, green 80, cyan 120, blue 160, purple 200); 240245 white; 246250 black; 255 = spot disabled Spot S2

Example list:

  1. What colour does spot S1 see?
  2. Colour announcer: show the colour name on screen
  3. Traffic pillar: stop on red, go on green
  4. Stop at the black line
  5. Three spots left, middle, right: where is the red?

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):

⬇ EV3-G (official software) | ⬇ Pybricks v4 | ⬇ EV3 MicroPython v2.0 | ⬇ clev3r

EV3-G (official software) blocks

SharpShot (WRO edition) What colour does spot S1 see?(EV3-G (official software))

(Too small? Click the picture to open it full size.)

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)
clev3r code
' ============================================================
' 神攝手 ESP32CAM 視覺感應器(WRO 2026 版 HUE12) EV3 新手範例 01:色點 S1 看到什麼顏色?
' 軟體:clev3r
' 接法:神攝手(WRO 版)插 1 號孔;左輪馬達接 B、右輪馬達接 C
' 這個範例會做什麼:WRO 版有 12 個色點,每個色點回報「那一個位置現在的顏色」。先設定 S1,把它的顏色碼和鮮豔度顯示在螢幕上。
' 讀值:hue1=色點 S1 的顏色碼(0 ~ 239 彩色(紅 0/239、黃 40、綠 80、青 120、藍 160、紫 200);240~245 白;246~250 黑;255=色點沒開);sta1=色點 S1 的鮮豔度(0 ~ 255(黑色固定 1))
' ============================================================
folder "prjs" "MBC_esp32cam_wro_ex01"

' 神攝手(WRO 版)插 1 號孔,使用模式 0
Sensor.SetMode(1, 0)
LCD.Clear()

' 清除螢幕
LCD.Clear()
' 一直重複
While "True"
  ' 第 1 行:S1 的顏色碼
  LCD.Text(1, 0, 0, 1, "S1 " + Math.Remainder(Sensor.ReadRawValue(1, 0), 256) + "      ")
  ' 第 2 行:S1 的鮮豔度
  LCD.Text(1, 0, 16, 1, "T1 " + Math.Remainder(Math.Floor(Sensor.ReadRawValue(1, 0) / 256), 256) + "      ")
  ' 等 0.1 秒
  Program.Delay(100)
EndWhile

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):

⬇ EV3-G (official software) | ⬇ Pybricks v4 | ⬇ EV3 MicroPython v2.0 | ⬇ clev3r

EV3-G (official software) blocks

SharpShot (WRO edition) Colour announcer: show the colour name on screen(EV3-G (official software))

(Too small? Click the picture to open it full size.)

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)
clev3r code
' ============================================================
' 神攝手 ESP32CAM 視覺感應器(WRO 2026 版 HUE12) EV3 新手範例 02:顏色播報:螢幕顯示顏色名稱
' 軟體:clev3r
' 接法:神攝手(WRO 版)插 1 號孔;左輪馬達接 B、右輪馬達接 C
' 這個範例會做什麼:把顏色碼分成幾段,判斷是紅、綠、藍、白、黑,在螢幕上顯示英文名稱並嗶一聲。
' 讀值:hue1=色點 S1 的顏色碼(0 ~ 239 彩色(紅 0/239、黃 40、綠 80、青 120、藍 160、紫 200);240~245 白;246~250 黑;255=色點沒開)
' ============================================================
folder "prjs" "MBC_esp32cam_wro_ex02"

' 神攝手(WRO 版)插 1 號孔,使用模式 0
Sensor.SetMode(1, 0)
LCD.Clear()

' 一直重複
While "True"
  ' 把 S1 的顏色碼存進 hue
  hue = Math.Remainder(Sensor.ReadRawValue(1, 0), 256)
  ' 清除螢幕
  LCD.Clear()
  ' 如果是紅色
  If (hue < 15) Or ((hue > 225) And (hue < 240)) Then
    ' 0~14 或 226~239:紅色
    LCD.Text(1, 0, 0, 1, "RED      ")
  ' 否則,如果是綠色
  ElseIf (hue >= 60) And (hue <= 100) Then
    ' 60~100:綠色
    LCD.Text(1, 0, 0, 1, "GREEN      ")
  ' 否則,如果是藍色
  ElseIf (hue >= 140) And (hue <= 180) Then
    ' 140~180:藍色
    LCD.Text(1, 0, 0, 1, "BLUE      ")
  ' 否則,如果是白色
  ElseIf (hue >= 240) And (hue <= 245) Then
    ' 240~245:白色
    LCD.Text(1, 0, 0, 1, "WHITE      ")
  ' 否則,如果是黑色
  ElseIf (hue >= 246) And (hue <= 250) Then
    ' 246~250:黑色
    LCD.Text(1, 0, 0, 1, "BLACK      ")
  Else
    ' 其他顏色
    LCD.Text(1, 0, 0, 1, "OTHER      ")
  EndIf
  ' 等 0.3 秒
  Program.Delay(300)
EndWhile

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):

⬇ EV3-G (official software) | ⬇ Pybricks v4 | ⬇ EV3 MicroPython v2.0 | ⬇ clev3r

EV3-G (official software) blocks

SharpShot (WRO edition) Traffic pillar: stop on red, go on green(EV3-G (official software))

(Too small? Click the picture to open it full size.)

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()
clev3r code
' ============================================================
' 神攝手 ESP32CAM 視覺感應器(WRO 2026 版 HUE12) EV3 新手範例 03:交通號誌柱:紅停綠走
' 軟體:clev3r
' 接法:神攝手(WRO 版)插 1 號孔;左輪馬達接 B、右輪馬達接 C
' 這個範例會做什麼:WRO 未來工程師常見的紅綠柱子:S1 對準前方,看到紅色就停車、看到綠色就往前開。
' 讀值:hue1=色點 S1 的顏色碼(0 ~ 239 彩色(紅 0/239、黃 40、綠 80、青 120、藍 160、紫 200);240~245 白;246~250 黑;255=色點沒開)
' ============================================================
folder "prjs" "MBC_esp32cam_wro_ex03"

' 神攝手(WRO 版)插 1 號孔,使用模式 0
Sensor.SetMode(1, 0)
LCD.Clear()

' 一直重複
While "True"
  ' 把 S1 的顏色碼存進 hue
  hue = Math.Remainder(Sensor.ReadRawValue(1, 0), 256)
  ' 如果是綠色(60~100)
  If (hue >= 60) And (hue <= 100) Then
    ' 綠色:往前開
    Motor.StartPower("B", 30)
    Motor.StartPower("C", 30)
  ' 否則,如果是紅色
  ElseIf (hue < 15) Or ((hue > 225) And (hue < 240)) Then
    ' 紅色:停車
    Motor.Stop("BC", "True")
  EndIf
EndWhile

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):

⬇ EV3-G (official software) | ⬇ Pybricks v4 | ⬇ EV3 MicroPython v2.0 | ⬇ clev3r

EV3-G (official software) blocks

SharpShot (WRO edition) Stop at the black line(EV3-G (official software))

(Too small? Click the picture to open it full size.)

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()
clev3r code
' ============================================================
' 神攝手 ESP32CAM 視覺感應器(WRO 2026 版 HUE12) EV3 新手範例 04:看到黑線就停車
' 軟體:clev3r
' 接法:神攝手(WRO 版)插 1 號孔;左輪馬達接 B、右輪馬達接 C
' 這個範例會做什麼:把 S1 設在畫面下方對著地面,車子往前開,S1 看到黑色(246~250)就停。
' 讀值:hue1=色點 S1 的顏色碼(0 ~ 239 彩色(紅 0/239、黃 40、綠 80、青 120、藍 160、紫 200);240~245 白;246~250 黑;255=色點沒開)
' ============================================================
folder "prjs" "MBC_esp32cam_wro_ex04"

' 神攝手(WRO 版)插 1 號孔,使用模式 0
Sensor.SetMode(1, 0)
LCD.Clear()

' 往前開
Motor.StartPower("B", 25)
Motor.StartPower("C", 25)
' 等到 S1 的顏色碼在 246~250(黑色)
While (Math.Remainder(Sensor.ReadRawValue(1, 0), 256) < 246) Or (Math.Remainder(Sensor.ReadRawValue(1, 0), 256) > 250)
  Program.Delay(10)
EndWhile
' 停車
Motor.Stop("BC", "True")
' 嗶一聲
Speaker.Tone(50, 1000, 100)
Speaker.Wait()

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):

⬇ EV3-G (official software) | ⬇ Pybricks v4 | ⬇ EV3 MicroPython v2.0 | ⬇ clev3r

EV3-G (official software) blocks

SharpShot (WRO edition) Three spots left, middle, right: where is the red?(EV3-G (official software))

(Too small? Click the picture to open it full size.)

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()
clev3r code
' ============================================================
' 神攝手 ESP32CAM 視覺感應器(WRO 2026 版 HUE12) EV3 新手範例 05:左中右三個色點:紅色在哪邊?
' 軟體:clev3r
' 接法:神攝手(WRO 版)插 1 號孔;左輪馬達接 B、右輪馬達接 C
' 這個範例會做什麼:設定 S1(左)、S2(中)、S3(右)三個色點,看紅色出現在哪一個,車子就往那邊轉。
' 讀值:hue1=色點 S1 的顏色碼(0 ~ 239 彩色(紅 0/239、黃 40、綠 80、青 120、藍 160、紫 200);240~245 白;246~250 黑;255=色點沒開);hue3=色點 S3 的顏色碼(0 ~ 239 彩色(紅 0/239、黃 40、綠 80、青 120、藍 160、紫 200);240~245 白;246~250 黑;255=色點沒開);hue2=色點 S2 的顏色碼(0 ~ 239 彩色(紅 0/239、黃 40、綠 80、青 120、藍 160、紫 200);240~245 白;246~250 黑;255=色點沒開)
' ============================================================
folder "prjs" "MBC_esp32cam_wro_ex05"

' 神攝手(WRO 版)插 1 號孔,使用模式 0
Sensor.SetMode(1, 0)
LCD.Clear()

' 一直重複
While "True"
  ' 如果 S1 是紅色
  If (Math.Remainder(Sensor.ReadRawValue(1, 0), 256) < 15) Or ((Math.Remainder(Sensor.ReadRawValue(1, 0), 256) > 225) And (Math.Remainder(Sensor.ReadRawValue(1, 0), 256) < 240)) Then
    ' 紅色在左邊(S1):往左轉
    Motor.StartPower("B", -15)
    Motor.StartPower("C", 15)
  ' 否則,如果 S3 是紅色
  ElseIf (Math.Remainder(Math.Floor(Sensor.ReadRawValue(1, 1) / 256), 256) < 15) Or ((Math.Remainder(Math.Floor(Sensor.ReadRawValue(1, 1) / 256), 256) > 225) And (Math.Remainder(Math.Floor(Sensor.ReadRawValue(1, 1) / 256), 256) < 240)) Then
    ' 紅色在右邊(S3):往右轉
    Motor.StartPower("B", 15)
    Motor.StartPower("C", -15)
  ' 否則,如果 S2 是紅色
  ElseIf (Math.Remainder(Math.Floor(Sensor.ReadRawValue(1, 0) / 65536), 256) < 15) Or ((Math.Remainder(Math.Floor(Sensor.ReadRawValue(1, 0) / 65536), 256) > 225) And (Math.Remainder(Math.Floor(Sensor.ReadRawValue(1, 0) / 65536), 256) < 240)) Then
    ' 紅色在中間(S2):往前開
    Motor.StartPower("B", 25)
    Motor.StartPower("C", 25)
  Else
    ' 沒看到紅色:停住
    Motor.Stop("BC", "True")
  EndIf
EndWhile

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.

Email for a quoteBuying Guide