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

อ่านเซนเซอร์ตรวจจับการเคลื่อนไหว PIR

ตรวจจับการเคลื่อนไหวและปรับความไวกับระยะหน่วง

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

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

What a PIR Detects

A PIR sensor watches for changes in infrared heat. When a warm body like a person moves across its view, it fires.

Why It Sees Movement

PIR stands for passive infrared. It only reacts to a change in heat, so a still object soon fades from notice while motion stands out.

It Has Three Pins

A typical PIR module has three pins: VCC for power, GND for ground, and OUT for the digital signal you read.

Power It Up

Most PIR modules run on 5V. Connect VCC to 5V and GND to ground, just like any other digital sensor.

OUT Is Digital

The OUT pin gives a clean digital signal. It goes HIGH when motion is detected and LOW when the area is calm.

Set the Pin as Input

Tell the board that the OUT pin is an input so it can listen. Do this once inside setup().

pinMode(2, INPUT);

Read the Motion State

Read the sensor with digitalRead. A returned HIGH means it just sensed movement nearby.

int motion = digitalRead(2);

Act on Detection

Wrap the reading in an if check so your code does something, like light an LED, only when motion is HIGH.

if (motion == HIGH) {
  // movement detected
}

Tune the Delay Trim

The on-board delay trimpot sets how long OUT stays HIGH after motion. Turn it to hold the signal longer or shorter.

Tune the Sensitivity Trim

The second trimpot adjusts sensitivity, the range at which motion triggers. Lower it to ignore far-off movement.

Let It Warm Up

Give a PIR up to a minute to calibrate after power-on. Early readings can be jittery until it settles.

Quick Check

What does a PIR sensor actually respond to?

Recap: Sensing Motion

You wired a PIR with VCC, GND, and OUT, read it with digitalRead, and tuned the delay and sensitivity trimpots.

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

บทเรียน “อ่านเซนเซอร์ตรวจจับการเคลื่อนไหว PIR” ฟรีหรือไม่

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

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

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

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

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

บทเรียน “อ่านเซนเซอร์ตรวจจับการเคลื่อนไหว PIR” ใช้เวลานานแค่ไหน

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

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

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

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

  1. อ่านเซนเซอร์ตรวจจับการเคลื่อนไหว PIR
  2. วัดแสงด้วย LDR
  3. ตั้งค่าเกณฑ์แสง
  4. ไฟกลางคืนอัตโนมัติ
← กลับไปที่ Arduino & IoT Academy