0Pricing
Arduino & IoT Academy · บทเรียน

การวัดระยะด้วยคลื่นอัลตราโซนิก

ส่งสัญญาณปิงและจับเวลาสะท้อนกลับเพื่อหาระยะทาง

การวัดระยะด้วยคลื่นอัลตราโซนิก เป็นบทเรียน Arduino & IoT Academy ฟรีบน CoddyKit นี่คือบทเรียนที่ 1 จากทั้งหมด 4 บทเรียน คุณสามารถอ่านบทเรียนทั้งหมดด้านล่างฟรี — จากนั้นลองปฏิบัติด้วยตัวคุณเองในเบราว์เซอร์พร้อมตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7 บทเรียนนี้เป็นส่วนหนึ่งของเส้นทางการเรียน Arduino & IoT Academy และความก้าวหน้าของคุณจะซิงค์ข้ามเว็บและแอป CoddyKit คอร์ส Arduino & IoT Academy มีบทเรียนทั้งหมด 4 บทเรียน

บางส่วนของบทเรียนนี้ยังไม่ได้รับการแปล และแสดงเป็นภาษาอังกฤษ

Seeing with Sound

An ultrasonic sensor measures distance the way a bat does: it sends out a sound pulse and listens for the echo bouncing back. 🦇

Too High to Hear

The pulse is ultrasonic, around 40 kHz, far above what your ears can detect. The sensor works silently while still using real sound waves.

Send, Then Listen

The trick is timing. The sensor fires a quick ping, then starts a stopwatch and waits for that same sound to return after hitting an object.

The Round Trip

The sound travels out to the object and all the way back, so the measured time covers a round trip, twice the actual distance to the target.

Sound Has a Speed

Sound moves through air at about 343 meters per second. Because that speed is known, time can be turned directly into distance.

Time to Distance

Distance equals speed times time. Knowing how long the echo took, you can compute exactly how far the sound traveled before bouncing.

// distance in cm, time in microseconds
distance = duration * 0.0343 / 2;

Why You Divide by Two

Since the echo covers the path twice, you halve the result. That single division converts a round trip into the real one-way distance.

Microseconds Matter

These pulses return in microseconds, so the sensor times very tiny intervals. Tinier time differences simply mean a closer object.

The HC-SR04

The popular HC-SR04 module does all this for you. It has one transmitter that chirps and one receiver that catches the returning echo.

Its Useful Range

This sensor reliably reads from about 2 cm to 400 cm. Closer than 2 cm or farther than that, and the readings stop being trustworthy.

Where Echoes Fail

Soft or angled surfaces can scatter the sound away, so a flat, solid target gives the cleanest, most accurate distance readings.

Quick Check

Think about the path the sound takes.

You Get It Now

Ultrasonic ranging is just timed echoes: ping, wait, and convert the round-trip time into distance. Next you will wire the sensor up. ✅

คำถามที่พบบ่อย

บทเรียน “การวัดระยะด้วยคลื่นอัลตราโซนิก” ฟรีหรือไม่

ใช่ — ข้อความเต็มของ “การวัดระยะด้วยคลื่นอัลตราโซนิก” ฟรีให้อ่านที่นี่บนเว็บ เพื่อปฏิบัติแบบโต้ตอบ (ตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7) และปลดล็อคส่วนที่เหลือของคอร์ส Arduino & IoT Academy ให้อัปเกรดเป็น CoddyKit PRO คอร์ส Arduino & IoT Academy มีบทเรียนทั้งหมด 4 บทเรียน

คุณจะเรียนรู้อะไรในบทเรียน “การวัดระยะด้วยคลื่นอัลตราโซนิก”

ส่งสัญญาณปิงและจับเวลาสะท้อนกลับเพื่อหาระยะทาง คุณปฏิบัติ Arduino & IoT Academy ด้วยโค้ดที่ใช้งานได้จริงที่คุณเรียกใช้โดยตรงในเบราว์เซอร์ และติวเตอร์ AI ตลอด 24/7 ตอบคำถามของคุณขณะที่คุณไปผ่านบทเรียน

คุณต้องมีประสบการณ์ก่อนที่จะเริ่มเรียน Arduino & IoT Academy หรือไม่

ไม่จำเป็นต้องมีประสบการณ์มาก่อน Arduino & IoT Academy บน CoddyKit ออกแบบมาสำหรับผู้เริ่มต้นไปจนถึงผู้เรียนขั้นสูง คุณสามารถเริ่มต้นที่นี่หรือเริ่มจากตัวแรกและเรียนด้วยความเร็วของคุณเอง นี่คือบทเรียนที่ 1 จากทั้งหมด 4 บทเรียน

บทเรียน “การวัดระยะด้วยคลื่นอัลตราโซนิก” ใช้เวลานานแค่ไหน

บทเรียน CoddyKit ส่วนใหญ่ใช้เวลาประมาณ 5–10 นาที แต่ละบทเรียนจึงสั้นและเป็นแบบโต้ตอบ คุณสามารถก้าวหน้าอย่างต่อเนื่องและกลับมาเรียนต่อจากตรงที่เพิ่งหยุดบนเว็บและแอปได้เลย

ฉันเขียนและรันโค้ดในบทเรียน Arduino & IoT Academy นี้ได้ไหม

ได้ บทเรียน Arduino & IoT Academy ทุกบทมีตัวแก้ไขโค้ดในตัว คุณจึงเขียนและรันโค้ดจริงได้เลยในเบราว์เซอร์ และได้รับข้อเสนอแนะจาก AI ในทันที — ไม่ต้องติดตั้งในเครื่องของคุณ

บทเรียนทั้งหมดในหลักสูตรนี้

  1. การวัดระยะด้วยคลื่นอัลตราโซนิก
  2. การต่อสาย Trigger และ Echo
  3. ใช้ pulseIn จับเวลาเสียงสะท้อน
  4. สร้างสัญญาณเตือนระยะใกล้
← กลับไปที่ Arduino & IoT Academy