Zum Hauptinhalt springen
LIVE
CVSS 6.5CVE-2026-111315 | The Smaily Connect plugin for WordPress is vulnerable to Insecure Direct Object Reference in versions up to, and including, 3.24.0 This is due to the smaily_get_edit_user_id() function reading an attacker-controlled $_GET['user_id'] parameter without performing any ownership or capability check, and then feeding that id into smaily_get_userdata() (which calls get_user_meta()) when rendering the WooCommerce My Account 'edit-account' form via the smaily_print_CVSS 6.4CVE-2026-137713 | Webmin through 2.670 before ae8feb1 allows XSS via an SVG attachment in a mail queue, relevant if an authenticated user uploads an SVG document and an administrator views it.CVSS 6.9CVE-2026-137678 | A security vulnerability has been detected in code-projects Online Job Portal 1.0. Affected by this issue is some unknown functionality of the file Admin/InsertUser.php. Such manipulation of the argument txtUserName/txtPassword leads to sql injection. The attack can be launched remotely. The exploit has been disclosed publicly and may be used.CVSS 5.3CVE-2026-137703 | Flask-AppBuilder before 5.3.1 contains a path traversal vulnerability in ImageManager.save_file that allows authenticated users to write image files outside IMG_UPLOAD_FOLDER via unsanitized multipart filenames. Attackers with add or edit permission on a ModelView with an ImageColumn can upload filenames containing ../ segments to create or overwrite image files like static assets.CVSS 6.1CVE-2026-130039 | The LiteSpeed Cache plugin for WordPress is vulnerable to Stored Cross-Site Scripting via the 'REQUEST_URI' parameter in all versions up to, and including, 7.9.3 due to insufficient input sanitization and output escaping. This makes it possible for unauthenticated attackers to inject arbitrary web scripts in pages that will execute whenever a user accesses an injected page. Successful exploitation requires comments to be open, a comment author name containinCVSS 6.1CVE-2026-136206 | The Export Products, Orders & Customers for WooCommerce plugin for WordPress is vulnerable to Reflected Cross-Site Scripting via the 'start_date' parameter in all versions up to, and including, 2.4.3 due to insufficient input sanitization and output escaping. This makes it possible for unauthenticated attackers to inject arbitrary web scripts in pages that execute if they can successfully trick a user into performing an action such as clicking on a link. SucCVSS 9.4CVE-2026-137706 | Smart Portal developed by Direk Tech has a Missing Authorization vulnerability. Authenticated remote attackers can add a specified account to the Active Directory Domain Admins group, thereby obtaining domain administrator privileges.CVSS 8.7CVE-2026-137705 | Smart Portal developed by Direk Tech has an Arbitrary File Read vulnerability.Unauthenticated remote attackers can exploit Relative Path Traversal to download arbitrary system files.
Alle im Drawer
Intelligence View
⚡ tsecurity.de Intelligence

用超聲波加紅外線達成全向障礙偵測:Arduino 雙感測器整合

Arduino 超聲波與紅外線感測器整合:打造全向障礙偵測系統 為光譜裡誰做:阿哲(想做避障小車) Parent Gene:超聲波感測(14)、紅外線感測(09) 概念句:用超聲波加紅外線達成全向障礙偵測 想像一下:你在桌子上的小型避障小車,忽然遇到一隻手、一塊淺色保麗龍、和遠處的牆——三種不同的障礙,它都能正確停下來…

Beitrag
0
Seite
0
↗ Quelle (dev.to)
Quelle & Fakten · 2 Min. Lesezeit
Quelle: dev.to
Rubrik: Sichere Programmierung




Arduino 超聲波與紅外線感測器整合:打造全向障礙偵測系統



為光譜裡誰做:阿哲(想做避障小車)

Parent Gene:超聲波感測(14)、紅外線感測(09)



概念句:用超聲波加紅外線達成全向障礙偵測






想像一下:你在桌子上的小型避障小車,忽然遇到一隻手、一塊淺色保麗龍、和遠處的牆——三種不同的障礙,它都能正確停下來嗎?



單一感測器做不到。但把超聲波感測器(HC-SR04)和紅外線感測器加在一起,就可以。






1. 為什麼要整合?(互補特性分析)






超音波感測器(HC-SR04)





  • 原理:發射超聲波,計算回傳時間 \text{Distance} = \frac{\text{Sonic Speed} \times \text{Time}}{2}。


  • 優點:測距範圍廣(約 2cm ~ 400cm),對物體顏色不敏感。


  • 缺點:



    • 盲區:太近的物體測不准。


    • 聲波散射:面對傾斜表面或吸音材料(海綿、布料)時,聲波被散射而回傳失敗,導致「看不見」障礙物。








紅外線感測器





  • 原理:發射紅外光,偵測反射回來的光強度。


  • 優點:反應速度快,適合近距離偵測(邊緣偵測、極近障礙)。


  • 缺點:



    • 深色物體吸收紅外光:黑色或深色表面會讓偵測距離大幅縮短甚至完全偵測不到。


    • 環境光干擾:強烈陽光(含紅外線成分)可能造成誤判。








整合策略:雙重驗證






































情境 超音波結果 紅外線結果 系統判定
遠處有牆 \text{Distance} < 20\text{cm} 無觸發 障礙物(遠)
面對淺色保麗龍(多孔) 無回傳(散射)
觸發(吸光少)

僅超聲波(超聲波盲,IR 補上)
面前有白色牆壁 \text{Distance} < 5\text{cm} 觸發 障礙物(極近)
空曠環境 \text{Distance} > 20\text{cm} 無觸發 安全



阿哲可能遇到的問題:為什麼淺色保麗龍讓超聲波「失效」了,但紅外線卻測到了?因為保麗龍表面軟、多孔,聲波散射回不上來,但紅外光仍能反射回讀——兩種感測器的物理特性不同,剛好互補。










2. 硬體接線






元件清單




  • Arduino Uno 或 Nano × 1(約 NT200-300)

  • HC-SR04 超聲波模組 × 1(約 NT50-80)

  • 紅外線障礙偵測模組 × 1(約 NT30-50)

  • 麵包板、杜邦線






接線表
























































元件 引腳 Arduino 引腳 說明
HC-SR04 VCC 5V 電源
Trig D9 觸發脈衝
Echo D10 接收回傳
GND GND 接地
IR Sensor VCC 5V 電源
OUT D2 偵測訊號(Low = 偵測到)
GND GND 接地








3. 程式碼實現






// 定義引腳
const int TRIG_PIN = 9;
const int ECHO_PIN = 10;
const int IR_PIN = 2;

const long MAX_DISTANCE = 300; // sentinel 值:代表「測不到/超範圍」,不是真實可測距離(pulseIn timeout 限制實測上限約 51cm)
const int DEBOUNCE_COUNT = 3; // 連續偵測次數

int stableCount = 0; // 紅外線穩定計數

void setup() {
Serial.begin(9600);
pinMode(TRIG_PIN, OUTPUT);
pinMode(ECHO_PIN, INPUT);
pinMode(IR_PIN, INPUT);
digitalWrite(TRIG_PIN, LOW);
Serial.println("System Initialized: 超聲波 + 紅外線融合");
Serial.println(">> 校準:打開 Serial Monitor,確認數值正常 <<");
}

long getUltrasonicDistance() {
digitalWrite(TRIG_PIN, LOW);
delayMicroseconds(2);
digitalWrite(TRIG_PIN, HIGH);
delayMicroseconds(10);
digitalWrite(TRIG_PIN, LOW);

// pulseIn timeout = 3000μs → 實測上限約 51cm(來回 102cm)。超過就回傳 MAX_DISTANCE(sentinel)
long duration = pulseIn(ECHO_PIN, HIGH, 3000);
if (duration == 0) return MAX_DISTANCE; // 無回傳視為超範圍 / 未知
return duration * 0.034 / 2;
}

void loop() {
long distance = getUltrasonicDistance();
int irDetected = digitalRead(IR_PIN);

Serial.print("距離: ");
Serial.print(distance);
Serial.print(" cm | IR: ");
Serial.println(irDetected == LOW ? "偵測到!" : "無");

// 整合邏輯:加括號避免優先順序錯誤
bool ultrasonicTrigger = (distance > 0 && distance < 20);
bool irTrigger = (irDetected == LOW);

// 防雜訊:紅外線連續 3 次偵測到才算數
if (irTrigger) {
stableCount++;
} else {
stableCount = 0;
}

if (ultrasonicTrigger || (stableCount >= DEBOUNCE_COUNT)) {
Serial.println(">>> 障礙物!停車! <<<");
// motorStop(); // 在這裡加入馬達停止指令
} else {
Serial.println("路徑暢通,前進中...");
// motorForward(); // 在這裡加入馬達前進指令
}

delay(200);
}









技術細節:為什麼要加 timeout?



pulseIn()預設可以等很久。如果超聲波沒收到回傳(例如面對吸音海綿),它會卡住直到收到為止——這段時間小車可能已經撞上了。



加入 timeout 參數(微秒)後,3ms(= 3000 微秒)內沒收到回傳就回傳 0,我們立刻知道「這次沒測到」,而不會卡死。聲音在空氣中每秒約走 340 公尺,也就是每秒 34,000 公分,所以每微秒約 0.034 公分。duration * 0.034 / 2 這個公式就是把微秒轉換成來回的距離(公分)。



MAX_DISTANCE 只是 sentinel 值,表示「測不到」,不代表真的 300cm。當超聲波完全收不到回傳時,pulseIn 回傳 0,我們回傳 MAX_DISTANCE,邏輯會走到 distance > 0 && distance < 20 這個超聲波觸發條件,結果是 false——這時候紅外線的 stableCount 就會在它感測到障礙時觸發。兩個感測器互相當作 backup。









4. 動手驗證(阿哲測試清單)





  1. 超聲波測試:拿一本書慢慢靠近,Serial Monitor 顯示的數值是否符合實際距離?


  2. 紅外線測試:用手靠近/遠離模組,觀察訊號燈和 Serial Monitor 輸出。


  3. 軟質材料測試:拿一塊白色或淺色保麗龍測試——超聲波可能失效(散射),但紅外線仍能偵測到(淺色表面反射紅外光良好),這正是兩種感測器互補的好例子。黑色海綿則是兩者的共同盲區——聲波散射 + 紅外光吸收,同時失效。


  4. 整合測試:同時觸發兩個感測器,確認「雙重驗證」邏輯正確。









5. 讓阿哲問的問答



Q:為什麼保麗龍讓超聲波測不准?

A:超聲波靠「聲波反射」回傳資訊。保麗龍、海綿等軟質/多孔材料會把聲波散射吃掉,幾乎沒有反射。紅外線靠「光反射」,如果表面是淺色,同樣能反射回讀——兩者互補。



Q:可以把這個邏輯用在循線小車上嗎?

A:可以。把紅外線模組朝下安裝,當車輪接近桌面邊緣時,紅外線訊號會從「無反射」變成「有反射」(桌面 vs. 懸空),就能及時停住。



Q:pulseIn 的 timeout 要設多少?

A:這題是物理+設定的混合問題。pulseIn() 的 timeout 參數單位是微秒(μs)。聲音在空氣中每秒約走 340 公尺(每秒 34,000 公分),所以每微秒約走 0.034 公分。來回 100cm(大約手臂伸直的距離)約需 2.9ms(= 2900 微秒)。pulseIn() 設 3000(微秒)表示:等 3ms 還沒有回傳就放棄。實務上 3ms timeout 讓 HC-SR04 最遠約測到 51cm(單程)——超過這個距離的障礙,會被視為「無障礙」。這是超聲波感測器的物理上限,不是程式的錯。









結論



超聲波的「遠距掃描」與紅外線的「近距補完」,剛好從兩個方向覆蓋了單一感測器的盲區。



這個整合做起來不貴(全部材料約 NT300 以內),邏輯也清晰——而且讓你真正理解「感測器融合」在實務上長什麼樣子。




動手門檻:國中生程度可以接線,但程式邏輯建議有高一以上基礎。或請旭豐帶你走一遍。


Information ergänzen Fachhinweis, Update, Korrektur oder Quelle zur Meldung beitragen
Gäste-Hinweise werden kurz redaktionell geprüft und danach hier angezeigt.

Community-Hinweise zur Meldung

0 freigegeben
Social ReaktionenReagiere als Erste:r — dein Feedback zählt!
Informations-Bewertung:

💬 Community-Diskussion & Kommentare

🌐 Zum Hauptchat

Starte die Diskussion im Social-Chat Broadcast Stream oder reiche oben über „Information ergänzen“ einen Fachbeitrag ein.

Community Rating &amp; Social Proof
⭐ Leser-Wertung
–
Ø / 5.0
Noch keine Leser-Bewertungen
War dieser Artikel hilfreich?
0
Jetzt Bewertung abgeben
Detail-Bewertung (optional)
Inhalt & Qualität
Quelle & Glaubwürdigkeit
Aktualität
Security Briefing Kostenlos · 1-Klick-Abmeldung

Intelligence Digest — kostenlos

Täglich die wichtigsten Security-News · jederzeit abbestellbar

Verwandte Story-Cluster & Quellen (Vektor-KI)

6 Cluster
41 Quellen
Best Black Friday MacBook Air deals: biggest discounts on Apple's thin and light laptop range
Latest from TechRadar vor 41 Min.
40 weitere Quellen
Latest from TechRadarvor 31 Min.Proton VPN vs ExpressVPN – which secure VPN should you pick this Black Friday? WIREDvor 9 Std.The 108 Best Black Friday Deals Are Now Live: Our Expert Picks for 2026 WIREDvor 38 Min.20 Best Black Friday Tech Deals (2026) WIREDvor 36 Min.The 10 Best Black Friday TV Deals (2026): Save Up to 53% Off Giga.devor 27 Min.Black Friday 2026 bei Back Market: Dyson, Ninja und GoPro jetzt deutlich günstiger Cyber Security Newsvor 1 Std.Black Friday or Black Fraud Day? 7 Cyber Traps to Watch Out for Before You Click ‘Buy’ CNETvor 2 TagenLive: Black Friday Is Here. Shop Our Favorite Deals and Save Up to 60% Apple, Anker, Bose and More WIREDvor 51 Min.22 Best Black Friday Deals Under $100 (2026) WIREDvor 49 Min.Best Black Friday Phone Deals (2026): iPhone, Pixel, and More The Vergevor 56 Min.The absolute best Black Friday deals we’ve found (so far) Giga.devor 48 Min.AirPods Pro 3 im Black-Friday-Sturzflug: So günstig waren Apples Top-In-Ears noch nie PC-WELTvor 46 Min.Black Friday bei Amazon Haul: 20 Prozent Rabatt auf Powerbanks, Batterieprüfer, Speichersticks und mehr PC-WELTvor 46 Min.Black Friday bei Amazon Haul: 20 Prozent Rabatt auf Powerbanks, Batterieprüfer, Speichersticks und mehr t3n.devor 1 Std.Kindle, Echo Dot, Fire TV: Diese neuen Amazon-Geräte sind zum Black Friday stark reduziert Macerkopf.devor 1 Std.Amazon Black Friday Woche: iPad Air, iPhone 18 Cases, AirTag 2, Fire TV Sticks, Echo Dot und mehr appgefahren.devor 1 Std.JMGO mit Black Friday-Deals: Heimkino-Bundles bis zu 60 Prozent günstiger PC-WELTvor 1 Std.Google Pixel 11 jetzt unglaubliche 430 Euro günstiger im Black-Friday-Deal: Tiefstpreis bei Amazon PC-WELTvor 1 Std.Norton 360 Premium-Security an Black Friday nur 19,99 Euro statt 100 Euro Latest from TechRadarvor 1 Std.The best Black Friday headphone deals: Sony, AirPods and more Latest from TechRadarvor 1 Std.Best Black Friday mini PC deals 2026 live: Save on desktops from Apple, Geekom, GMKtec, Minisforum, and more Golem.devor 1 Std.Anzeige: Amazon startet mit Glücksrad-Gewinnspiel in den Black Friday Latest from TechRadarvor 1 Std.These smart and polished backpacks have accompanied me to events all over the world — and they're now 30% for Black Friday PC-WELTvor 1 Std.Riesiger 75 Zoll 4K-QLED-Fernseher fällt bei Amazon auf nur 469 Eur im Black-Friday-Angebot PC-WELTvor 1 Std.Black Friday: Beliebte Mähroboter von Mammotion jetzt ab 599 Euro Latest from TechRadarvor 1 Std.Save up to around £200 on these top mini PCs for Black Friday — with multiple options and configurations available for your exact needs or preferences Caschys Blogvor 3 Std.FlexiSpot Black Friday 2026: Bis zu 40 % Rabatt auf Bestseller bei Amazon Golem.devor 1 Std.Black Friday: Verdi mobilisiert bei Amazon in Gera nur wenige PC-WELTvor 1 Std.Notebooksbilliger Black Friday: 150 Euro Extra-Rabatt – Laptops unter 300 Euro appgefahren.devor 1 Std.tink.de bietet bis zu 50 Euro Extra-Rabatt auf Black-Friday-Angebote PC-WELTvor 1 Std.Notebooksbilliger Black Friday: 150 Euro Extra-Rabatt – Laptops unter 300 Euro Latest from TechRadarvor 2 Std.Which all-in-one Black Friday VPN bundle is really worth it? I compared NordVPN Prime, ExpressVPN Pro, and Proton Unlimited — all under $7 a month — to decide PC-WELTvor 2 Std.Amazon verlost an Black Friday Einkaufsgutscheine im Wert von 2.000 Euro PC-WELTvor 2 Std.Amazon verlost an Black Friday Einkaufsgutscheine im Wert von 2.000 Euro t3n.devor 2 Std.Zum Black Friday bei Ecoflow den Heimspeicher fürs Frühjahr sichern PC-WELTvor 2 Std.Black Friday ist da! Die besten Technik-Deals bei Amazon am 27.11. GamingOnLinux Latest Articl…vor 2 Std.Valve update the Discounts & Events page for Black Friday sales Latest from TechRadarvor 2 Std.I'm an Audio Editor and these are the only cheap hi-fi and headphone deals I want you to see this Black Friday t3n.devor 2 Std.Fritzbox am Black Friday: 9 gute Angebote rund um Router und Repeater PC-WELTvor 2 Std.Black Friday bei Amazon Haul: Bis zu 20 Prozent Rabatt auf Powerbanks, Bosch-Produkte und mehr PC-WELTvor 2 Std.Black Friday bei Amazon Haul: Bis zu 20 Prozent Rabatt auf Powerbanks, Bosch-Produkte und mehr
17 Quellen
Google will soon share Android developers' addresses publicly
Engadget - Technology News & Expert Reviews vor 53 Min.
16 weitere Quellen
VulDB Updatesvor 1 Std.CVE-2026-95429 | Google Android BrEdrDynamicChannel bredr_dynamic_channel.cc resource consumption VulDB Updatesvor 1 Std.CVE-2026-95434 | Google Android LowEnergyScanner low_energy_scanner.cc NotifyPeerFound resource consumption VulDB Updatesvor 1 Std.CVE-2026-95441 | Google Android Bluetooth connection.cc OnDisconnectionComplete denial of service VulDB Updatesvor 1 Std.CVE-2026-95422 | Google Android periodic_advertising_synchronizer.cc OnSyncEstablished assertion VulDB Updatesvor 1 Std.CVE-2026-95423 | Google Android local_service_manager.cc OnWriteCCC null pointer dereference VulDB Updatesvor 1 Std.CVE-2026-95447 | Google Android SDP Client client.cc OnRxFrame memory corruption VulDB Updatesvor 1 Std.CVE-2026-95421 | Google Android Command Processing bredr_signaling_channel.cc DecodeRxUnit use after free VulDB Updatesvor 1 Std.CVE-2026-95435 | Google Android advertising_data.cc FromBytes out-of-bounds VulDB Updatesvor 1 Std.CVE-2026-95446 | Google Android credit_based_flow_control_rx_engine.cc ProcessPdu input validation VulDB Updatesvor 1 Std.CVE-2026-95420 | Google Android Pairing security_manager.cc OnEncryptionChange privileges management VulDB Updatesvor 1 Std.CVE-2026-95419 | Google Android Bluetooth Security Manager security_manager.cc OnPairingRequest unusual condition VulDB Updatesvor 1 Std.CVE-2026-95416 | Google Android Link Encryption Key security_manager.cc OnPairingFailed denial of service VulDB Updatesvor 1 Std.CVE-2026-95415 | Google Android RemoteCharacteristic remote_characteristic.cc denial of service VulDB Updatesvor 1 Std.CVE-2026-95417 | Google Android remote_characteristic.cc ResolvePendingNotifyRequests use after free VulDB Updatesvor 1 Std.CVE-2026-95414 | Google Android http_file_request_handler.cc GetFilePath path traversal VulDB Updatesvor 1 Std.CVE-2026-95418 | Google Android logical_link.cc LogicalLink::SignalError use after free
Ähnliche Beiträge
🔍 Verwandte News

Auch interessante Nachrichten 用超聲波加紅外線達成全向障礙偵測:Arduino 雙感測器整合

Thematisch verwandte Begriffe: 用超聲波加紅外線達成全向障礙偵測Arduino, 雙感測器整合 · 6 Treffer

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

💬 Kommentare werden geladen…
Zum Aktualisieren ziehen
Widgets & Themen
Widgets werden geladen…
Nächster Beitrag