วันอาทิตย์ที่ 28 กุมภาพันธ์ พ.ศ. 2559

ESP LCD Hello World

โปรเจคนี้เราจะมาทำการต่อบอร์ด NodeMcu กับจอ LCD I2C เพื่อแสดงผลแบบง่ายๆ ผ่านโปรแกรม Arduino IDE กัน

1.ให้ทำการต่อบอร์ด NodeMcu เข้ากับจอ LCD I2C ตามนี้

NodeMcu     LCD I2c
Vin-------------VCC
GND-----------GND
D1--------------SCL
D2--------------SDA





2.เปิดโปรแกรม Arduino IDE และเลือกบอร์ดพร้อมทั้งลงไลบลารี่ LiquidCrystal_I2C ให้เรียบร้อยหากยังไม่มี
3.ก๊อปโค๊ดด้านล่างไปและอัพโหลดเข้าบอร์ด NodeMCU

#include <Wire.h>
#include <LiquidCrystal_I2C.h>
// Set the LCD address to 0x27 for a 16 chars and 2 line display
// Arduino UNO => PIN 4 = SCL, PIN 5 = SDA
// NodeMCU Dev Kit => D1 = SCL, D2 = SDA
LiquidCrystal_I2C lcd(0x27, 20, 4);
void setup()
{
// initialize the LCD
lcd.begin();
// Turn on the blacklight and print a message.
lcd.backlight();
lcd.print("Hello LCD Line 1");
lcd.setCursor(0, 1);
lcd.print("Hello LCD Line 2");
}
void loop()
{
// Do nothing here...
}
4.หากไม่มีอะไรผิดพลาดจะได้ผลตามนี้ หากไม่ออกลองทบทวนขั้นตอนที่ผ่านมาให้ดีๆ



1 ความคิดเห็น: