ใช้อุปกรณ์หลายตัวบนบัสเดียว
ใช้ I2C ร่วมกันระหว่าง LCD และเซนเซอร์
ใช้อุปกรณ์หลายตัวบนบัสเดียว เป็นบทเรียน Arduino & IoT Academy ฟรีบน CoddyKit นี่คือบทเรียนที่ 4 จากทั้งหมด 4 บทเรียน คุณสามารถอ่านบทเรียนทั้งหมดด้านล่างฟรี — จากนั้นลองปฏิบัติด้วยตัวคุณเองในเบราว์เซอร์พร้อมตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7 บทเรียนนี้เป็นส่วนหนึ่งของเส้นทางการเรียน Arduino & IoT Academy และความก้าวหน้าของคุณจะซิงค์ข้ามเว็บและแอป CoddyKit คอร์ส Arduino & IoT Academy มีบทเรียนทั้งหมด 4 บทเรียน
บางส่วนของบทเรียนนี้ยังไม่ได้รับการแปล และแสดงเป็นภาษาอังกฤษ
Share the Same Wires
The real power of I2C is sharing. An LCD and a sensor can sit on the same two wires at once. 🔗
Addresses Keep Order
Because every device has a unique address, the master talks to each one in turn without any of them getting confused.
Wire Them in Parallel
Connect every device's SDA to SDA and SCL to SCL. They all sit in parallel on the same shared bus lines.
One Set of Pull-Ups
The whole bus needs only one pair of pull-up resistors, not one per device. Many breakouts already include theirs.
Beware Address Clashes
Two devices sharing one address will conflict. Run your scanner first to spot duplicates before wiring everything together.
Change an Address
Many boards let you change the address with a solder jumper or pin. That frees you to run two identical sensors at once.
One Wire.begin for All
You call Wire.begin() just once. Every library on the bus shares that single connection no matter how many devices you add.
void setup() {
Wire.begin();
}Each Library Knows Its Address
You give each library the device's address when you create it, so calls route to the right chip automatically.
LiquidCrystal_I2C lcd(0x27, 16, 2);Talk to Each in the Loop
In loop, read the sensor, then update the LCD. The bus handles one conversation at a time, so order is fine.
float t = sensor.readTemp();
lcd.print(t);Keep Wires Short
Long shared wires add noise and can break the bus. Keep I2C runs short and tidy for reliable communication.
Scale Up Your Projects
With this skill you can grow a project by simply adding more I2C modules, all on the same two trusty wires. 🚀
Quick Check
What happens if two I2C devices share the same address?
Recap
You can now wire multiple I2C devices in parallel, avoid address clashes, and address each one to build bigger projects. ✅
คำถามที่พบบ่อย
บทเรียน “ใช้อุปกรณ์หลายตัวบนบัสเดียว” ฟรีหรือไม่
ใช่ — ข้อความเต็มของ “ใช้อุปกรณ์หลายตัวบนบัสเดียว” ฟรีให้อ่านที่นี่บนเว็บ เพื่อปฏิบัติแบบโต้ตอบ (ตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7) และปลดล็อคส่วนที่เหลือของคอร์ส Arduino & IoT Academy ให้อัปเกรดเป็น CoddyKit PRO คอร์ส Arduino & IoT Academy มีบทเรียนทั้งหมด 4 บทเรียน
คุณจะเรียนรู้อะไรในบทเรียน “ใช้อุปกรณ์หลายตัวบนบัสเดียว”
ใช้ I2C ร่วมกันระหว่าง LCD และเซนเซอร์ คุณปฏิบัติ Arduino & IoT Academy ด้วยโค้ดที่ใช้งานได้จริงที่คุณเรียกใช้โดยตรงในเบราว์เซอร์ และติวเตอร์ AI ตลอด 24/7 ตอบคำถามของคุณขณะที่คุณไปผ่านบทเรียน
คุณต้องมีประสบการณ์ก่อนที่จะเริ่มเรียน Arduino & IoT Academy หรือไม่
ไม่จำเป็นต้องมีประสบการณ์มาก่อน Arduino & IoT Academy บน CoddyKit ออกแบบมาสำหรับผู้เริ่มต้นไปจนถึงผู้เรียนขั้นสูง คุณสามารถเริ่มต้นที่นี่หรือเริ่มจากตัวแรกและเรียนด้วยความเร็วของคุณเอง นี่คือบทเรียนที่ 4 จากทั้งหมด 4 บทเรียน
บทเรียน “ใช้อุปกรณ์หลายตัวบนบัสเดียว” ใช้เวลานานแค่ไหน
บทเรียน CoddyKit ส่วนใหญ่ใช้เวลาประมาณ 5–10 นาที แต่ละบทเรียนจึงสั้นและเป็นแบบโต้ตอบ คุณสามารถก้าวหน้าอย่างต่อเนื่องและกลับมาเรียนต่อจากตรงที่เพิ่งหยุดบนเว็บและแอปได้เลย
ฉันเขียนและรันโค้ดในบทเรียน Arduino & IoT Academy นี้ได้ไหม
ได้ บทเรียน Arduino & IoT Academy ทุกบทมีตัวแก้ไขโค้ดในตัว คุณจึงเขียนและรันโค้ดจริงได้เลยในเบราว์เซอร์ และได้รับข้อเสนอแนะจาก AI ในทันที — ไม่ต้องติดตั้งในเครื่องของคุณ
บทเรียนทั้งหมดในหลักสูตรนี้
- I2C สื่อสารผ่านสายสองเส้นอย่างไร
- สแกนหาที่อยู่ I2C
- SPI ส่งข้อมูลได้รวดเร็วอย่างไร
- ใช้อุปกรณ์หลายตัวบนบัสเดียว