LCD(Liquid Crystal Display) En: 두 판 사이의 차이

아두위키 : Arduwiki
잔글 (ArduWiki님이 LCD1602 en 문서를 넘겨주기를 만들지 않고 LCD(Liquid Crystal Display) En 문서로 이동했습니다: 철자가 잘못된 제목)
잔글편집 요약 없음
1번째 줄: 1번째 줄:
[[File:1602LCDimg1.jpg|center|class=coders70]]
{{#seo:|title=Arduwiki : Arduino LCD Guide|title_mode=append|keywords=Arduino, Information Science, Maker Learning, Performance Assessment, Buzzer, Arduino Project, Capstone Project, Arduino Example Code|description=This introduces how to control a LCD with Arduino (basic information, circuit, example code). It can be used in Information Science and Maker classes.}}
[[File:1602LCDimg2.jpg|center|class=coders70]]It's a module for controlling a 16x2 LCD with just four wires via I2C communication.  


The I2C address is mostly [0x27], but there are occasional exceptions, so it's recommended to check the address before use.
[[파일:1602LCDimg1.jpg|class=coders100]]
[[파일:1602LCDimg2.jpg|class=coders100]]


== Specifications and Required Hardware ==
The Arduino LCD module is used to display characters or numbers, with 16x2 or 20x4 sized LCD displays being commonly used. This document covers LCDs that support I2C communication. Using the I2C interface instead of a typical parallel interface reduces the number of pins required and simplifies wiring. It can be easily connected to an Arduino board to visually represent information in various projects.


* Operating Voltage: 5V
== '''Main Specifications''' ==
* 16x2 LCD I2C MODULE
* Arduino UNO
* UNO Cable
* F-M Cable (4ea)


== Libraries ==
'''Display Size''': Commonly used sizes are 16x2 and 20x4.
'''Power Supply Range''': 5V (supplied directly from the Arduino board)
'''Interface''': I2C (SDA, SCL)
'''Character Set''': Supports ASCII character set
'''I2C Address''': Default is 0x27 or 0x3F (varies by module)
== '''Features''' ==


* Wire (No need to install as it's a default library.)
'''Character Display''': Can display alphabets, numbers, and special characters. For shapes or graphics, the capability is very limited, and graphic LCDs or OLEDs are more suitable.
* LiquidCrystal I2C
'''Backlight Control''': The backlight can be turned on and off, and brightness can be adjusted.
'''Cursor Control''': The cursor position can be moved or hidden using setCursor().
'''Scroll Function''': Text can scroll left and right.
There is a variable resistor on the back for adjusting the brightness of the text.


== Connections ==
[[파일:LCD1602 가변저항.png|class=coders50]]
 
 
== '''Usage Examples''' ==
 
=== '''Library''' ===
 
Wire (This is a basic library, so no installation is needed.)
*LiquidCrystal I2C : [https://arduwiki.com/wiki/아두이노_라이브러리 라이브러리 설치방법] Check the installation method through the link.
 
 
=== '''연결''' ===
It is the same regardless of size (16x2, 20x4).
{| class="wikitable"
{| class="wikitable"
|+
!I2C LCD Module Pin
!'''I2C LCD'''
!Arduino Uno Pin
!'''Arduino UNO'''
|-
|VCC
|5V
|-
|-
|GND
|GND
|GND
|GND
|-
|VCC
|5V
|-
|-
|SDA
|SDA
35번째 줄: 50번째 줄:
|A5
|A5
|}
|}
[[File:LCD1602 회로.png|center|class=coders100]]
[[파일:LCD1602 회로.png|class=coders100]]


== How to Check the Address ==
 
You can verify the address by uploading the following code and then running the Serial Monitor.<syntaxhighlight lang="cpp" line="1">
=== '''1. Checking the Module Address''' ===
 
==== 1-1. Code ====
<syntaxhighlight lang="c++" line="1">
#include <Wire.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16, 2);
 
void setup()
void setup()
{   
{
   // Initialize the LCD before use.
  Wire.begin();
   lcd.init();
  Serial.begin(9600);
  Serial.println("\nI2C Scanner");
}
   
void loop()
{
   byte error, address;
  int nDevices;
  Serial.println("Scanning...");
  nDevices = 0;
  for(address = 1; address < 127; address++ )
  {
    Wire.beginTransmission(address);
    error = Wire.endTransmission();
    if (error == 0)
    {
      Serial.print("I2C device found at address 0x");
      if (address<16)
        Serial.print("0");
      Serial.print(address,HEX);
      Serial.println("  !");
      nDevices++;
    }
    else if (error==4)
    {
      Serial.print("Unknow error at address 0x");
      if (address<16)
        Serial.print("0");
      Serial.println(address,HEX);
    }   
  }
  if (nDevices == 0)
    Serial.println("No I2C devices found\n");
   else
    Serial.println("done\n");
  delay(5000);        
}
</syntaxhighlight>


  // Turn on the LCD backlight.
===== 1-2. Execution Result =====
  lcd.backlight();
[[파일:LCD1602 주소 확인.png|class=coders100]]
 
  // Set the LCD cursor position to (0,0) (top left corner).
  lcd.setCursor(0, 0);


  // Write the text to display.
  lcd.print("Gongzipsa");


  // Move the LCD cursor to position (0,1).
==== 2. Displaying Text on the LCD ====
  lcd.setCursor(0, 1);


  // Print the value of val.
==== 2-2. Code ====
  int val = 1004;
<syntaxhighlight lang="c++" line="1">
  lcd.print(val);
}
 
void loop(){}
</syntaxhighlight>
[[File:LCD1602 주소 확인.png|center|class=coders100]]
 
== Example Code ==
<syntaxhighlight lang="cpp" line="1">
#include <Wire.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <LiquidCrystal_I2C.h>
77번째 줄: 115번째 줄:
void setup()
void setup()
{   
{   
   // Initialize the LCD before use.
   // Initialize the LCD before use
   lcd.init();
   lcd.init();


   // Turn on the LCD backlight.
   // Turn on the LCD's backlight
   lcd.backlight();
   lcd.backlight();
 
 
   // Set the LCD cursor position to (0,0) (top left corner).
   // Set the cursor position to (0,0) (top-left corner)
   lcd.setCursor(0, 0);
   lcd.setCursor(0, 0);


   // Write the text to display.
   // Write the text to be displayed
   lcd.print("Gongzipsa");
   lcd.print("Gongzipsa");


   // Move the LCD cursor to position (0,1).
   // Set the cursor position to (0,1)
   lcd.setCursor(0, 1);
   lcd.setCursor(0, 1);


   // Print the value of val.
   // Output the val value
   int val = 1004;
   int val = 1004;
   lcd.print(val);
   lcd.print(val);
98번째 줄: 136번째 줄:


void loop(){}
void loop(){}
</syntaxhighlight>
==== 2-2. Execution Result[[파일:LCD1602 예제.jpg|class=coders100]] ====


</syntaxhighlight>
== '''Reference Document''' ==
[https://docs.arduino.cc/learn/electronics/lcd-displays/ 아두이노 LCD Doc]


=== Example Code Result: ===
[[File:LCD1602 예제.jpg|center|class=coders100]]


== '''Additional Information''' ==
== '''Purchase Link''' ==
The brightness of the LCD text can be adjusted by controlling the variable resistor.
[https://gongzipsa.com/shop/search.php?q=lcd GONGZIPSA]
[[File:LCD1602 가변저항.png|center|class=coders50]]

2024년 8월 9일 (금) 10:52 판


The Arduino LCD module is used to display characters or numbers, with 16x2 or 20x4 sized LCD displays being commonly used. This document covers LCDs that support I2C communication. Using the I2C interface instead of a typical parallel interface reduces the number of pins required and simplifies wiring. It can be easily connected to an Arduino board to visually represent information in various projects.

Main Specifications

Display Size: Commonly used sizes are 16x2 and 20x4. Power Supply Range: 5V (supplied directly from the Arduino board) Interface: I2C (SDA, SCL) Character Set: Supports ASCII character set I2C Address: Default is 0x27 or 0x3F (varies by module)

Features

Character Display: Can display alphabets, numbers, and special characters. For shapes or graphics, the capability is very limited, and graphic LCDs or OLEDs are more suitable. Backlight Control: The backlight can be turned on and off, and brightness can be adjusted. Cursor Control: The cursor position can be moved or hidden using setCursor(). Scroll Function: Text can scroll left and right. There is a variable resistor on the back for adjusting the brightness of the text.


Usage Examples

Library

Wire (This is a basic library, so no installation is needed.)


연결

It is the same regardless of size (16x2, 20x4).

I2C LCD Module Pin Arduino Uno Pin
VCC 5V
GND GND
SDA A4
SCL A5


1. Checking the Module Address

1-1. Code

#include <Wire.h>
 
void setup()
{
  Wire.begin();
  Serial.begin(9600);
  Serial.println("\nI2C Scanner");
}
 
void loop()
{
  byte error, address;
  int nDevices;
  Serial.println("Scanning...");
  nDevices = 0;
  for(address = 1; address < 127; address++ ) 
  {
    Wire.beginTransmission(address);
    error = Wire.endTransmission();
    if (error == 0)
    {
      Serial.print("I2C device found at address 0x");
      if (address<16) 
        Serial.print("0");
      Serial.print(address,HEX);
      Serial.println("  !");
      nDevices++;
    }
    else if (error==4) 
    {
      Serial.print("Unknow error at address 0x");
      if (address<16) 
        Serial.print("0");
      Serial.println(address,HEX);
    }    
  }
  if (nDevices == 0)
    Serial.println("No I2C devices found\n");
  else
    Serial.println("done\n");
  delay(5000);          
}
1-2. Execution Result


2. Displaying Text on the LCD

2-2. Code

#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16, 2);

void setup()
{  
  // Initialize the LCD before use
  lcd.init();

  // Turn on the LCD's backlight
  lcd.backlight();

  // Set the cursor position to (0,0) (top-left corner)
  lcd.setCursor(0, 0);

  // Write the text to be displayed
  lcd.print("Gongzipsa");

  // Set the cursor position to (0,1)
  lcd.setCursor(0, 1);

  // Output the val value
  int val = 1004;
  lcd.print(val);
}

void loop(){}


2-2. Execution Result

Reference Document

아두이노 LCD Doc


Purchase Link

GONGZIPSA