ไลบรารี LiquidCrystal_I2C
เริ่มต้นจอแสดงผลและตั้งค่าที่อยู่
ไลบรารี LiquidCrystal_I2C เป็นบทเรียน Arduino & IoT Academy ฟรีบน CoddyKit นี่คือบทเรียนที่ 2 จากทั้งหมด 4 บทเรียน คุณสามารถอ่านบทเรียนทั้งหมดด้านล่างฟรี — จากนั้นลองปฏิบัติด้วยตัวคุณเองในเบราว์เซอร์พร้อมตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7 บทเรียนนี้เป็นส่วนหนึ่งของเส้นทางการเรียน Arduino & IoT Academy และความก้าวหน้าของคุณจะซิงค์ข้ามเว็บและแอป CoddyKit คอร์ส Arduino & IoT Academy มีบทเรียนทั้งหมด 4 บทเรียน
บางส่วนของบทเรียนนี้ยังไม่ได้รับการแปล และแสดงเป็นภาษาอังกฤษ
What the Library Does
The LiquidCrystal_I2C library handles all the low-level I2C chatter for you. You just call simple commands to show text. 📚
Install It Once
Open the Library Manager in the Arduino IDE and search for LiquidCrystal_I2C. Click install and it is ready to use.
Include the Header
At the top of your sketch you add an include line so the compiler can find the library's code.
#include <LiquidCrystal_I2C.h>Create the Object
You make one lcd object that represents your display. Every command you give will go through this object.
LiquidCrystal_I2C lcd(0x27, 16, 2);The Address Argument
The first number is the I2C address. If your display stays blank, swap 0x27 for 0x3F, the other common value.
Columns and Rows
The next two numbers tell the library the size: 16 columns and 2 rows. This matches a standard 16x2 panel.
Initialize in setup
Inside setup you call lcd.init() once to wake the display and prepare it to receive text.
void setup() {
lcd.init();
}Turn On the Backlight
The screen starts dark until you call lcd.backlight(). This lights it up so the characters are readable.
lcd.backlight();Print Your First Word
Now lcd.print() sends text to the screen. Whatever you pass appears starting at the top-left corner. 🎉
lcd.print("Hello!");Clearing the Screen
Call lcd.clear() to wipe everything and move the cursor back to the start before writing fresh text.
lcd.clear();If It Stays Blank
Blank screen with backlight on usually means the wrong address. Run an I2C scanner sketch to find the real one.
Quick Check
Your sketch compiles but the LCD stays dark even with power. Which call did you likely forget?
Recap
You included LiquidCrystal_I2C, created an lcd object with its address and size, then called init and backlight. Your display is alive. ✅
คำถามที่พบบ่อย
บทเรียน “ไลบรารี LiquidCrystal_I2C” ฟรีหรือไม่
ใช่ — ข้อความเต็มของ “ไลบรารี LiquidCrystal_I2C” ฟรีให้อ่านที่นี่บนเว็บ เพื่อปฏิบัติแบบโต้ตอบ (ตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7) และปลดล็อคส่วนที่เหลือของคอร์ส Arduino & IoT Academy ให้อัปเกรดเป็น CoddyKit PRO คอร์ส Arduino & IoT Academy มีบทเรียนทั้งหมด 4 บทเรียน
คุณจะเรียนรู้อะไรในบทเรียน “ไลบรารี LiquidCrystal_I2C”
เริ่มต้นจอแสดงผลและตั้งค่าที่อยู่ คุณปฏิบัติ Arduino & IoT Academy ด้วยโค้ดที่ใช้งานได้จริงที่คุณเรียกใช้โดยตรงในเบราว์เซอร์ และติวเตอร์ AI ตลอด 24/7 ตอบคำถามของคุณขณะที่คุณไปผ่านบทเรียน
คุณต้องมีประสบการณ์ก่อนที่จะเริ่มเรียน Arduino & IoT Academy หรือไม่
ไม่จำเป็นต้องมีประสบการณ์มาก่อน Arduino & IoT Academy บน CoddyKit ออกแบบมาสำหรับผู้เริ่มต้นไปจนถึงผู้เรียนขั้นสูง คุณสามารถเริ่มต้นที่นี่หรือเริ่มจากตัวแรกและเรียนด้วยความเร็วของคุณเอง นี่คือบทเรียนที่ 2 จากทั้งหมด 4 บทเรียน
บทเรียน “ไลบรารี LiquidCrystal_I2C” ใช้เวลานานแค่ไหน
บทเรียน CoddyKit ส่วนใหญ่ใช้เวลาประมาณ 5–10 นาที แต่ละบทเรียนจึงสั้นและเป็นแบบโต้ตอบ คุณสามารถก้าวหน้าอย่างต่อเนื่องและกลับมาเรียนต่อจากตรงที่เพิ่งหยุดบนเว็บและแอปได้เลย
ฉันเขียนและรันโค้ดในบทเรียน Arduino & IoT Academy นี้ได้ไหม
ได้ บทเรียน Arduino & IoT Academy ทุกบทมีตัวแก้ไขโค้ดในตัว คุณจึงเขียนและรันโค้ดจริงได้เลยในเบราว์เซอร์ และได้รับข้อเสนอแนะจาก AI ในทันที — ไม่ต้องติดตั้งในเครื่องของคุณ
บทเรียนทั้งหมดในหลักสูตรนี้
- ต่อสาย LCD ขนาด 16x2 (แผงต่อ I2C)
- ไลบรารี LiquidCrystal_I2C
- จัดตำแหน่งเคอร์เซอร์และพิมพ์ข้อความ
- แดชบอร์ดเซนเซอร์แบบสด