Tuesday, July 21, 2020

How to connect 16*2 LCD Display Module to Arduino UNO (Method 1) - Arduino Tutorials #14

In this post, I will show you how to connect the 16*2 LCD Display Module to an Arduino UNO.

If you prefer video mode you can click here to watch it on YouTube.

First, connect the circuit according to the circuit diagram shared below


Next, connect the circuit to a Laptop or a Desktop and open your Arduino IDE


Next, install the library "LiquidCrystal" if it is not installed and upload the sketch "HelloWorld" which is under File > Examples > LiquidCrystal to test the circuit. 
    
After uploading if you don't see any character displayed adjust the brightness using the trimmer until you get the display



Sketch

Sketch Start

#include <LiquidCrystal.h>

const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);

void setup() {
  lcd.begin(16, 2);
  lcd.print("hello, world!");
}

void loop() {
  lcd.setCursor(0, 1);
  lcd.print(millis() / 1000);
}

Sketch End

Sketch Explanation - Hello World

#include <LiquidCrystal.h> - Includes the library code for Liquid Crystal
const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2; Assigning the Pin Numbers
LiquidCrystal lcd(rs, en, d4, d5, d6, d7); - Creates a variable of type Liquid Crystal & initializes the library by associating to LCD interface pins.
void setup() {} - Setup function runs when you power the board or press reset button. 
lcd.begin(16, 2); - Defining the LCD's Number of Columns (16) and rows(2)
lcd.print("hello, world!"); - Prints hello, world on the LCD Module
void loop() {} - Loop function runs statements inside it over and over again forever
lcd.setCursor(0, 1); - sets the cursor to column 1, row 2 and then prints the next print statement 
lcd.print(millis() / 1000); - prints the number of seconds since reset

Affiliate Links
Thank You For Reading !!!

No comments:

Post a Comment

Hi, Thanks for Commenting !!!