Difference between revisions of "LCD1602 Module"

From Wiki
Jump to: navigation, search
(delete)
Line 1: Line 1:
 
==Introduction==
 
==Introduction==
 +
 +
 +
 
LCD1602, or 1602 character-type liquid crystal display, is a kind of dot matrix module to show letters, numbers, and characters and so on. It's composed of 5x7 or 5x11 dot matrix positions; each position can display one character. There's a dot pitch between two characters and a space between lines, thus separating characters and lines. The number 1602 means on the display, 2 rows can be showed and 16 characters in each.<br>
 
LCD1602, or 1602 character-type liquid crystal display, is a kind of dot matrix module to show letters, numbers, and characters and so on. It's composed of 5x7 or 5x11 dot matrix positions; each position can display one character. There's a dot pitch between two characters and a space between lines, thus separating characters and lines. The number 1602 means on the display, 2 rows can be showed and 16 characters in each.<br>
 
Generally, LCD1602 has parallel ports, that is, it would control several pins at the same time. LCD1602 can be categorized into eight-port and four-port connections. If the eight-port connection is used, then all the digital ports of the SunFounder Uno board are almost completely occupied. If you want to connect more sensors, there will be no ports available. Therefore, the four-port connection is used here for better application.<br>
 
Generally, LCD1602 has parallel ports, that is, it would control several pins at the same time. LCD1602 can be categorized into eight-port and four-port connections. If the eight-port connection is used, then all the digital ports of the SunFounder Uno board are almost completely occupied. If you want to connect more sensors, there will be no ports available. Therefore, the four-port connection is used here for better application.<br>
  
[[File:1-1.jpg]]<br>
+
==Pins of LCD1602 and their functions==
  
===Pins of LCD1602 and their functions===
+
 
VSS: connected to ground<br>
+
 
VDD: connected to a +5V power supply<br>
+
==The Experiment for Arduino==
VO: to adjust the contrast<br>
+
'''<font color="green">Components</font><br>
RS: A register select pin that controls where in the LCD’s memory you are 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.<br>
+
R/W: A Read/Write pin to select between reading and writing mode<br>
+
E: An enabling pin that reads the information when High level (1) is received. The instructions are run when the signal changes from High level to Low level. <br>
+
D0-D7: to read and write data<br>
+
A and K: Pins that control the LCD backlight. Connect K to GND and A to 3.3v. Open the backlight and you will see clear characters in a comparatively dark environment. <br>
+
==Components==
+
 
- 1 * SunFounder Uno board<br>
 
- 1 * SunFounder Uno board<br>
 
- 1 * Breadboard<br>
 
- 1 * Breadboard<br>
Line 21: Line 18:
 
- 1 * USB cable<br>
 
- 1 * USB cable<br>
 
- Jumper wires<br>
 
- Jumper wires<br>
==Experimental Principle==
 
  
[[File:5-5.png]]<br>
+
'''<font color="green">Experimental Procedures</font><br>
 +
<font color="red">Note: before connecting circuit, need to plug the pin headers onto a breadboard, and then put the LCD1602 on to it for easy soldering.</font><br>
  
Connect K to GND and A to 3.3 V, and then the backlight of the LCD1602 will be turned on. Connect VSS to GND and the LCD1602 to the power source. Connect VO to the middle pin of the potentiometer – with it you can adjust the contrast of the screen display. Connect RS to D4 and R/W pin to GND, which means then you can write characters to the LCD1602.  Connect E to pin6 and the characters displayed on the LCD1602 are controlled by D4-D7. For programming, it is optimized by calling function libraries.<br>
 
==Experimental Procedures==
 
''<font color="red">Note:</font> before connecting circuit, need to plug the pin headers onto a breadboard, and then put the LCD1602 on to it for easy soldering.''<br>
 
  
[[File:2-2.jpg]]<br>
 
  
Step 1: Build the circuit (make sure the pins are connected correctly. Otherwise, characters will not be displayed properly):<br>
+
'''Step 1:''' Build the circuit (make sure the pins are connected correctly. Otherwise, characters will not be displayed properly):<br>
  
[[File:3-3.png]]<br>
 
  
Step 2: Copy the follwing code to the Arduino IDE ,click to the upload icon to upload the code to the control board.<br>
+
 
 +
'''Step 2:''' Download the package [http://wiki.sunfounder.cc/images/b/b2/LCD1602_for_Arduino.rar  LCD1602_for_Arduino], then unzip it and open the LCD1602.ino File
 +
 
 +
 
 +
 
 +
'''Step 3:''' Select correct Board and Port
 +
'''Step 4:''' Upload the sketch to the SunFounder Uno board
 +
 
 +
'''<font color="green">Experimental phenomenon</font><br>
 +
<font color="red">Note: you may need to adjust the potentiometer on the LCD1602 until it can display clearly.</font><br>
 +
You should now see the characters "SunFounder" and "hello, world! " rolling on the LCD.<br>
 +
 
 +
 
 +
 
 +
==The Experiment for Raspberry Pi==
 +
'''<font color="green">Components</font><br>
 +
- 1 * Raspberry Pi
 +
- 1 * Breadboard
 +
- 1 * LCD1602
 +
- 1 * Potentiometer
 +
- Jumper wires
 +
 
 +
'''<font color="green">Experimental Procedures</font><br>
 +
'''Step 1:''' Build the circuit (please be sure the pins are connected correctly. Otherwise, characters will not be displayed properly):<br>
 +
 
 +
 
 +
 
 +
<font color="red">Note: After you run the code, characters may not appear on the LCD1602. You need to adjust the contrast of the screen (the gradual change from black to white) by spinning the potentiometer clockwise or anticlockwise, until the screen displays characters clearly.</font><br>
 +
 
 +
'''Step 2:''' Transfer the package [http://wiki.sunfounder.cc/images/8/87/LCD1602_for_Raspberry_Pi.zip  LCD1602_for_Raspberry_Pi] to the Raspberry Pi<br>
 
<pre>
 
<pre>
 +
wget http://wiki.sunfounder.cc/images/8/87/LCD1602_for_Raspberry_Pi.zip
 +
</pre>
  
//LCD1602
+
'''Step 3:''' Extract the package<br>
//You should now see your LCD1602 display the flowing characters "SUNFOUNDER" and "hello, world"
+
<pre>
//Email:support@sunfounder.com
+
unzip LCD1602_for_Raspberry_Pi.zip
//Website:www.sunfounder.com
+
</pre>
#include <LiquidCrystal.h>// include the library code
+
/**********************************************************/
+
char array1[]=" SunFounder              ";  //the string to print on the LCD
+
char array2[]="hello, world!            ";  //the string to print on the LCD
+
int tim = 250;  //the value of delay time
+
// initialize the library with the numbers of the interface pins
+
LiquidCrystal lcd(4, 6, 10, 11, 12, 13);
+
/*********************************************************/
+
void setup()
+
{
+
  lcd.begin(16, 2);  // set up the LCD's number of columns and rows:
+
}
+
/*********************************************************/
+
void loop()
+
{
+
    lcd.setCursor(15,0);  // set the cursor to column 15, line 0
+
    for ( int positionCounter1 = 0; positionCounter1 < 26; positionCounter1++)
+
    {
+
      lcd.scrollDisplayLeft();  //Scrolls the contents of the display one space to the left.
+
      lcd.print(array1[positionCounter1]);  // Print a message to the LCD.
+
      delay(tim);  //wait for 250 microseconds
+
    }
+
    lcd.clear();  //Clears the LCD screen and positions the cursor in the upper-left corner.
+
    lcd.setCursor(15,1);  // set the cursor to column 15, line 1
+
    for (int positionCounter2 = 0; positionCounter2 < 26; positionCounter2++)
+
    {
+
      lcd.scrollDisplayLeft();  //Scrolls the contents of the display one space to the left.
+
      lcd.print(array2[positionCounter2]);  // Print a message to the LCD.
+
      delay(tim);  //wait for 250 microseconds
+
    }
+
    lcd.clear();  //Clears the LCD screen and positions the cursor in the upper-left corner.
+
}
+
/************************************************************/
+
  
 +
'''<font color="orange">(For C language users)</font><br>
 +
'''Step 4:''' Get into the folder of code<br>
 +
<pre>
 +
cd LCD1602_for_Raspberry_Pi/C
 
</pre>
 
</pre>
Step 3: Select correct Board and Port<br>
 
Step 4: Upload the sketch to the SunFounder Uno board<br>
 
''<font color="red">Note:</font> you may need to adjust the potentiometer on the LCD1602 until it can display clearly.''<br>
 
==Experimental Phenomenon==
 
You should now see the characters "SunFounder" and "hello, world" rolling on the LCD.<br>
 
  
[[File:4-4.jpg]]<br>
+
'''Step 5:''' Compile<br>
 +
<pre>
 +
gcc lcd1602.c –o lcd1602 –lwiringPiDev –lwiringPi
 +
</pre>
 +
 
 +
'''Step 6:''' Run<br>
 +
<pre>
 +
sudo ./lcd1602
 +
</pre>
 +
 
 +
'''<font color="orange">(For Python users)</font><br>
 +
'''Step 4:''' Get into the folder of code<br>
 +
<pre>
 +
cd LCD1602_for_Raspberry_Pi/Python
 +
</pre>
 +
 
 +
'''Step 5:''' Run<br> 
 +
<pre>
 +
sudo python lcd1602.py
 +
</pre>
 +
 
 +
'''<font color="green">Experimental Phenomenon</font><br>
 +
You should see two lines of characters displayed on the LCD1602: “hello, world! ” , “SunFounder”.<br>
 +
 +
 
  
 
==Resource==
 
==Resource==
 
[http://wiki.sunfounder.cc/images/b/b2/LCD1602_for_Arduino.rar  LCD1602_for_Arduino][[File:ZIP.jpg]]<br>
 
[http://wiki.sunfounder.cc/images/b/b2/LCD1602_for_Arduino.rar  LCD1602_for_Arduino][[File:ZIP.jpg]]<br>
 
[http://wiki.sunfounder.cc/images/8/87/LCD1602_for_Raspberry_Pi.zip  LCD1602_for_Raspberry_Pi][[File:ZIP.jpg]]<br>
 
[http://wiki.sunfounder.cc/images/8/87/LCD1602_for_Raspberry_Pi.zip  LCD1602_for_Raspberry_Pi][[File:ZIP.jpg]]<br>

Revision as of 02:56, 12 June 2017

Introduction

LCD1602, or 1602 character-type liquid crystal display, is a kind of dot matrix module to show letters, numbers, and characters and so on. It's composed of 5x7 or 5x11 dot matrix positions; each position can display one character. There's a dot pitch between two characters and a space between lines, thus separating characters and lines. The number 1602 means on the display, 2 rows can be showed and 16 characters in each.
Generally, LCD1602 has parallel ports, that is, it would control several pins at the same time. LCD1602 can be categorized into eight-port and four-port connections. If the eight-port connection is used, then all the digital ports of the SunFounder Uno board are almost completely occupied. If you want to connect more sensors, there will be no ports available. Therefore, the four-port connection is used here for better application.

Pins of LCD1602 and their functions

The Experiment for Arduino

Components
- 1 * SunFounder Uno board
- 1 * Breadboard
- 1 * LCD1602
- 1 * Potentiometer (50kΩ)
- 1 * USB cable
- Jumper wires

Experimental Procedures
Note: before connecting circuit, need to plug the pin headers onto a breadboard, and then put the LCD1602 on to it for easy soldering.


Step 1: Build the circuit (make sure the pins are connected correctly. Otherwise, characters will not be displayed properly):


Step 2: Download the package LCD1602_for_Arduino, then unzip it and open the LCD1602.ino File


Step 3: Select correct Board and Port Step 4: Upload the sketch to the SunFounder Uno board

Experimental phenomenon
Note: you may need to adjust the potentiometer on the LCD1602 until it can display clearly.
You should now see the characters "SunFounder" and "hello, world! " rolling on the LCD.


The Experiment for Raspberry Pi

Components
- 1 * Raspberry Pi - 1 * Breadboard - 1 * LCD1602 - 1 * Potentiometer - Jumper wires

Experimental Procedures
Step 1: Build the circuit (please be sure the pins are connected correctly. Otherwise, characters will not be displayed properly):


Note: After you run the code, characters may not appear on the LCD1602. You need to adjust the contrast of the screen (the gradual change from black to white) by spinning the potentiometer clockwise or anticlockwise, until the screen displays characters clearly.

Step 2: Transfer the package LCD1602_for_Raspberry_Pi to the Raspberry Pi

wget http://wiki.sunfounder.cc/images/8/87/LCD1602_for_Raspberry_Pi.zip

Step 3: Extract the package

unzip LCD1602_for_Raspberry_Pi.zip

(For C language users)
Step 4: Get into the folder of code

cd LCD1602_for_Raspberry_Pi/C

Step 5: Compile

gcc lcd1602.c –o lcd1602 –lwiringPiDev –lwiringPi

Step 6: Run

sudo ./lcd1602

(For Python users)
Step 4: Get into the folder of code

cd LCD1602_for_Raspberry_Pi/Python

Step 5: Run

sudo python lcd1602.py

Experimental Phenomenon
You should see two lines of characters displayed on the LCD1602: “hello, world! ” , “SunFounder”.


Resource

LCD1602_for_ArduinoZIP.jpg
LCD1602_for_Raspberry_PiZIP.jpg