本文是參考部落格文章:Cactus x Raspberry Pi,但改用Arduino UNO Q開發板 並搭配新版本的Needle 3進行實作驗證。關於Needle AI模型與Arduino UNO Q開發板的背景知識就不再此重複說明,請參照「參考資訊」內連結之內容。
接下來進行「將文字輸入轉化為動作」的實作,使用這段英文"Please turn on the device's LED."將Arduino UNO Q開發板上的LED點亮。相關步驟說明如下:
【步驟一】 開啟Arduino App Lab,選擇「Blink LED from Python」範例:

【步驟二】 點選Arduino App Lab右上方複製按鈕,以複製該範例:

並將專案命名為「Cactus Needle Hello World」:

【步驟三】 在python目錄下新增requirements.txt,加入Needle套件:

並修改main.py程式碼:

完整的Python程式碼如下所示:
from arduino.app_utils import *
import needle
# Define your hardware action tools using the @needle.tool decorator
@needle.tool
def set_led(state: str):
"""Turn the device LED on or off.
Args:
state: Must be either 'on' or 'off'.
"""
if state.lower() == "on":
Bridge.call("set_led_state", True)
print("Hardware action: LED turned ON")
return {"status": "success", "led": "on"}
elif state.lower() == "off":
Bridge.call("set_led_state", False)
print("Hardware action: LED turned OFF")
return {"status": "success", "led": "off"}
return {"status": "error", "message": "Invalid state argument"}
# Initialize the Needle agent with your tools
agent = needle.Needle(tools=[set_led])
# Run a natural language prompt to trigger the action
response = agent.run("Please turn on the device's LED.")
print(response["results"])
App.run()
之後點選Arduino App Lab右上方Run按鈕,以執行該專案。
【步驟四】 執行結果如下所示:

參考資訊
- Edge AI Taiwan邊緣智能交流區之介紹文章 :
Needle 2是由Cactus Compute開發的超輕量級開源基礎 AI 模型(4,500 萬參數),檔案大小僅有14MB,專門針對手機、穿戴式裝置、智慧家庭與機器人等邊緣運算裝置設計,可在極低資源環境下實現離線的工具呼叫(Tool Calling)與結構化資料萃取。- Arduino UNO Q 專欄:
- 【Arduino UNO Q 專欄01】- 基礎硬體及軟體簡介
- 【Arduino UNO Q 專欄02】- 軟體開發初體驗
- EDGE AI Taipei 2026議程:
A Siri for Your Fridge — Cactus Needle: a Tiny Function-Calling LLM for Any Hardware