LCD (Liquid Crystal Display) is usually used as a simple
display output on a microcontroller system. An LCD can display alphanumeric
characters, different from the seven segments, which only displays numeric
characters only (limited characters). One of LCD’s advantages is programmable
to display any characters, so LCD is worth considering in your electronics
project.
In the market, the most widely available and most affordable
is a LCD 16x2 which means there is a 2 row display there are 16 columns for
display 16 characters per line. So totally there are 32 characters can be displayed
in LCD 16x2.
Displays Hello World in LCD 16x2 Experiment Using Arduino
In preparation, please wiring prototype circuit as follows. If you
buy a LCD 16x2, you need a bit of soldering parts pinout that will be connected
to an Arduino or protoboard.
LCD - Arduino Prototype Circuit:
Materials:
- Arduino Uno + USB cable type B
- LCD 16x2
- potentiometer/trimmer 10K
- resistor 10k
- jumper cabe male to male
- protoboard
- LCD 16x2
- potentiometer/trimmer 10K
- resistor 10k
- jumper cabe male to male
- protoboard
LCD - Arduino Wiring Connections:
LCD 16 x 2 Pin
|
Arduino Pin
|
RS
|
12
|
Enable (E)
|
11
|
D4
|
5
|
D5
|
4
|
D6
|
3
|
D7
|
2
|
R/W
|
GND
|
VSS
|
GND
|
Vcc
|
5V
|
V0 =>potensiometer/trimmer
|
LCD - Arduino Sketch Handler
After wiring of hardware is complete, upload Arduino sketch
as follows:
#include <LiquidCrystal.h> LiquidCrystal lcd(12, 11, 5, 4, 3, 2); void setup() { lcd.begin(16, 2); lcd.print("hello, world!"); } void loop() { lcd.setCursor(0, 1); lcd.print(millis() / 1000); }
The essence of the sketch above is located in the 'LiquidCrystal.h'
library. This is a built in library from official Arduino IDE (Integrated
Development Environment), so you can use it immediately. If you are already
declaring this library, you will have an object named 'lcd' that has some
methods to handle your LCD hardware easier. Examples of the method can be
called are:
lcd.begin (row, column); => To initialize LCD appropriate
type (if you’re using LCD 16x2 for example, then the command is lcd.begin
(16,2);
lcd.print (character); => To display characters on the
LCD. Parameter 'character' must be on ‘string’ type
lcd.setCursor (row, column); => Set the location of the
characters to be displayed based on the coordinates (row, column).
After you upload the sketch above, then watch the LCD
display. Are there any characters display 'hello world'? If not, don’t worry,
maybe you need to adjust the brightness of character with twisting
potentiometer/trimmer connected to pin Vo. If now displayed, congratulations,
you've managed to display characters on the LCD 16x2 from Arduino. Easy enough,
right? With the 'LiquidCrystal' library of Arduino, it makes everything so much
easier. You do not need to set one by one LCD memory address and fill it with
characters that will be displayed. In the next article I will explain in more
detail about how interfacing Arduino with LCD and how to handle it using Arduino sketch.
ConversionConversion EmoticonEmoticon