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

วัดแสงด้วย LDR

ต่อวงจรแบ่งแรงดันเพื่ออ่านความสว่าง

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

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

What an LDR Is

An LDR is a light-dependent resistor. Its resistance drops in bright light and climbs high in the dark.

Resistance Tracks Light

Cover an LDR and its resistance soars; shine a lamp on it and resistance falls. That change is what you measure.

It Cannot Be Read Alone

The Arduino reads voltage, not resistance. So an LDR by itself gives no voltage the board can sense directly.

Pair It With a Resistor

Combine the LDR with a fixed resistor to form a voltage divider. Together they turn light into a readable voltage.

Pick a 10k Partner

A 10k ohm resistor is a solid default partner for most LDRs. It keeps your readings spread across a useful range.

Tap the Middle Point

Connect the junction between the LDR and the resistor to an analog pin like A0. That midpoint voltage is your signal.

Read the Brightness

Call analogRead on the divider pin to get a 0 to 1023 number that rises and falls with the light.

int light = analogRead(A0);

Wiring Sets Direction

Which side the LDR sits on decides whether bright gives a high or low number. Test it and note your result.

Watch It Live

Print the value so you can wave your hand over the sensor and see the number react with Serial.println.

Serial.println(analogRead(A0));

Smooth Out Flicker

Lights flicker faster than your eye sees. Averaging a few readings gives a steadier brightness value.

A Cheap, Useful Sensor

The LDR is a cheap way to add light awareness. It powers night lights, plant monitors, and auto-dimming displays.

Quick Check

Why cant an LDR connect to an analog pin on its own?

Recap: Reading Light

You built an LDR voltage divider with a 10k resistor, tapped the midpoint to A0, and read brightness with analogRead.

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

บทเรียน “วัดแสงด้วย LDR” ฟรีหรือไม่

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

คุณจะเรียนรู้อะไรในบทเรียน “วัดแสงด้วย LDR”

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

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

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

บทเรียน “วัดแสงด้วย LDR” ใช้เวลานานแค่ไหน

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

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

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

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

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