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

สวิตช์อุปกรณ์ไฟบ้านด้วยรีเลย์

เปิดปิดโคมไฟหรือพัดลมจากขาดิจิทัล

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

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

Controlling Big Things

Sometimes you want your Arduino to switch a lamp or a fan, not just an LED. For mains-powered gear you reach for a relay. 💡

A Relay Is a Switch

A relay is an electrically controlled switch. A small coil current pulls a metal contact closed, connecting a totally separate, much higher-power circuit.

Electrical Isolation

The coil and the contacts never touch electrically. This isolation is why a 5V Arduino can safely command a 220V device without sharing wires.

Use a Relay Module

Grab a ready-made relay module. It already has the driving transistor, a flyback diode, and screw terminals, so you just supply a control signal.

The Three Control Wires

A typical module has three pins: VCC, GND, and a signal input. Connect signal to any Arduino digital pin to control the relay.

Driving It in Code

Treat the relay like an LED. Set the pin HIGH or LOW to close or open the contact, depending on how your module is wired.

int relay = 7;
pinMode(relay, OUTPUT);
digitalWrite(relay, HIGH); // switch on

Active-Low Surprise

Many modules are active-low: LOW turns the load on and HIGH turns it off. Test yours so the logic in your sketch matches reality.

NO and NC Terminals

The output side offers NO and NC contacts. Normally Open stays off until triggered; Normally Closed is on until the relay switches.

Wire the Load Through COM

Run one mains wire to the COM terminal and the other to NO. When the relay clicks, the circuit closes and your device powers up.

Respect Mains Safety

Mains voltage can kill. Never touch live terminals, keep the high-voltage side enclosed, and have an adult or pro check anything wired to the wall. ⚠️

Hear the Click

When the relay switches you hear a satisfying click as the coil snaps the contact. That sound confirms your code reached the real world.

Quick Check

What is the main reason a relay is used to switch mains-powered devices from an Arduino?

Recap

A relay is an isolated switch: a small signal closes contacts that power big loads. Use a module, mind active-low logic, and respect mains safety. 🚀

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

บทเรียน “สวิตช์อุปกรณ์ไฟบ้านด้วยรีเลย์” ฟรีหรือไม่

ใช่ — ข้อความเต็มของ “สวิตช์อุปกรณ์ไฟบ้านด้วยรีเลย์” ฟรีให้อ่านที่นี่บนเว็บ เพื่อปฏิบัติแบบโต้ตอบ (ตัวแก้ไขโค้ดในตัวและติวเตอร์ 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 ออกแบบมาสำหรับผู้เริ่มต้นไปจนถึงผู้เรียนขั้นสูง คุณสามารถเริ่มต้นที่นี่หรือเริ่มจากตัวแรกและเรียนด้วยความเร็วของคุณเอง นี่คือบทเรียนที่ 3 จากทั้งหมด 4 บทเรียน

บทเรียน “สวิตช์อุปกรณ์ไฟบ้านด้วยรีเลย์” ใช้เวลานานแค่ไหน

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

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

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

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

  1. ทำไมจึงต้องใช้ตัวขับ
  2. ความเร็วและทิศทางด้วยสะพานรูปตัว H
  3. สวิตช์อุปกรณ์ไฟบ้านด้วยรีเลย์
  4. ป้องกันแรงดันกระชากจากการเหนี่ยวนำกลับ
← กลับไปที่ Arduino & IoT Academy