Arduino Serial 通訊教學|將資料傳送到 TouchDesigner 並實現互動控制

本教學說明如何透過 Serial 通訊將 Arduino 資料傳送至 TouchDesigner,並透過 Serial (DAT) 實現實時互動控制。包含完整 Arduino 程式碼與 TouchDesigner 設定流程,適合互動設計初學者快速上手。

Dec 27, 2021
🧰 TouchDesigner 工具庫 | Luxmin Institute on Patreon
我們把接案與展場現場累積下來的 TouchDesigner 元件、專案檔與製作系統,整理發佈在 Patreon,部分工具與 Demo 免費開放下載。
https://www.patreon.com/cw/LuxminInstitute
⭑⭑⭑⭑⭑⭑⭑⭑⭑⭑⭑⭑⭑⭑⭑⭑
這篇教學將引導您如何從 Arduino 傳送資料到 TouchDesigner,實現兩者之間的串列通訊。

Arduino 端

完整程式碼

void setup() { Serial.begin(9600); } void loop() { int dir = 0; Serial.print(dir); delay(100); }

說明

  1. 設定 Serial 通訊速率:在 setup() 函數中,使用 Serial.begin(9600); 設定與 TouchDesigner 通訊的 baud 率為 9600。
  2. 傳送資料:在 loop() 函數中,使用 Serial.print(dir); 將變數 dir 的值傳送到串列埠。
  3. 延遲傳送:使用 delay(100); 讓每次資料傳送之間有 100 毫秒的間隔,避免資料過於頻繁地傳送。

TouchDesigner 端

  1. 新增 Serial DAT:在 TouchDesigner 中,新增一個 Serial (DAT) Operator,用於接收 Arduino 傳送的資料。
  2. 設定參數
    • Port:選擇 Arduino 所連接的 Serial 端口。
    notion image
    • Baud Rate:設定為 9600,與 Arduino 端一致。
    notion image
  3. 查看資料:啟動 Arduino 程式後,您應該可以在 Serial (DAT) 中看到從 Arduino 傳送過來的資料。
  4. 進一步處理:您可以使用其他 DAT 或 CHOP Operator 對接收到的資料進行處理,實現各種互動效果。
notion image
⭑⭑⭑⭑⭑⭑⭑⭑⭑⭑⭑⭑⭑⭑⭑⭑
Luxmin Institute (互動研究院) on Patreon
教學講的是觀念,工具則是我們在真實展場裡跑過、改過、確定能用的東西。TD 元件、專案檔、校正與製作流程都陸續發佈在 Patreon 上,免費層可以先看 Demo 與公開工具,付費層取得完整檔案與更新:
https://www.patreon.com/cw/LuxminInstitute
最新的活動動態與報名資訊:
https://www.threads.com/@luxmin.institute
 
如有相關專案或其他需求,請洽 luxmin.art