Code mẫu
#include
#includeLiquidCrystal_I2C lcd(0x3F,16,2); void setup() { lcd.init(); lcd.backlight(); lcd.setCursor(2,0); lcd.print(“Arduinokit.vn”); lcd.setCursor(0,1); lcd.print(“Xin chao cac ban”); } void loop() { }
Giải thích code
LiquidCrystal_I2C lcd(0x3F,16,2);
- Đặt địa chỉ LCD là 0x3F cho màn hình LCD 16×2.
- 16 là số cột của màn hình (nếu dùng loại màn hình 20×4) thì thay bằng 20.
- 2 là số dòng của màn hình (nếu dùng loại màn hình 20×4) thì thay bằng 4.
lcd.init();
Khởi động màn hình LCD, bắt đầu cho phép Arduino sử dụng màn hình.
lcd.backlight();
Bật đèn nền LCD 16×2.
lcd.setCursor(2,0);
Đưa con trỏ tới hàng 1, cột 3.
Lưu ý: giá trị hàng và cột bắt đầu từ số 0 có nghĩa 0 là hàng(cột) 1.
lcd.print(“Arduinokit.vn”);
Xuất ra dòng chữ Arduinokit.vn tại vị trí con trỏ ở hàng 1, cột 3.
lcd.setCursor(0,1); lcd.print(“Xin chao cac ban”);
Đoạn code này thì tương tự như trên, xuất ra dòng chữ “Xin chao cac ban” tại vị trí con trỏ ở hàng 2, cột 1.
Bây giờ thì các bạn upload chương trình và xem kết quả nhé.
Module I2C Arduino
LCD có quá nhiều nhiều chân gây khó khăn trong quá trình đấu nối và chiếm dụng nhiều chân trên vi điều khiển.
Module I2C LCD ra đời và giải quyết vấn để này cho bạn.
Thay vì phải mất 6 chân vi điều khiển để kết nối với LCD 16×2 (RS, EN, D7, D6, D5 và D4) thì module IC2 bạn chỉ cần tốn 2 chân (SCL, SDA) để kết nối.
Module I2C hỗ trợ các loại LCD sử dụng driver HD44780(LCD 16×2, LCD 20×4, …) và tương thích với hầu hết các vi điều khiển hiện nay.
Ưu điểm
- Tiết kiệm chân cho vi điều khiển.
- Dễ dàng kết nối với LCD.
Thông số kĩ thuật
- Điện áp hoạt động: 2.5-6V DC.
- Hỗ trợ màn hình: LCD1602,1604,2004 (driver HD44780).
- Giao tiếp: I2C.
- Địa chỉ mặc định: 0X27 (có thể điều chỉnh bằng ngắn mạch chân A0/A1/A2).
- Tích hợp Jump chốt để cung cấp đèn cho LCD hoặc ngắt.
- Tích hợp biến trở xoay điều chỉnh độ tương phản cho LCD.
Để sử dụng màn hình LCD giao tiếp I2C sử dụng Arduino thì ta cần cài đặt thư viện Liquidcrystal_I2C. Tại đây
Lời kết
Qua bài hôm nay các bạn biết cách làm thế nào để hiển thị các ký tự và chuỗi ký tự lên LCD 16×2 và biết cách giao tiếp I2C.
Để nhận được nhiều kiến thức mới các bạn Đăng ký để nhận được thông báo sớm nhất.
Tham gia Cộng đồng Arduino KIT để cùng nhau thảo luận và chia sẽ kiến thức về lập trình Arduino.
Nếu các bạn thấy bài viết bổ ích nhớ Like và Share cho mọi người cùng đọc nhé.
Chúc các bạn thành công.
Trân trọng.
Giao tiếp I2C LCD Arduino
Module I2C LCD 16×2 | Arduino UNO |
GND | GND |
VCC | 5V |
SDA | A4/SDA |
SCL | A5/SCL |
Sơ đồ đấu nối
Các linh kiện cần thiết cho dự án:
Tên linh kiện | Số lượng | Shopee |
Arduino UNO R3 | Mua ngay | |
Dây cáp nạp | Mua ngay | |
Màn hình LCD 16×2 | Mua ngay | |
Module I2C LCD 16×2 | Mua ngay | |
Dây cắm (Đực – Cái) | Mua ngay |
Bạn sẽ học được gì
- Có kiến thức cơ bản về Robotics
- Chế tạo Robot dò đường thông minh
- Đánh thức nhà khoa học bên trong bạn
- Tìm hiểu thêm về Robotics, các thuật toán Robot tự động
- Kiến thức nền tảng để chế tạo các máy móc tự động phục vụ đời sống sinh hoạt, lao động sản xuất
- Kiến thức để chế tạo sản phẩm, tham gia các cuộc thi khoa học công nghệ trong nước và quốc tế
Circuit
Note that this circuit was originally designed for the Arduino UNO. As the Arduino is communicating with the display using SPI, pin 11 & 12 will change depending on what board you are using. For example, on a MKR WiFi 1010, the SPI bus is attached to pin 8 & 11.
Before wiring the LCD screen to your Arduino board we suggest to solder a pin header strip to the 14 (or 16) pin count connector of the LCD screen, as you can see in the image further up.
To wire your LCD screen to your board, connect the following pins:
- LCD RS pin to digital pin 12
- LCD Enable pin to digital pin 11
- LCD D4 pin to digital pin 5
- LCD D5 pin to digital pin 4
- LCD D6 pin to digital pin 3
- LCD D7 pin to digital pin 2
- LCD R/W pin to GND
- LCD VSS pin to GND
- LCD VCC pin to 5V
- LCD LED+ to 5V through a 220 ohm resistor
- LCD LED- to GND
Additionally, wire a 10k potentiometer to +5V and GND, with it’s wiper (output) to LCD screens VO pin (pin3).
Schematic
Hello World Example
This example sketch prints
to the LCD and shows the time in seconds since the Arduino was reset.
Hello World!
1/*2 LiquidCrystal Library – Hello World34 Demonstrates the use a 16×2 LCD display. The LiquidCrystal5 library works with all LCD displays that are compatible with the6 Hitachi HD44780 driver. There are many of them out there, and you7 can usually tell them by the 16-pin interface.89 This sketch prints “Hello World!” to the LCD10 and shows the time.1112 The circuit:13 * LCD RS pin to digital pin 1214 * LCD Enable pin to digital pin 1115 * LCD D4 pin to digital pin 516 * LCD D5 pin to digital pin 417 * LCD D6 pin to digital pin 318 * LCD D7 pin to digital pin 219 * LCD R/W pin to ground20 * LCD VSS pin to ground21 * LCD VCC pin to 5V22 * 10K resistor:23 * ends to +5V and ground24 * wiper to LCD VO pin (pin 3)2526 Library originally added 18 Apr 200827 by David A. Mellis28 library modified 5 Jul 200929 by Limor Fried (http://www.ladyada.net)30 example added 9 Jul 200931 by Tom Igoe32 modified 22 Nov 201033 by Tom Igoe34 modified 7 Nov 201635 by Arturo Guadalupi3637 This example code is in the public domain.3839 https://docs.arduino.cc/learn/electronics/lcd-displays4041*/4243// include the library code:44#include
4546// initialize the library by associating any needed LCD interface pin47// with the arduino pin number it is connected to48const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;49LiquidCrystal lcd(rs, en, d4, d5, d6, d7);5051void setup() {52 // set up the LCD’s number of columns and rows:53 lcd.begin(16, 2);54 // Print a message to the LCD.55 lcd.print(“hello, world!”);56}5758void loop() {59 // set the cursor to column 0, line 160 // (note: line 1 is the second row, since counting begins with 0):61 lcd.setCursor(0, 1);62 // print the number of seconds since reset:63 lcd.print(millis() / 1000);64}
Autoscroll Example
This example sketch shows how to use the
and
autoscroll()
methods to move all the text on the display left or right.
noAutoscroll()
-
moves all the text one space to the left each time a letter is added
autoscroll()
-
turns scrolling off
noAutoscroll()
This sketch prints the characters
to
with autoscroll off, then moves the cursor to the bottom right, turns autoscroll on, and prints them again.
1/*23 LiquidCrystal Library – Autoscroll45 Demonstrates the use a 16×2 LCD display. The LiquidCrystal67 library works with all LCD displays that are compatible with the89 Hitachi HD44780 driver. There are many of them out there, and you1011 can usually tell them by the 16-pin interface.1213 This sketch demonstrates the use of the autoscroll()1415 and noAutoscroll() functions to make new text scroll or not.1617 The circuit:1819 * LCD RS pin to digital pin 122021 * LCD Enable pin to digital pin 112223 * LCD D4 pin to digital pin 52425 * LCD D5 pin to digital pin 42627 * LCD D6 pin to digital pin 32829 * LCD D7 pin to digital pin 23031 * LCD R/W pin to ground3233 * 10K resistor:3435 * ends to +5V and ground3637 * wiper to LCD VO pin (pin 3)3839 Library originally added 18 Apr 20084041 by David A. Mellis4243 library modified 5 Jul 20094445 by Limor Fried (http://www.ladyada.net)4647 example added 9 Jul 20094849 by Tom Igoe5051 modified 22 Nov 20105253 by Tom Igoe5455 modified 7 Nov 20165657 by Arturo Guadalupi5859 This example code is in the public domain.6061 http://www.arduino.cc/en/Tutorial/LiquidCrystalAutoscroll6263*/6465// include the library code:66#include
6768// initialize the library by associating any needed LCD interface pin69// with the arduino pin number it is connected to7071const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;7273LiquidCrystal lcd(rs, en, d4, d5, d6, d7);7475void setup() {7677 // set up the LCD’s number of columns and rows:7879 lcd.begin(16, 2);80}8182void loop() {8384 // set the cursor to (0,0):8586 lcd.setCursor(0, 0);8788 // print from 0 to 9:8990 for (int thisChar = 0; thisChar < 10; thisChar++) {9192 lcd.print(thisChar);9394 delay(500);9596 }9798 // set the cursor to (16,1):99100 lcd.setCursor(16, 1);101102 // set the display to automatically scroll:103104 lcd.autoscroll();105106 // print from 0 to 9:107108 for (int thisChar = 0; thisChar < 10; thisChar++) {109110 lcd.print(thisChar);111112 delay(500);113114 }115116 // turn off automatic scrolling117118 lcd.noAutoscroll();119120 // clear screen for the next loop:121122 lcd.clear();123}
Blink Example
This example sketch shows how to use the
and
blink()
methods to blink a block-style cursor.
noBlink()
1/*23 LiquidCrystal Library – Blink45 Demonstrates the use a 16×2 LCD display. The LiquidCrystal67 library works with all LCD displays that are compatible with the89 Hitachi HD44780 driver. There are many of them out there, and you1011 can usually tell them by the 16-pin interface.1213 This sketch prints “Hello World!” to the LCD and makes the1415 cursor block blink.1617 The circuit:1819 * LCD RS pin to digital pin 122021 * LCD Enable pin to digital pin 112223 * LCD D4 pin to digital pin 52425 * LCD D5 pin to digital pin 42627 * LCD D6 pin to digital pin 32829 * LCD D7 pin to digital pin 23031 * LCD R/W pin to ground3233 * 10K resistor:3435 * ends to +5V and ground3637 * wiper to LCD VO pin (pin 3)3839 Library originally added 18 Apr 20084041 by David A. Mellis4243 library modified 5 Jul 20094445 by Limor Fried (http://www.ladyada.net)4647 example added 9 Jul 20094849 by Tom Igoe5051 modified 22 Nov 20105253 by Tom Igoe5455 modified 7 Nov 20165657 by Arturo Guadalupi5859 This example code is in the public domain.6061 http://www.arduino.cc/en/Tutorial/LiquidCrystalBlink6263*/6465// include the library code:66#include
6768// initialize the library by associating any needed LCD interface pin69// with the arduino pin number it is connected to7071const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;7273LiquidCrystal lcd(rs, en, d4, d5, d6, d7);7475void setup() {7677 // set up the LCD’s number of columns and rows:7879 lcd.begin(16, 2);8081 // Print a message to the LCD.8283 lcd.print(“hello, world!”);84}8586void loop() {8788 // Turn off the blinking cursor:8990 lcd.noBlink();9192 delay(3000);9394 // Turn on the blinking cursor:9596 lcd.blink();9798 delay(3000);99}
Cursor
This example sketch shows how to use the
and
cursor()
methods to control an underscore-style cursor.
noCursor()
1/*23 LiquidCrystal Library – Cursor45 Demonstrates the use a 16×2 LCD display. The LiquidCrystal67 library works with all LCD displays that are compatible with the89 Hitachi HD44780 driver. There are many of them out there, and you1011 can usually tell them by the 16-pin interface.1213 This sketch prints “Hello World!” to the LCD and1415 uses the cursor() and noCursor() methods to turn1617 on and off the cursor.1819 The circuit:2021 * LCD RS pin to digital pin 122223 * LCD Enable pin to digital pin 112425 * LCD D4 pin to digital pin 52627 * LCD D5 pin to digital pin 42829 * LCD D6 pin to digital pin 33031 * LCD D7 pin to digital pin 23233 * LCD R/W pin to ground3435 * 10K resistor:3637 * ends to +5V and ground3839 * wiper to LCD VO pin (pin 3)4041 Library originally added 18 Apr 20084243 by David A. Mellis4445 library modified 5 Jul 20094647 by Limor Fried (http://www.ladyada.net)4849 example added 9 Jul 20095051 by Tom Igoe5253 modified 22 Nov 20105455 by Tom Igoe5657 modified 7 Nov 20165859 by Arturo Guadalupi6061 This example code is in the public domain.6263 http://www.arduino.cc/en/Tutorial/LiquidCrystalCursor6465*/6667// include the library code:68#include
6970// initialize the library by associating any needed LCD interface pin71// with the arduino pin number it is connected to7273const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;7475LiquidCrystal lcd(rs, en, d4, d5, d6, d7);7677void setup() {7879 // set up the LCD’s number of columns and rows:8081 lcd.begin(16, 2);8283 // Print a message to the LCD.8485 lcd.print(“hello, world!”);86}8788void loop() {8990 // Turn off the cursor:9192 lcd.noCursor();9394 delay(500);9596 // Turn on the cursor:9798 lcd.cursor();99100 delay(500);101}
Display Example
This example sketch shows how to use the
and
display()
methods to turn on and off the display. The text to be displayed will still be preserved when you use noDisplay() so it’s a quick way to blank the display without losing everything on it.
noDisplay()
1/*2 LiquidCrystal Library – display() and noDisplay()34 Demonstrates the use a 16×2 LCD display. The LiquidCrystal5 library works with all LCD displays that are compatible with the6 Hitachi HD44780 driver. There are many of them out there, and you7 can usually tell them by the 16-pin interface.89 This sketch prints “Hello World!” to the LCD and uses the10 display() and noDisplay() functions to turn on and off11 the display.1213 The circuit:14 * LCD RS pin to digital pin 1215 * LCD Enable pin to digital pin 1116 * LCD D4 pin to digital pin 517 * LCD D5 pin to digital pin 418 * LCD D6 pin to digital pin 319 * LCD D7 pin to digital pin 220 * LCD R/W pin to ground21 * 10K resistor:22 * ends to +5V and ground23 * wiper to LCD VO pin (pin 3)2425 Library originally added 18 Apr 200826 by David A. Mellis27 library modified 5 Jul 200928 by Limor Fried (http://www.ladyada.net)29 example added 9 Jul 200930 by Tom Igoe31 modified 22 Nov 201032 by Tom Igoe33 modified 7 Nov 201634 by Arturo Guadalupi3536 This example code is in the public domain.3738 http://www.arduino.cc/en/Tutorial/LiquidCrystalDisplay3940*/4142// include the library code:43#include
4445// initialize the library by associating any needed LCD interface pin46// with the arduino pin number it is connected to47const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;48LiquidCrystal lcd(rs, en, d4, d5, d6, d7);4950void setup() {51 // set up the LCD’s number of columns and rows:52 lcd.begin(16, 2);53 // Print a message to the LCD.54 lcd.print(“hello, world!”);55}5657void loop() {58 // Turn off the display:59 lcd.noDisplay();60 delay(500);61 // Turn on the display:62 lcd.display();63 delay(500);64}
Scroll Example
This example sketch shows how to use the
and
scrollDisplayLeft()
methods to reverse the direction the text is flowing. It prints “Hello World!”, scrolls it offscreen to the left, then offscreen to the right, then back to home.
scrollDisplayRight()
1/*2 LiquidCrystal Library – scrollDisplayLeft() and scrollDisplayRight()34 Demonstrates the use a 16×2 LCD display. The LiquidCrystal5 library works with all LCD displays that are compatible with the6 Hitachi HD44780 driver. There are many of them out there, and you7 can usually tell them by the 16-pin interface.89 This sketch prints “Hello World!” to the LCD and uses the10 scrollDisplayLeft() and scrollDisplayRight() methods to scroll11 the text.1213 The circuit:14 * LCD RS pin to digital pin 1215 * LCD Enable pin to digital pin 1116 * LCD D4 pin to digital pin 517 * LCD D5 pin to digital pin 418 * LCD D6 pin to digital pin 319 * LCD D7 pin to digital pin 220 * LCD R/W pin to ground21 * 10K resistor:22 * ends to +5V and ground23 * wiper to LCD VO pin (pin 3)2425 Library originally added 18 Apr 200826 by David A. Mellis27 library modified 5 Jul 200928 by Limor Fried (http://www.ladyada.net)29 example added 9 Jul 200930 by Tom Igoe31 modified 22 Nov 201032 by Tom Igoe33 modified 7 Nov 201634 by Arturo Guadalupi3536 This example code is in the public domain.3738 http://www.arduino.cc/en/Tutorial/LiquidCrystalScroll3940*/4142// include the library code:43#include
4445// initialize the library by associating any needed LCD interface pin46// with the arduino pin number it is connected to47const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;48LiquidCrystal lcd(rs, en, d4, d5, d6, d7);4950void setup() {51 // set up the LCD’s number of columns and rows:52 lcd.begin(16, 2);53 // Print a message to the LCD.54 lcd.print(“hello, world!”);55 delay(1000);56}5758void loop() {59 // scroll 13 positions (string length) to the left60 // to move it offscreen left:61 for (int positionCounter = 0; positionCounter < 13; positionCounter++) {62 // scroll one position left:63 lcd.scrollDisplayLeft();64 // wait a bit:65 delay(150);66 }6768 // scroll 29 positions (string length + display length) to the right69 // to move it offscreen right:70 for (int positionCounter = 0; positionCounter < 29; positionCounter++) {71 // scroll one position right:72 lcd.scrollDisplayRight();73 // wait a bit:74 delay(150);75 }7677 // scroll 16 positions (display length + string length) to the left78 // to move it back to center:79 for (int positionCounter = 0; positionCounter < 16; positionCounter++) {80 // scroll one position left:81 lcd.scrollDisplayLeft();82 // wait a bit:83 delay(150);84 }8586 // delay at the end of the full loop:87 delay(1000);8889}
Serial to Display Example
This example sketch accepts serial input from a host computer and displays it on the LCD. To use it, upload the sketch, then open the Serial Monitor and type some characters and click Send. The text will appear on your LCD.
1/*2 LiquidCrystal Library – Serial Input34 Demonstrates the use a 16×2 LCD display. The LiquidCrystal5 library works with all LCD displays that are compatible with the6 Hitachi HD44780 driver. There are many of them out there, and you7 can usually tell them by the 16-pin interface.89 This sketch displays text sent over the serial port10 (e.g. from the Serial Monitor) on an attached LCD.1112 The circuit:13 * LCD RS pin to digital pin 1214 * LCD Enable pin to digital pin 1115 * LCD D4 pin to digital pin 516 * LCD D5 pin to digital pin 417 * LCD D6 pin to digital pin 318 * LCD D7 pin to digital pin 219 * LCD R/W pin to ground20 * 10K resistor:21 * ends to +5V and ground22 * wiper to LCD VO pin (pin 3)2324 Library originally added 18 Apr 200825 by David A. Mellis26 library modified 5 Jul 200927 by Limor Fried (http://www.ladyada.net)28 example added 9 Jul 200929 by Tom Igoe30 modified 22 Nov 201031 by Tom Igoe32 modified 7 Nov 201633 by Arturo Guadalupi3435 This example code is in the public domain.3637 http://www.arduino.cc/en/Tutorial/LiquidCrystalSerialDisplay3839*/4041// include the library code:42#include
4344// initialize the library by associating any needed LCD interface pin45// with the arduino pin number it is connected to46const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;47LiquidCrystal lcd(rs, en, d4, d5, d6, d7);4849void setup() {50 // set up the LCD’s number of columns and rows:51 lcd.begin(16, 2);52 // initialize the serial communications:53 Serial.begin(9600);54}5556void loop() {57 // when characters arrive over the serial port…58 if (Serial.available()) {59 // wait a bit for the entire message to arrive60 delay(100);61 // clear the screen62 lcd.clear();63 // read all the available characters64 while (Serial.available() > 0) {65 // display each character to the LCD66 lcd.write(Serial.read());67 }68 }69}
Set Cursor Example
This example sketch shows how to use the
method to reposition the cursor. To move the cursor, just call
setCursor()
with a row and column position. For example, for a 2×16 display:
setCursor()
1lcd.setCursor(0, 0); // top left2lcd.setCursor(15, 0); // top right3lcd.setCursor(0, 1); // bottom left4lcd.setCursor(15, 1); // bottom right
Here is the full example:
1/*23 LiquidCrystal Library – setCursor45 Demonstrates the use a 16×2 LCD display. The LiquidCrystal67 library works with all LCD displays that are compatible with the89 Hitachi HD44780 driver. There are many of them out there, and you1011 can usually tell them by the 16-pin interface.1213 This sketch prints to all the positions of the LCD using the1415 setCursor() method:1617 The circuit:1819 * LCD RS pin to digital pin 122021 * LCD Enable pin to digital pin 112223 * LCD D4 pin to digital pin 52425 * LCD D5 pin to digital pin 42627 * LCD D6 pin to digital pin 32829 * LCD D7 pin to digital pin 23031 * LCD R/W pin to ground3233 * 10K resistor:3435 * ends to +5V and ground3637 * wiper to LCD VO pin (pin 3)3839 Library originally added 18 Apr 20084041 by David A. Mellis4243 library modified 5 Jul 20094445 by Limor Fried (http://www.ladyada.net)4647 example added 9 Jul 20094849 by Tom Igoe5051 modified 22 Nov 20105253 by Tom Igoe5455 modified 7 Nov 20165657 by Arturo Guadalupi5859 This example code is in the public domain.6061 http://www.arduino.cc/en/Tutorial/LiquidCrystalSetCursor6263*/6465// include the library code:66#include
6768// initialize the library by associating any needed LCD interface pin69// with the arduino pin number it is connected to7071const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;7273LiquidCrystal lcd(rs, en, d4, d5, d6, d7);7475// these constants won’t change. But you can change the size of76// your LCD using them:7778const int numRows = 2;7980const int numCols = 16;8182void setup() {8384 // set up the LCD’s number of columns and rows:8586 lcd.begin(numCols, numRows);87}8889void loop() {9091 // loop from ASCII ‘a’ to ASCII ‘z’:9293 for (int thisLetter = ‘a’; thisLetter <= ‘z’; thisLetter++) {9495 // loop over the columns:9697 for (int thisRow = 0; thisRow < numRows; thisRow++) {9899 // loop over the rows:100101 for (int thisCol = 0; thisCol < numCols; thisCol++) {102103 // set the cursor position:104105 lcd.setCursor(thisCol, thisRow);106107 // print the letter:108109 lcd.write(thisLetter);110111 delay(200);112113 }114115 }116117 }118}
Text Direction Example
This example sketch shows how to use the
and
leftToRight()
methods. These methods control which way text flows from the cursor.
rightToLeft()
-
causes text to flow to the left from the cursor, as if the display is right-justified.
rightToLeft()
-
causes text to flow to the right from the cursor, as if the display is left-justified.
leftToRight()
This sketch prints
through
right to left, then
through
left to right, then
through
right to left again.
1/*23 LiquidCrystal Library – TextDirection45 Demonstrates the use a 16×2 LCD display. The LiquidCrystal67 library works with all LCD displays that are compatible with the89 Hitachi HD44780 driver. There are many of them out there, and you1011 can usually tell them by the 16-pin interface.1213 This sketch demonstrates how to use leftToRight() and rightToLeft()1415 to move the cursor.1617 The circuit:1819 * LCD RS pin to digital pin 122021 * LCD Enable pin to digital pin 112223 * LCD D4 pin to digital pin 52425 * LCD D5 pin to digital pin 42627 * LCD D6 pin to digital pin 32829 * LCD D7 pin to digital pin 23031 * LCD R/W pin to ground3233 * 10K resistor:3435 * ends to +5V and ground3637 * wiper to LCD VO pin (pin 3)3839 Library originally added 18 Apr 20084041 by David A. Mellis4243 library modified 5 Jul 20094445 by Limor Fried (http://www.ladyada.net)4647 example added 9 Jul 20094849 by Tom Igoe5051 modified 22 Nov 20105253 by Tom Igoe5455 modified 7 Nov 20165657 by Arturo Guadalupi5859 This example code is in the public domain.6061 http://www.arduino.cc/en/Tutorial/LiquidCrystalTextDirection6263*/6465// include the library code:66#include
6768// initialize the library by associating any needed LCD interface pin69// with the arduino pin number it is connected to7071const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;7273LiquidCrystal lcd(rs, en, d4, d5, d6, d7);7475int thisChar = ‘a’;7677void setup() {7879 // set up the LCD’s number of columns and rows:8081 lcd.begin(16, 2);8283 // turn on the cursor:8485 lcd.cursor();86}8788void loop() {8990 // reverse directions at ‘m’:9192 if (thisChar == ‘m’) {9394 // go right for the next letter9596 lcd.rightToLeft();9798 }99100 // reverse again at ‘s’:101102 if (thisChar == ‘s’) {103104 // go left for the next letter105106 lcd.leftToRight();107108 }109110 // reset at ‘z’:111112 if (thisChar > ‘z’) {113114 // go to (0,0):115116 lcd.home();117118 // start again at 0119120 thisChar = ‘a’;121122 }123124 // print the character125126 lcd.write(thisChar);127128 // wait a second:129130 delay(1000);131132 // increment the letter:133134 thisChar++;135}
Custom Character
This example demonstrates how to add custom characters on an LCD display.
Note that this example requires an additional potentiometer:
- Outer pins connected to 5V and GND.
- Inner pin (wiper) connected to A0.
This potentiometer controls the
variable.
delayTime
1/*2 LiquidCrystal Library – Custom Characters34 Demonstrates how to add custom characters on an LCD display.5 The LiquidCrystal library works with all LCD displays that are6 compatible with the Hitachi HD44780 driver. There are many of7 them out there, and you can usually tell them by the 16-pin interface.89 This sketch prints “I
Arduino!” and a little dancing man10 to the LCD.1112 The circuit:13 * LCD RS pin to digital pin 1214 * LCD Enable pin to digital pin 1115 * LCD D4 pin to digital pin 516 * LCD D5 pin to digital pin 417 * LCD D6 pin to digital pin 318 * LCD D7 pin to digital pin 219 * LCD R/W pin to ground20 * 10K potentiometer:21 * ends to +5V and ground22 * wiper to LCD VO pin (pin 3)23 * 10K poterntiometer on pin A02425 created 21 Mar 201126 by Tom Igoe27 modified 11 Nov 201328 by Scott Fitzgerald29 modified 7 Nov 201630 by Arturo Guadalupi3132 Based on Adafruit’s example at33 https://github.com/adafruit/SPI_VFD/blob/master/examples/createChar/createChar.pde3435 This example code is in the public domain.36 https://docs.arduino.cc/learn/electronics/lcd-displays#custom-character3738 Also useful:39 http://icontexto.com/charactercreator/4041*/4243// include the library code:44#include4546// initialize the library by associating any needed LCD interface pin47// with the arduino pin number it is connected to48const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;49LiquidCrystal lcd(rs, en, d4, d5, d6, d7);5051// make some custom characters:52byte heart[8] = {53 0b00000,54 0b01010,55 0b11111,56 0b11111,57 0b11111,58 0b01110,59 0b00100,60 0b0000061};6263byte smiley[8] = {64 0b00000,65 0b00000,66 0b01010,67 0b00000,68 0b00000,69 0b10001,70 0b01110,71 0b0000072};7374byte frownie[8] = {75 0b00000,76 0b00000,77 0b01010,78 0b00000,79 0b00000,80 0b00000,81 0b01110,82 0b1000183};8485byte armsDown[8] = {86 0b00100,87 0b01010,88 0b00100,89 0b00100,90 0b01110,91 0b10101,92 0b00100,93 0b0101094};9596byte armsUp[8] = {97 0b00100,98 0b01010,99 0b00100,100 0b10101,101 0b01110,102 0b00100,103 0b00100,104 0b01010105};106107void setup() {108 // initialize LCD and set up the number of columns and rows:109 lcd.begin(16, 2);110111 // create a new character112 lcd.createChar(0, heart);113 // create a new character114 lcd.createChar(1, smiley);115 // create a new character116 lcd.createChar(2, frownie);117 // create a new character118 lcd.createChar(3, armsDown);119 // create a new character120 lcd.createChar(4, armsUp);121122 // set the cursor to the top left123 lcd.setCursor(0, 0);124125 // Print a message to the lcd.126 lcd.print(“I “);127 lcd.write(byte(0)); // when calling lcd.write() ‘0’ must be cast as a byte128 lcd.print(” Arduino! “);129 lcd.write((byte)1);130131}132133void loop() {134 // read the potentiometer on A0:135 int sensorReading = analogRead(A0);136 // map the result to 200 – 1000:137 int delayTime = map(sensorReading, 0, 1023, 200, 1000);138 // set the cursor to the bottom row, 5th position:139 lcd.setCursor(4, 1);140 // draw the little man, arms down:141 lcd.write(3);142 delay(delayTime);143 lcd.setCursor(4, 1);144 // draw him arms up:145 lcd.write(4);146 delay(delayTime);147}
Suggested changes
The content on docs.arduino.cc is facilitated through a public GitHub repository. You can read more on how to contribute in the contribution policy.
License
The Arduino documentation is licensed under the Creative Commons Attribution-Share Alike 4.0 license.
Màn hình LCD 1602 Xanh Lá
LCD Display LCD1602 Module Green Screen
Mã sản phẩm: 67HZ
Sản phẩm hiện đang còn hàng.
Xem chi nhánh còn hàng
Màn hình LCD 1602 xanh lá. Điện áp hoạt động là 5V. Chữ trắng, nền xanh dương. Kích thước: 80 x 36 x 12.5mm
- Cộng thêm 3 điểm tích lũy
-
TP.HCM: Miễn phí vận chuyển đơn hàng từ 300k
Tỉnh thành khác: Miễn phí vận chuyển đơn hàng từ 500k
Xem thêm các khuyến mãi vận chuyển khác.
Giới thiệu LCD 16×2
Thông số kỹ thuật LCD 16×2
LCD 16×2 được sử dụng để hiển thị trạng thái hoặc các thông số.
- LCD 16×2 có 16 chân trong đó 8 chân dữ liệu (D0 – D7) và 3 chân điều khiển (RS, RW, EN).
- 5 chân còn lại dùng để cấp nguồn và đèn nền cho LCD 16×2.
- Các chân điều khiển giúp ta dễ dàng cấu hình LCD ở chế độ lệnh hoặc chế độ dữ liệu.
- Chúng còn giúp ta cấu hình ở chế độ đọc hoặc ghi.
LCD 16×2 có thể sử dụng ở chế độ 4 bit hoặc 8 bit tùy theo ứng dụng ta đang làm.
Chi tiết sản phẩm
Màn hình LCD 1602 xanh lá sử dụng driver HD44780, có khả năng hiển thị 2 dòng với mỗi dòng 16 ký tự, màn hình có độ bền cao, rất phổ biến, nhiều code mẫu và dễ dàng sử dụng hơn nếu đi kèm mạch chuyển tiếp I2C
THÔNG SỐ KỸ THUẬT
- Điện áp hoạt động là 5V.
- Kích thước: 80 x 36 x 12.5mm
- Chữ trắng, nền xanh dương
- Khoảng cách giữa hai chân kết nối là 0.1 inch tiện dụng khi kết nối với Breadboard.
- Tên các chân được ghi ở mặt sau của màn hình LCD hổ trợ việc kết nối, đi dây điện.
- Có đèn led nền, có thể dùng biến trở hoặc PWM điều chình độ sáng để sử dụng ít điện năng hơn.
- Có thể được điều khiển với 6 dây tín hiệu
- Có bộ ký tự được xây dựng hỗ trợ tiếng Anh và tiếng Nhật, xem thêm HD44780 datasheet để biết thêm chi tiết.
Sơ đồ chân Màn hình LCD 1602 Xanh Lá:
Chân | Ký hiệu | Mô tả | Giá trị |
VSS | GND | 0V | |
VCC | 5V | ||
V0 | Độ tương phản | ||
RS | Lựa chọn thanh ghi |
RS=0 (mức thấp) chọn thanh ghi lệnh
RS=1 (mức cao) chọn thanh ghi dữ liệu |
|
R/W | Chọn thanh ghi đọc/viết dữ liệu |
R/W=0 thanh ghi viết
R/W=1 thanh ghi đọc |
|
Enable | |||
DB0 | Chân truyền dữ liệu | 8 bit: DB0DB7 | |
DB1 | |||
DB2 | |||
10 | DB3 | ||
11 | DB4 | ||
12 | DB5 | ||
13 | DB6 | ||
14 | DB7 | ||
15 | Cực dương led nền | 0V đến 5V | |
16 | Cực âm led nền | 0V |
SƠ ĐỒ LẮP MẠCH TRỰC TIẾP VỚI ARDUINO :
SƠ ĐỒ LẮP MẠCH VỚI ARDUINO THÔNG QUA MẠCH I2C :
————————CODE THAM KHẢO———————
Thư viện LiquidCrystal.h : https://github.com/adafruit/STEMMA_LiquidCrystal
#include
LiquidCrystal lcd(12, 11, 5, 4, 3, 2); void setup() { lcd.begin(16, 2); lcd.print(“Dien Tu NSHOP”); lcd.setCursor(0,1); lcd.print(” Xin Kinh Chao “); } void loop() { }
Hình ảnh sản phẩm:
MỘT SỐ SẢN PHẨM LIÊN QUAN:
https://nshopvn.com/product/mach-chuyen-giao-tiep-lcd1602-lcd1604-lcd2004-sang-i2c/
https://nshopvn.com/product/arduino-uno-r3-dip-kem-cap/
https://nshopvn.com/product/arduino-uno-r3-smd-chip-dan-kem-cap/
Nshopvn.com · 07/03/2019 10:43 AM
Màn hình LCD 1602 Xanh Lá giá chỉ 32.000₫
NnormImind
cialis pills for sale Japanese spotted fever caused by Rickettsia japonica and Siberian tick typhus caused by R
Ôªø
Ngày nay, thi·∫øt b·ªã hi·ªÉn th·ªã LCD 1602 (Liquid Crystal Display) ƒë∆∞·ª£c s·ª≠ d·ª•ng trong r·∫•t nhi·ªÅu các ·ª©ng d·ª•ng c·ªßa VƒêK. LCD 1602 có r·∫•t nhi·ªÅu ∆∞u ƒëi·ªÉm so v·ªõi các d·∫°ng hi·ªÉn th·ªã khác nh∆∞: kh·∫£ nƒÉng hi·ªÉn th·ªã kí t·ª± ƒëa d·∫°ng (ch·ªØ, s·ªë, kí t·ª± ƒë·ªì h·ªça); d·ªÖ dàng ƒë∆∞a vào m·∫°ch ·ª©ng d·ª•ng theo nhi·ªÅu giao th·ª©c giao ti·∫øp khác nhau, tiêu t·ªën r·∫•t ít tài nguyên h·ªá th·ªëng, giá thành r·∫ª,…
Thông s·ªë kƒ© thu·∫≠t c·ªßa s·∫£n ph·∫©m LCD 1602:
– ƒêi·ªán áp MAX : 7V
– ƒêi·ªán áp MIN : – 0,3V
– Ho·∫°t ƒë·ªông ·ªïn ƒë·ªãnh : 2.7-5.5V
– ƒêi·ªán áp ra m·ª©c cao : > 2.4
– ƒêi·ªán áp ra m·ª©c th·∫•p : <0.4V
– Dòng ƒëi·ªán c·∫•p ngu·ªìn : 350uA – 600uA
– Nhi·ªát ƒë·ªô ho·∫°t ƒë·ªông : – 30 – 75 ƒë·ªô C
LCD 1602 xanh lá
Ch·ª©c nƒÉng c·ªßa t·ª´ng chân LCD 1602:
– Chân s·ªë 1 – VSS : chân n·ªëi ƒë·∫•t cho LCD ƒë∆∞·ª£c n·ªëi v·ªõi GND c·ªßa m·∫°ch ƒëi·ªÅu khi·ªÉn
– Chân s·ªë 2 – VDD : chân c·∫•p ngu·ªìn cho LCD, ƒë∆∞·ª£c n·ªëi v·ªõi VCC=5V c·ªßa m·∫°ch ƒëi·ªÅu khi·ªÉn
– Chân s·ªë 3 – VE : ƒëi·ªÅu ch·ªânh ƒë·ªô t∆∞∆°ng ph·∫£n c·ªßa LCD
– Chân s·ªë 4 – RS : chân ch·ªçn thanh ghi, ƒë∆∞·ª£c n·ªëi v·ªõi logic “0” ho·∫∑c logic “1”:
+ Logic “0”: Bus DB0 – DB7 s·∫Ω n·ªëi v·ªõi thanh ghi l·ªánh IR c·ªßa LCD (·ªü ch·∫ø ƒë·ªô “ghi” – write) ho·∫∑c n·ªëi v·ªõi b·ªô ƒë·∫øm ƒë·ªãa ch·ªâ c·ªßa LCD (·ªü ch·∫ø ƒë·ªô “ƒë·ªçc” – read)
+ Logic “1”: Bus DB0 – DB7 s·∫Ω n·ªëi v·ªõi thanh ghi d·ªØ li·ªáu DR bên trong LCD
– Chân s·ªë 5 – R/W : chân ch·ªçn ch·∫ø ƒë·ªô ƒë·ªçc/ghi (Read/Write), ƒë∆∞·ª£c n·ªëi v·ªõi logic “0” ƒë·ªÉ ghi ho·∫∑c n·ªëi v·ªõi logic “1” ƒë·ªçc
– Chân s·ªë 6 – E : chân cho phép (Enable). Sau khi các tín hi·ªáu ƒë∆∞·ª£c ƒë·∫∑t lên bus DB0-DB7, các l·ªánh ch·ªâ ƒë∆∞·ª£c ch·∫•p nh·∫≠n khi có 1 xung cho phép c·ªßa chân này nh∆∞ sau:
+ ·ªû ch·∫ø ƒë·ªô ghi: D·ªØ li·ªáu ·ªü bus s·∫Ω ƒë∆∞·ª£c LCD chuy·ªÉn vào thanh ghi bên trong khi phát hi·ªán m·ªôt xung (high-to-low transition) c·ªßa tín hi·ªáu chân E
+ ·ªû ch·∫ø ƒë·ªô ƒë·ªçc: D·ªØ li·ªáu s·∫Ω ƒë∆∞·ª£c LCD xu·∫•t ra DB0-DB7 khi phát hi·ªán c·∫°nh lên (low-to-high transition) ·ªü chân E và ƒë∆∞·ª£c LCD gi·ªØ ·ªü bus ƒë·∫øn khi nào chân E xu·ªëng m·ª©c th·∫•p
LCD 1602 Xanh d∆∞∆°ng 5v
– Chân s·ªë 7 ƒë·∫øn 14 – D0 ƒë·∫øn D7: 8 ƒë∆∞·ªùng c·ªßa bus d·ªØ li·ªáu dùng ƒë·ªÉ trao ƒë·ªïi thông tin v·ªõi MPU. Có 2 ch·∫ø ƒë·ªô s·ª≠ d·ª•ng 8 ƒë∆∞·ªùng bus này là: Ch·∫ø ƒë·ªô 8 bit (d·ªØ li·ªáu ƒë∆∞·ª£c truy·ªÅn trên c·∫£ 8 ƒë∆∞·ªùng, v·ªõi bit MSB là bit DB7) và Ch·∫ø ƒë·ªô 4 bit (d·ªØ li·ªáu ƒë∆∞·ª£c truy·ªÅn trên 4 ƒë∆∞·ªùng t·ª´ DB4 t·ªõi DB7, bit MSB là DB7)
– Chân s·ªë 15 – A : ngu·ªìn d∆∞∆°ng cho ƒëèn n·ªÅn
– Chân s·ªë 16 – K : ngu·ªìn âm cho ƒëèn n·ªÅn
Trên ƒëây là m·ªôt s·ªë thông tin v·ªÅ thông s·ªë kƒ© thu·∫≠t c·ªßa LCD 1602 mà b·∫°n có th·ªÉ tìm hi·ªÉu. Hãy tham kh·∫£o ngay ƒë·ªÉ có th·ªÉ s·ª≠ d·ª•ng thi·∫øt b·ªã linh ki·ªán này m·ªôt cách ƒëúng ƒë·∫Øn nh·∫•t nhé.
Ngày nay, thi·∫øt b·ªã hi·ªÉn th·ªã LCD 1602 (Liquid Crystal Display) ƒë∆∞·ª£c s·ª≠ d·ª•ng trong r·∫•t nhi·ªÅu các ·ª©ng d·ª•ng c·ªßa VƒêK. LCD 1602 có r·∫•t nhi·ªÅu ∆∞u ƒëi·ªÉm so v·ªõi các d·∫°ng hi·ªÉn th·ªã khác nh∆∞: kh·∫£ nƒÉng hi·ªÉn th·ªã kí t·ª± ƒëa d·∫°ng (ch·ªØ, s·ªë, kí t·ª± ƒë·ªì h·ªça); d·ªÖ dàng ƒë∆∞a vào m·∫°ch ·ª©ng d·ª•ng theo nhi·ªÅu giao th·ª©c giao ti·∫øp khác nhau, tiêu t·ªën r·∫•t ít tài nguyên h·ªá th·ªëng, giá thành r·∫ª,…
Thông s·ªë kƒ© thu·∫≠t c·ªßa s·∫£n ph·∫©m LCD 1602:
– ƒêi·ªán áp MAX : 7V
– ƒêi·ªán áp MIN : – 0,3V
– Ho·∫°t ƒë·ªông ·ªïn ƒë·ªãnh : 2.7-5.5V
– ƒêi·ªán áp ra m·ª©c cao : > 2.4
– ƒêi·ªán áp ra m·ª©c th·∫•p : <0.4V
– Dòng ƒëi·ªán c·∫•p ngu·ªìn : 350uA – 600uA
– Nhi·ªát ƒë·ªô ho·∫°t ƒë·ªông : – 30 – 75 ƒë·ªô C
LCD 1602 xanh lá
Ch·ª©c nƒÉng c·ªßa t·ª´ng chân LCD 1602:
– Chân s·ªë 1 – VSS : chân n·ªëi ƒë·∫•t cho LCD ƒë∆∞·ª£c n·ªëi v·ªõi GND c·ªßa m·∫°ch ƒëi·ªÅu khi·ªÉn
– Chân s·ªë 2 – VDD : chân c·∫•p ngu·ªìn cho LCD, ƒë∆∞·ª£c n·ªëi v·ªõi VCC=5V c·ªßa m·∫°ch ƒëi·ªÅu khi·ªÉn
– Chân s·ªë 3 – VE : ƒëi·ªÅu ch·ªânh ƒë·ªô t∆∞∆°ng ph·∫£n c·ªßa LCD
– Chân s·ªë 4 – RS : chân ch·ªçn thanh ghi, ƒë∆∞·ª£c n·ªëi v·ªõi logic “0” ho·∫∑c logic “1”:
+ Logic “0”: Bus DB0 – DB7 s·∫Ω n·ªëi v·ªõi thanh ghi l·ªánh IR c·ªßa LCD (·ªü ch·∫ø ƒë·ªô “ghi” – write) ho·∫∑c n·ªëi v·ªõi b·ªô ƒë·∫øm ƒë·ªãa ch·ªâ c·ªßa LCD (·ªü ch·∫ø ƒë·ªô “ƒë·ªçc” – read)
+ Logic “1”: Bus DB0 – DB7 s·∫Ω n·ªëi v·ªõi thanh ghi d·ªØ li·ªáu DR bên trong LCD
– Chân s·ªë 5 – R/W : chân ch·ªçn ch·∫ø ƒë·ªô ƒë·ªçc/ghi (Read/Write), ƒë∆∞·ª£c n·ªëi v·ªõi logic “0” ƒë·ªÉ ghi ho·∫∑c n·ªëi v·ªõi logic “1” ƒë·ªçc
– Chân s·ªë 6 – E : chân cho phép (Enable). Sau khi các tín hi·ªáu ƒë∆∞·ª£c ƒë·∫∑t lên bus DB0-DB7, các l·ªánh ch·ªâ ƒë∆∞·ª£c ch·∫•p nh·∫≠n khi có 1 xung cho phép c·ªßa chân này nh∆∞ sau:
+ ·ªû ch·∫ø ƒë·ªô ghi: D·ªØ li·ªáu ·ªü bus s·∫Ω ƒë∆∞·ª£c LCD chuy·ªÉn vào thanh ghi bên trong khi phát hi·ªán m·ªôt xung (high-to-low transition) c·ªßa tín hi·ªáu chân E
+ ·ªû ch·∫ø ƒë·ªô ƒë·ªçc: D·ªØ li·ªáu s·∫Ω ƒë∆∞·ª£c LCD xu·∫•t ra DB0-DB7 khi phát hi·ªán c·∫°nh lên (low-to-high transition) ·ªü chân E và ƒë∆∞·ª£c LCD gi·ªØ ·ªü bus ƒë·∫øn khi nào chân E xu·ªëng m·ª©c th·∫•p
LCD 1602 Xanh d∆∞∆°ng 5v
– Chân s·ªë 7 ƒë·∫øn 14 – D0 ƒë·∫øn D7: 8 ƒë∆∞·ªùng c·ªßa bus d·ªØ li·ªáu dùng ƒë·ªÉ trao ƒë·ªïi thông tin v·ªõi MPU. Có 2 ch·∫ø ƒë·ªô s·ª≠ d·ª•ng 8 ƒë∆∞·ªùng bus này là: Ch·∫ø ƒë·ªô 8 bit (d·ªØ li·ªáu ƒë∆∞·ª£c truy·ªÅn trên c·∫£ 8 ƒë∆∞·ªùng, v·ªõi bit MSB là bit DB7) và Ch·∫ø ƒë·ªô 4 bit (d·ªØ li·ªáu ƒë∆∞·ª£c truy·ªÅn trên 4 ƒë∆∞·ªùng t·ª´ DB4 t·ªõi DB7, bit MSB là DB7)
– Chân s·ªë 15 – A : ngu·ªìn d∆∞∆°ng cho ƒëèn n·ªÅn
– Chân s·ªë 16 – K : ngu·ªìn âm cho ƒëèn n·ªÅn
Trên ƒëây là m·ªôt s·ªë thông tin v·ªÅ thông s·ªë kƒ© thu·∫≠t c·ªßa LCD 1602 mà b·∫°n có th·ªÉ tìm hi·ªÉu. Hãy tham kh·∫£o ngay ƒë·ªÉ có th·ªÉ s·ª≠ d·ª•ng thi·∫øt b·ªã linh ki·ªán này m·ªôt cách ƒëúng ƒë·∫Øn nh·∫•t nhé.
NnormImind
cialis pills for sale Japanese spotted fever caused by Rickettsia japonica and Siberian tick typhus caused by R
Tin hot
Đọc nhiều nhất
Đặt lịch
LCD 16×2 Pin Configuration and Its Working Nowadays, we always use the devices which are made up of LCDs such as CD players, DVD players, digital watches, computers, etc. These are commonly used in the screen industries to replace the utilization of CRTs. Cathode Ray Tubes use huge power when compared with LCDs, and CRTs heavier as well as bigger. These devices are thinner as well power consumption is extremely less. The LCD 16×2 working principle is, it blocks the light rather than dissipate. This article discusses an overview of LCD 16X2, pin configuration and its working. What is the LCD 16×2? The term LCD stands for liquid crystal display. It is one kind of electronic display module used in an extensive range of applications like various circuits & devices like mobile phones, calculators, computers, TV sets, etc. These displays are mainly preferred for multi-segment light-emitting diodes and seven segments. The main benefits of using this module are inexpensive; simply programmable, animations, and there are no limitations for displaying custom characters, special and even animations, etc. 16X2 LCD LCD 16×2 Pin Diagram The 16×2 LCD pinout is shown below. Pin1 (Ground/Source Pin): This is a GND pin of display, used to connect the GND terminal of the microcontroller unit or power source. Pin2 (VCC/Source Pin): This is the voltage supply pin of the display, used to connect the supply pin of the power source. Pin3 (V0/VEE/Control Pin): This pin regulates the difference of the display, used to connect a changeable POT that can supply 0 to 5V. Pin4 (Register Select/Control Pin): This pin toggles among command or data register, used to connect a microcontroller unit pin and obtains either 0 or 1(0 = data mode, and 1 = command mode). Pin5 (Read/Write/Control Pin): This pin toggles the display among the read or writes operation, and it is connected to a microcontroller unit pin to get either 0 or 1 (0 = Write Operation, and 1 = Read Operation). Pin 6 (Enable/Control Pin): This pin should be held high to execute Read/Write process, and it is connected to the microcontroller unit & constantly held high. Pins 7-14 (Data Pins): These pins are used to send data to the display. These pins are connected in two-wire modes like 4-wire mode and 8-wire mode. In 4-wire mode, only four pins are connected to the microcontroller unit like 0 to 3, whereas in 8-wire mode, 8-pins are connected to microcontroller unit like 0 to 7. Pin15 (+ve pin of the LED): This pin is connected to +5V Pin 16 (-ve pin of the LED): This pin is connected to GND. LCD-16×2-pin-diagram Features of LCD16x2 The features of this LCD mainly include the following. The operating voltage of this LCD is 4.7V-5.3V It includes two rows where each row can produce 16-characters. The utilization of current is 1mA with no backlight Every character can be built with a 5×8 pixel box The alphanumeric LCDs alphabets & numbers Is display can work on two modes like 4-bit & 8-bit These are obtainable in Blue & Green Backlight It displays a few custom generated characters Registers of LCD A 16×2 LCD has two registers like data register and command register. The RS (register select) is mainly used to change from one register to another. When the register set is ‘0’, then it is known as command register. Similarly, when the register set is ‘1’, then it is known as data register. Command Register The main function of the command register is to store the instructions of command which are given to the display. So that predefined tasks can be performed such as clearing the display, initializing, set the cursor place, and display control. Here commands processing can occur within the register. Data Register The main function of the data register is to store the information which is to be exhibited on the LCD screen. Here, the ASCII value of the character is the information which is to be exhibited on the screen of LCD. Whenever we send the information to LCD, it transmits to the data register, and then the process will be starting there. When register set =1, then the data register will be selected. 16×2 LCD Commands The commands of LCD 16X2 include the following. For Hex Code-01, the LCD command will be the clear LCD screen For Hex Code-02, the LCD command will be returning home For Hex Code-04, the LCD command will be decrement cursor For Hex Code-06, the LCD command will be Increment cursor For Hex Code-05, the LCD command will be Shift display right For Hex Code-07, the LCD command will be Shift display left For Hex Code-08, the LCD command will be Display off, cursor off For Hex Code-0A, the LCD command will be cursor on and display off For Hex Code-0C, the LCD command will be cursor off, display on For Hex Code-0E, the LCD command will be cursor blinking, Display on For Hex Code-0F, the LCD command will be cursor blinking, Display on For Hex Code-10, the LCD command will be Shift cursor position to left For Hex Code-14, the LCD command will be Shift cursor position to the right For Hex Code-18, the LCD command will be Shift the entire display to the left For Hex Code-1C, the LCD command will be Shift the entire display to the right For Hex Code-80, the LCD command will be Force cursor to the beginning ( 1st line) For Hex Code-C0, the LCD command will be Force cursor to the beginning ( 2nd line) For Hex Code-38, the LCD command will be 2 lines and 5×7 matrix LCD 16×2 Arduino Please refer to this link to know more about-How to Interface Liquid Crystal Display using An Arduino. Thus, this is all about LCD 16×2 datasheet, which includes what is a 16X2 LCD, pin configuration, working principle, and its applications. The main advantages of this LCD device include power consumption is less and low cost. The main disadvantages of this LCD device include it occupies a large area, slow devices and also lifespan of these devices will be reduced due to direct current. So these LCDs use AC supply with less than 500Hz frequency. Here is a question for you, what are the applications of LCD? Share This Post: Facebook Twitter Google+ LinkedIn Pinterest Post navigation ‹ Previous Automotive Electronics and Its InnovationsNext › IoT Sensor Working and Its Applications Related Content Magnetic Materials : Properties, Working, Types, Differences & Their Applications Light-Activated Switch with MOSFET Motor Speed Control with MOSFET Synchronous Condenser : Design, Working, Phasor Diagram & Its Applications
Tổng quan LCD 16×2 và giao tiếp I2C LCD sử dụng Arduino
Các lỗi thường gặp khi sử dụng I2C LCD
- Hiển thị một dãy ô vuông.
- Màn hình chỉ in ra một ký tự đầu.
- Màn hình nhấp nháy.
Các lỗi này chủ yếu là do sai địa chỉ bus, để fix lỗi các bạn thay địa chỉ mặc định là “0x27” thành “0x3F.
Trong trường hợp vẫn không được các bạn fix lỗi bằng cách nạp code tìm địa chỉ bus của I2C.
Sau khi tìm xong các bạn thay địa chỉ vừa tìm được vào vị trí “0x27” là xong.
- Các bạn có thể tải code tìm địa chỉ bus ở đây. Tải ngay.
Liquid Crystal Displays (LCD) with Arduino
Find out how to wire an LCD to an Arduino, and how to use the LiquidCrystal library through a set of useful examples.
This article was revised on 2021/11/18 by Karl Söderby.
The LiquidCrystal library allows you to control LCD displays that are compatible with the Hitachi HD44780 driver. There are many of them out there, and you can usually tell them by the 16-pin interface.
The LCDs have a parallel interface, meaning that the microcontroller has to manipulate several interface pins at once to control the display. The interface consists of the following pins:
- A register select (RS) pin that controls where in the LCD’s memory you’re writing data to. You can select either the data register, which holds what goes on the screen, or an instruction register, which is where the LCD’s controller looks for instructions on what to do next.
- A Read/Write (R/W) pin that selects reading mode or writing mode
- An Enable pin that enables writing to the registers
- 8 data pins (D0 -D7). The states of these pins (high or low) are the bits that you’re writing to a register when you write, or the values you’re reading when you read.
There’s also a display contrast pin (Vo), power supply pins (+5V and GND) and LED Backlight (Bklt+ and BKlt-) pins that you can use to power the LCD, control the display contrast, and turn on and off the LED backlight, respectively.
The process of controlling the display involves putting the data that form the image of what you want to display into the data registers, then putting instructions in the instruction register. The LiquidCrystal Library simplifies this for you so you don’t need to know the low-level instructions.
The Hitachi-compatible LCDs can be controlled in two modes: 4-bit or 8-bit. The 4-bit mode requires seven I/O pins from the Arduino, while the 8-bit mode requires 11 pins. For displaying text on the screen, you can do most everything in 4-bit mode, so example shows how to control a 16×2 LCD in 4-bit mode.
Keywords searched by users: liquid crystal display 16×2
Categories: Tóm tắt 57 Liquid Crystal Display 16X2
See more here: kientrucannam.vn
See more: https://kientrucannam.vn/vn/