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:

💬 Topluluk tartışması ve yorumlar

🌐 Ana sohbete katıl

Tartışmayı başlat: Social Chat yayın akışı veya yukarıdaki ekleme formuyla uzman katkısı gönder.

Community Rating &amp; Social Proof
⭐ Okuyucu Puanı
–
Ø / 5.0
Hiçbir okuyucu henüz yorum yok
Bu makale yararlı mıydı?
0
Değerlendirmenizi gönderin
Detaylı değerlendirme (isteğe bağlı)
İçerik ve Kalite
Kaynak ve Güvenilirlik
Güncellik
Security Briefing Ücretsiz · Tek tıkla abonelikten çıkma

Zeka Digest - ücretsiz

Günlük en önemli güvenlik haberi · herhangi bir zamanda alınabilir

İlgili Story Cluster & Kaynaklar (vector AI)

6 Cluster
41 Kaynaklar
Best Black Friday MacBook Air deals: biggest discounts on Apple's thin and light laptop range
Latest from TechRadar 41 dakika önce
40 diğer kaynaklar
Latest from TechRadar31 dakika önceProton VPN vs ExpressVPN – which secure VPN should you pick this Black Friday? WIRED9 saat önceThe 108 Best Black Friday Deals Are Now Live: Our Expert Picks for 2026 WIRED38 dakika önce20 Best Black Friday Tech Deals (2026) WIRED36 dakika önceThe 10 Best Black Friday TV Deals (2026): Save Up to 53% Off Giga.de28 dakika önceBlack Friday 2026 bei Back Market: Dyson, Ninja und GoPro jetzt deutlich günstiger Cyber Security News1 saat önceBlack Friday or Black Fraud Day? 7 Cyber Traps to Watch Out for Before You Click ‘Buy’ CNET2 gün önceLive: Black Friday Is Here. Shop Our Favorite Deals and Save Up to 60% Apple, Anker, Bose and More WIRED51 dakika önce22 Best Black Friday Deals Under $100 (2026) WIRED49 dakika önceBest Black Friday Phone Deals (2026): iPhone, Pixel, and More The Verge56 dakika önceThe absolute best Black Friday deals we’ve found (so far) Giga.de48 dakika önceAirPods Pro 3 im Black-Friday-Sturzflug: So günstig waren Apples Top-In-Ears noch nie PC-WELT46 dakika önceBlack Friday bei Amazon Haul: 20 Prozent Rabatt auf Powerbanks, Batterieprüfer, Speichersticks und mehr PC-WELT46 dakika önceBlack Friday bei Amazon Haul: 20 Prozent Rabatt auf Powerbanks, Batterieprüfer, Speichersticks und mehr t3n.de1 saat önceKindle, Echo Dot, Fire TV: Diese neuen Amazon-Geräte sind zum Black Friday stark reduziert Macerkopf.de1 saat önceAmazon Black Friday Woche: iPad Air, iPhone 18 Cases, AirTag 2, Fire TV Sticks, Echo Dot und mehr appgefahren.de1 saat önceJMGO mit Black Friday-Deals: Heimkino-Bundles bis zu 60 Prozent günstiger PC-WELT1 saat önceGoogle Pixel 11 jetzt unglaubliche 430 Euro günstiger im Black-Friday-Deal: Tiefstpreis bei Amazon PC-WELT1 saat önceNorton 360 Premium-Security an Black Friday nur 19,99 Euro statt 100 Euro Latest from TechRadar1 saat önceThe best Black Friday headphone deals: Sony, AirPods and more Latest from TechRadar1 saat önceBest Black Friday mini PC deals 2026 live: Save on desktops from Apple, Geekom, GMKtec, Minisforum, and more Golem.de1 saat önceAnzeige: Amazon startet mit Glücksrad-Gewinnspiel in den Black Friday Latest from TechRadar1 saat önceThese smart and polished backpacks have accompanied me to events all over the world — and they're now 30% for Black Friday PC-WELT1 saat önceRiesiger 75 Zoll 4K-QLED-Fernseher fällt bei Amazon auf nur 469 Eur im Black-Friday-Angebot PC-WELT1 saat önceBlack Friday: Beliebte Mähroboter von Mammotion jetzt ab 599 Euro Latest from TechRadar1 saat önceSave 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 Blog3 saat önceFlexiSpot Black Friday 2026: Bis zu 40 % Rabatt auf Bestseller bei Amazon Golem.de1 saat önceBlack Friday: Verdi mobilisiert bei Amazon in Gera nur wenige PC-WELT1 saat önceNotebooksbilliger Black Friday: 150 Euro Extra-Rabatt – Laptops unter 300 Euro appgefahren.de1 saat öncetink.de bietet bis zu 50 Euro Extra-Rabatt auf Black-Friday-Angebote PC-WELT1 saat önceNotebooksbilliger Black Friday: 150 Euro Extra-Rabatt – Laptops unter 300 Euro Latest from TechRadar2 saat önceWhich 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-WELT2 saat önceAmazon verlost an Black Friday Einkaufsgutscheine im Wert von 2.000 Euro PC-WELT2 saat önceAmazon verlost an Black Friday Einkaufsgutscheine im Wert von 2.000 Euro t3n.de2 saat önceZum Black Friday bei Ecoflow den Heimspeicher fürs Frühjahr sichern PC-WELT2 saat önceBlack Friday ist da! Die besten Technik-Deals bei Amazon am 27.11. GamingOnLinux Latest Articl…2 saat önceValve update the Discounts & Events page for Black Friday sales Latest from TechRadar2 saat önceI'm an Audio Editor and these are the only cheap hi-fi and headphone deals I want you to see this Black Friday t3n.de2 saat önceFritzbox am Black Friday: 9 gute Angebote rund um Router und Repeater PC-WELT2 saat önceBlack Friday bei Amazon Haul: Bis zu 20 Prozent Rabatt auf Powerbanks, Bosch-Produkte und mehr PC-WELT2 saat önceBlack Friday bei Amazon Haul: Bis zu 20 Prozent Rabatt auf Powerbanks, Bosch-Produkte und mehr
17 Kaynaklar
Google will soon share Android developers' addresses publicly
Engadget - Technology News & Expert Reviews 53 dakika önce
16 diğer kaynaklar
VulDB Updates1 saat önceCVE-2026-95429 | Google Android BrEdrDynamicChannel bredr_dynamic_channel.cc resource consumption VulDB Updates1 saat önceCVE-2026-95434 | Google Android LowEnergyScanner low_energy_scanner.cc NotifyPeerFound resource consumption VulDB Updates1 saat önceCVE-2026-95441 | Google Android Bluetooth connection.cc OnDisconnectionComplete denial of service VulDB Updates1 saat önceCVE-2026-95422 | Google Android periodic_advertising_synchronizer.cc OnSyncEstablished assertion VulDB Updates1 saat önceCVE-2026-95423 | Google Android local_service_manager.cc OnWriteCCC null pointer dereference VulDB Updates1 saat önceCVE-2026-95447 | Google Android SDP Client client.cc OnRxFrame memory corruption VulDB Updates1 saat önceCVE-2026-95421 | Google Android Command Processing bredr_signaling_channel.cc DecodeRxUnit use after free VulDB Updates1 saat önceCVE-2026-95435 | Google Android advertising_data.cc FromBytes out-of-bounds VulDB Updates1 saat önceCVE-2026-95446 | Google Android credit_based_flow_control_rx_engine.cc ProcessPdu input validation VulDB Updates1 saat önceCVE-2026-95420 | Google Android Pairing security_manager.cc OnEncryptionChange privileges management VulDB Updates1 saat önceCVE-2026-95419 | Google Android Bluetooth Security Manager security_manager.cc OnPairingRequest unusual condition VulDB Updates1 saat önceCVE-2026-95416 | Google Android Link Encryption Key security_manager.cc OnPairingFailed denial of service VulDB Updates1 saat önceCVE-2026-95415 | Google Android RemoteCharacteristic remote_characteristic.cc denial of service VulDB Updates1 saat önceCVE-2026-95417 | Google Android remote_characteristic.cc ResolvePendingNotifyRequests use after free VulDB Updates1 saat önceCVE-2026-95414 | Google Android http_file_request_handler.cc GetFilePath path traversal VulDB Updates1 saat önceCVE-2026-95418 | Google Android logical_link.cc LogicalLink::SignalError use after free
Benzer katkılar
🔍 Verwandte News

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

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

Laden...

Videolar yükleniyor...

Laden...

Contributions yüklenir ...

Laden...

Videolar yükleniyor...

Laden...

Contributions yüklenir ...

Laden...

Videolar yükleniyor...

Yorumlar yüklenir..
Update to Update
Widgets & Topics
Loading widgets…
Nächster Beitrag