用 Arduino + 超聲波感測器打造互動燈光裝置 🔊💡

用 Arduino + 超聲波感測器打造互動燈光裝置 🔊💡 前言 想做出「手一靠近燈就亮」的魔術效果嗎?其實只要幾百塊錢的零件,就能用 Arduino + 超聲波感測器做出超酷的互動燈光裝置! 今天就來分享如何從零打造這套系統,適合新手入門,也適合拿来做為互動藝術專案的基础。 原理說明 超聲波感測器怎麼測距離? HC-SR04 超聲波感測器運作原理很直覺: 發射超聲波:模組發射一個 40...

By · · 1 min read
用 Arduino + 超聲波感測器打造互動燈光裝置 🔊💡

Source: DEV Community

用 Arduino + 超聲波感測器打造互動燈光裝置 🔊💡 前言 想做出「手一靠近燈就亮」的魔術效果嗎?其實只要幾百塊錢的零件,就能用 Arduino + 超聲波感測器做出超酷的互動燈光裝置! 今天就來分享如何從零打造這套系統,適合新手入門,也適合拿来做為互動藝術專案的基础。 原理說明 超聲波感測器怎麼測距離? HC-SR04 超聲波感測器運作原理很直覺: 發射超聲波:模組發射一個 40kHz 的超聲波脈衝 等待反射:超聲波碰到障礙物後反彈回來 計算時間:模組測量超聲波來回的飛行時間 轉換距離:使用公式 距離 = 時間 × 聲速 / 2(除以二是因為要算單程) 聲速大約是 340 m/s,所以在室溫下公式可以簡化為:距離(cm) = 時間(μs) / 58 LED 亮度控制 Arduino 控制 LED 亮度的方式是 PWM(脈寬調變)。簡單來說: 把數位訊號「開開關關」,以極快速度切換 調整「開」的比例,就能控制平均電壓 進而控制 LED 的亮度(0 = 全暗,255 = 最亮) 硬體清單 零件 數量 備註 Arduino Uno 1 也可以用 Nano 或 Mega HC-SR04 超聲波感測器 1 測量範圍 2cm - 400cm RGB LED 或 單色 LED 1-3 這裡用 RGB LED 做示範 220Ω 電阻 3 限流用 麵包板 + 跳線 若干 組裝用 電路接線圖 Arduino HC-SR04 ------- ------- 5V ───► VCC GND ───► GND Pin 7 ───► TRIG Pin 6 ───► ECHO (透過 1kΩ 電阻分壓保護 Arduino) Arduino RGB LED (共陽極) ------- --------------- Pin 9 ───► R (透過 220Ω) Pin 10 ───► G (透過 220Ω) Pin 11 ───► B (透過 220Ω) 5V ───► 共陽腳 (最長的腳) ⚠️ 注意:HC-SR04 的 ECHO 腳會輸出 5V 訊號,直接接到 Arduino 5V 針腳可能會有風險。建議加上 1kΩ + 2kΩ 電阻做分壓,或使用 5V 容忍的 Arduino 板(如 Due)。 程式碼 // 互動燈光裝置 - 超聲波感測器控制 RGB LED // 作者:你的名

Related Posts

Similar Topics

#webdev (160)#ai (159)#for (113)#python (110)#programming (99)#learn (104)#productivity (76)#javascript (58)#algorithms (42)#computerscience (35)#devops (36)#instrument (15)#api (33)#learning (30)#security (27)#agents (27)#language (27)#terraform (15)#opensource (24)#career (21)

Trending on ShareHub

  1. Understanding Modern JavaScript Frameworks in 2026
    by Alex Chen · Feb 12, 2026 · 0 likes
  2. The System Design Primer
    by Sarah Kim · Feb 12, 2026 · 0 likes
  3. Just shipped my first open-source project!
    by Alex Chen · Feb 12, 2026 · 0 likes
  4. OpenAI Blog
    by Sarah Kim · Feb 12, 2026 · 0 likes
  5. Building Accessible Web Applications: A Practical Guide
    by Alex Chen · Feb 12, 2026 · 0 likes
  6. Rapper Lil Poppa dead at 25, days after releasing new music
    Rapper Lil Poppa dead at 25, days after releasing new music
    by Anonymous User · Feb 19, 2026 · 0 likes
  7. write-for-us
    by Volt Raven · Mar 7, 2026 · 0 likes
  8. Before the Coffee Gets Cold: Heartfelt Story of Time Travel and Second Chances
    Before the Coffee Gets Cold: Heartfelt Story of Time Travel and Second Chances
    by Anonymous User · Feb 12, 2026 · 0 likes
    #coffee gets cold #the #time travel
  9. Best DoorDash Promo Code Reddit Finds for Top Discounts
    Best DoorDash Promo Code Reddit Finds for Top Discounts
    by Anonymous User · Feb 12, 2026 · 0 likes
    #doordash #promo #reddit
  10. Premium SEO Services That Boost Rankings & Revenue | VirtualSEO.Expert
    by Anonymous User · Feb 12, 2026 · 0 likes
  11. NBC under fire for commentary about Team USA women's hockey team
    NBC under fire for commentary about Team USA women's hockey team
    by Anonymous User · Feb 18, 2026 · 0 likes
  12. Where to Watch The Nanny: Streaming and Online Viewing Options
    Where to Watch The Nanny: Streaming and Online Viewing Options
    by Anonymous User · Feb 12, 2026 · 0 likes
    #streaming #the nanny #where
  13. How Much Is Kindle Unlimited? Subscription Cost and Plan Details
    How Much Is Kindle Unlimited? Subscription Cost and Plan Details
    by Anonymous User · Feb 12, 2026 · 0 likes
    #kindle unlimited #subscription #unlimited
  14. Russian skater facing backlash for comment about Amber Glenn
    Russian skater facing backlash for comment about Amber Glenn
    by Anonymous User · Feb 18, 2026 · 0 likes
  15. Google News
    Google News
    by Anonymous User · Feb 18, 2026 · 0 likes

Latest on ShareHub

Browse Topics

#artificial intelligence (36883)#data science (24144)#generative ai (19046)#ai (17823)#crypto (15048)#machine learning (14734)#bitcoin (14333)#featured (13584)#news & insights (13064)#crypto news (11118)

Around the Network