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

I2C สื่อสารผ่านสายสองเส้นอย่างไร

อธิบาย SDA, SCL และที่อยู่ของอุปกรณ์

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

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

Two Wires, Many Devices

I2C lets many chips share just two wires, so you can add sensors and screens without running out of pins. 🔌

Meet SDA and SCL

I2C uses two lines: SDA carries the data, and SCL carries the clock pulses that keep both sides perfectly in step.

The Clock Keeps Time

The SCL clock line ticks like a metronome. Every tick tells devices exactly when to read the next bit on the data line.

Master and Slaves

Your Arduino is the master: it starts every conversation. Sensors and displays are slaves that only answer when called.

Every Device Has an Address

Each chip on the bus owns a unique address, usually a 7-bit number. The master uses it to talk to exactly one device. 📬

How a Message Begins

The master sends a start signal, then the target address. The matching device replies, and the rest stay quiet on the shared lines.

Pull-Up Resistors Are Required

I2C lines need pull-up resistors to 3.3V or 5V. Without them the bus floats and your devices simply will not respond.

Boards on the Uno

On an Arduino Uno, SDA is pin A4 and SCL is pin A5. Many breakout boards include their own pull-ups already.

The Wire Library

Arduino talks I2C through the built-in Wire library. One include line gives you everything you need to start communicating.

#include <Wire.h>

Begin the Bus

Call Wire.begin() in setup to join the bus as master. After that you can send to any device by its address.

void setup() {
  Wire.begin();
}

Why I2C Wins

Because devices share two lines, I2C keeps wiring simple and your pins free. That is why so many modules use it.

Quick Check

Which two lines does I2C use to communicate?

Recap

You learned that I2C shares two wires, SDA and SCL, with a master, addressed slaves, and pull-ups. Two wires, many devices. ✅

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

บทเรียน “I2C สื่อสารผ่านสายสองเส้นอย่างไร” ฟรีหรือไม่

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

คุณจะเรียนรู้อะไรในบทเรียน “I2C สื่อสารผ่านสายสองเส้นอย่างไร”

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

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

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

บทเรียน “I2C สื่อสารผ่านสายสองเส้นอย่างไร” ใช้เวลานานแค่ไหน

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

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

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

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

  1. I2C สื่อสารผ่านสายสองเส้นอย่างไร
  2. สแกนหาที่อยู่ I2C
  3. SPI ส่งข้อมูลได้รวดเร็วอย่างไร
  4. ใช้อุปกรณ์หลายตัวบนบัสเดียว
← กลับไปที่ Arduino & IoT Academy