How to use: LCD 16x2

Are you a starter with Croduino? Or a newbie when it comes to electronics? You fancy a specific module, but you don't know how to use it? Don't worry, we have our How To Use series!

How to Use is a series of blog tutorials by e-radionica where you will find everything you need to begin working with your favorite modules. Tutorials include technical characteristics, operating principles, instructions on how to connect the module with Croduino and basic coding. Everything else is up to you and your imagination.

Basic characteristics

LCD ( Liquid Crystal Display) is probably one of the most used modules because it is truly useful. It allows you to get any kind of information on an easy-to-read LCD screen. The LCD in our offer has a blue backlight with white lettering. Both LCDs, 16x2 and 20x4, have identical pin assignment and this tutorial is universal for both. Also, the IIC adapter will work with both LCDs.

DSC_8573

  • •Size: 16 characters in 2 rows (16x2) or 20 characters in 4 rows (20x4)
  • •Voltage: 5V
  • •Display size: 64.5 x 16 mm(for 16x2)
  • •Size of module: 80 x 36 x 12 mm(for 16x2)
  • •Character colour: white
  • •Background colour: blue

Module working principle

Explaining how LCD works cannot be done in only few sentences. It is based on liquid crystals (which, suprisingly, are discovered in 199th century). Each liquid crystal creates one pixel. These are located between two polarizers and they are rotating the light. When a certain voltage faces them, they are correcting themselves and polarization doesn't rotate the light and passes towards our eye. As a result, we can see active pixels. For all those interested in more details regarding the working principle of LCDs, we suggest an article on Wikipedia.

In this tutorial we will use:

  • •Croduino Basic2
  • •LCD 16x2
  • •Potentiometer 10K
  • •Breadboard
  • •Breadboard cables

How to connect module with Croduino (without IIC adapter)

Establish a connection using a table above or schematic below - whatever you like more :)

lcd

How to connect module with Croduino (with IIC adapter)

Before connecting, IIC adapter must be soldered on the LCD screen. Insert the adapter from the back of the LCD pins and solder them. The result should be something like the picture below.

It is time to connect the adapter with Croduino! Fortunately, the connection is now simplified and it requires only 2 communication pins and 2 power pins. Follow the table below or connection schematic.

lcdiic

Code for module

Arduino IDE comes with a LiquidCrystal library that works great but it will only work in the first variant of the connection when the IIC adapter is not used. Therefore, we recommend that you download our custom LiquidCrystal library that works for both connectivity methods. A direct downloading link is here.

IMPORTANT: In the folder where your libraries are, delete the LiquidCrystal folder and copy the downloaded file. Make sure it has the same name.

In a few words we will explain the most important functions of this library. They are already described in the examples of the library and are generally the same as for the LiquidCrystal library:
• lcd.print(); - prints something on LCD. If there is a variable in brackets, a content of the brackets will be shown on the LCD.
• lcd.setCursor(x,y); - sets a cursor (e.g. like one in Word) to a specific position. First coordinate (x) determines the position from left to right (e.g. 0 would be the first character), while second coordinate determines the position from top to bottom (e.g. 0 would be the first row, 1 would be the second row). Example of use: lcd.setCursor(0,1); - sets the cursor to the beginning of the second row. Now we can use lcd.print (); to print something in the second row.
• lcd.clear(); - removes everything what is printed on the LCD
• lcd.home(); - goes with the cursor to the beginning (0,0), but does not clear the screen! (does not work the same as lcd.clear ();)
 lcd.backlight(); - Turns on backlighting
• lcd.noBacklight(); - Turns off backlighting

Download e-radionica LiquidCrystal library with examples.

Leave a Reply