Arduino projects: Arduino lcd display

We have used LCD displays in the previous posts with the I2C, but it is possible to use it without an I2C. Let’s see how this is done.

We will take the advantage to visit some of the useful function you can make use of when working with LCDs.

Using the Arduino serial LCD module

 

Here are the parts we will need

  • 1 x Arduino Uno board
  • 1 x LCD display (We use a 20 x 4 display, but any will do)
  • 1 x Breadboard
  • Jumper wires
  • 1 x Potentiometer 10k

Follow the sketch below to connect the part together. Make sure the connections are right before powering up the project. A bad connection can easily damage the LCD.

There are 4 pins of the LCD we are not using, those pins are used to read data coming from the LCD which is not needed for this project. We are only using the LCD to write on, nothing more.

The Potentiometer is used to control the contrast of the LCD. In some case, you might need to rotate the potentiometer handle to see anything appearing on the LCD.

The last 2 pins of the LCD are used to light the LCD’s LED. You will need to connect them one pin to 5V and the other to Ground.

When you are done connecting everything, you can upload the following code to the Arduino. But before doing that you need to add the Adafruit_LiquidCrystal.h to your code. To do so, simply navigate to the library manager, search for LCD and it will be right there. Click on it to add it.

The major functions used here are clear, print, setCursor. These are really easy to use and self-explanatory.

#include "Wire.h"
#include "Adafruit_LiquidCrystal.h"

// those are default pins for LCD, you can change them but most examples and codes on the internet use those.
Adafruit_LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

void setup() {
// if you have 16x2 LCD just change 20 to 16 and 4 to 2
lcd.begin(20, 4);
}

void loop() {
lcd.clear();
//with setCursor we can move "cursor" to the position that we want
//the first number is character number in my case from 0 to 19
//second number is line in my case from 0 to 3
//after set cursor we can call print and text will be printed in place that we want
lcd.setCursor(0, 0);
lcd.print("HI! Nice to see you");
delay(2000);
lcd.setCursor(0, 1);
lcd.print("We're tutorial45.com");
delay(2000);
lcd.setCursor(0, 2);
lcd.print("We want to show you");
delay(1000);
lcd.setCursor(0, 3);
lcd.print("How to use this lcd");
delay(3000);
//with clear we can delate everything from LCD
lcd.clear();

lcd.setCursor(0, 0);
lcd.print("Ohh.. wait");
delay(2000);
lcd.setCursor(0, 1);
lcd.print("We've just shown it");
delay(2000);
lcd.setCursor(0, 2);
lcd.print("So thx for watching!");
delay(2000);
lcd.setCursor(0, 3);
lcd.print("Have a nice day! Bye");
delay(3000);
}

That’s it for this session. Here are other projects where we made good use of the serial LCD module.

tchouken2

Related Posts