RoboShala
  • Home
    • Home #1
      • Infinite Scroll Load More
      • Infinite Load More Posts
      • Home Featured Video
      • Body Boxed Image
      • Body Boxed Color
      • Home with Left Sidebar
      • Home with Sticky Sidebar
      • Standard Layout
      • Classic Layout
    • Home #2
      • Grid Layout
      • Grid with Sidebar
      • Grid 2 Columns Layout
      • List Layout
      • Masonry Layout
      • Masonry with Sidebar
      • Masonry 2 Columns Layout
      • Boxed Layout
      • Overlay Layout
    • Home #3
      • Mixed Layout
      • Mixed Style 2 Layout
      • Photography Layout
      • Magazine Layout 1
      • Magazine Layout 2
      • Magazine Layout 3
      • 1st Overlay Then Grid
      • 1st Overlay Then List
      • 1st Standard Then Grid
    • Home #4
      • 1st Standard Grid Sidebar
      • 1st Standard Then Grid 2
      • 1st Standard Then List
      • 1st Standard Then Boxed
      • 1st Classic Then Grid
      • 1st Classic Grid Sidebar
      • 1st Classic Then Grid 2
      • 1st Classic Then List
      • 1st Classic Then Boxed
  • Sliders
    • Slider #1
      • Home with Slider 1
      • Home with Slider 2
      • Home with Slider 3
      • Home with Slider 4
      • Home with Slider 5
      • Home with Slider 6
      • Home with Slider 7
      • Home with Slider 8
      • Home with Slider 9
    • Slider #2
      • Home with Slider 10
      • Home with Slider 11
      • Home with Slider 12
      • Home with Slider 13
      • Home with Slider 14
      • Home with Slider 15
      • Home with Slider 16
      • Home with Slider 17
      • Home with Slider 18
    • Slider #3
      • Home with Slider 19
      • Home with Slider 20
      • Home with Slider 21
      • Home with Slider 22
      • Home with Slider 23
      • Home with Slider 24
      • Home with Slider 25
      • Home with Slider 26
      • Home with Slider 27
    • Slider #4
      • Home with Slider 28
      • Home with Slider 29
      • Home with Slider 30
      • Home with Slider 35
      • Home with Slider 36
      • Home with Slider 37
      • Home with Slider 38
      • Home Penci Slider 1
      • Home Penci Slider 2
  • Features
    • Post Templates
      • Template Style 1
      • Template Style 2
      • Template Style 3
      • Style 3 with Parallax
      • Template Style 4
      • Style 4 with Parallax
      • Template Style 5
      • Style 5 with Parallax
      • Template Style 6
      • Style 6 with Parallax
      • Template Style 7
      • Style 7 with Parallax
      • Template Style 8
      • Style 8 with Parallax
      • Template Style 9
      • Style 9 with Parallax
      • Template Style 10
      • Style 10 with Parallax
    • Headers
      • Header Style 1
      • Header Style 2
      • Header Style 3
      • Header Style 4 (Centerd)
      • Header Style 5 (Centerd)
      • Header Style 6
      • Header Style 7
      • Header Style 8
      • Header Style 9
    • Menu Item Style 2
    • Real Awesome Gallery
    • Post Formats
      • Standard Post
      • Gallery Post
      • Video Post
        • Youtube Post
        • Vimeo Post
      • Audio Post
        • Soundcloud Audio
        • Self-hosted Audio
      • Quote Post
      • Link Post
    • Pages
      • About me
      • Contact
      • Page Left Sidebar
      • Page Full Width
      • Page 404
    • Typography
  • Tech Update
    • Esp8266

      Sending Data from ESP8266 NodeMCU to Google Drive

      May 10, 2018

      Esp8266

      NodeMCU Pinout

      February 11, 2018

      Esp8266

       IOT theft Notification Using Blynk : Door Status

      October 14, 2017

      Esp8266

      Make NodeMCU ESP Web Server

      September 23, 2017

      Esp8266

      Control NodeMCU using Android App

      September 23, 2017

  • VR & Future
  • Portfolio
    • Masonry 3 Columns
    • Masonry 2 Columns
    • Masonry with Sidebar
    • Grid 3 Columns
    • Grid with Sidebar
    • Grid 2 Columns
    • Single Portfolio
  • Shop

RoboShala

  • Home
    • Home #1
      • Infinite Scroll Load More
      • Infinite Load More Posts
      • Home Featured Video
      • Body Boxed Image
      • Body Boxed Color
      • Home with Left Sidebar
      • Home with Sticky Sidebar
      • Standard Layout
      • Classic Layout
    • Home #2
      • Grid Layout
      • Grid with Sidebar
      • Grid 2 Columns Layout
      • List Layout
      • Masonry Layout
      • Masonry with Sidebar
      • Masonry 2 Columns Layout
      • Boxed Layout
      • Overlay Layout
    • Home #3
      • Mixed Layout
      • Mixed Style 2 Layout
      • Photography Layout
      • Magazine Layout 1
      • Magazine Layout 2
      • Magazine Layout 3
      • 1st Overlay Then Grid
      • 1st Overlay Then List
      • 1st Standard Then Grid
    • Home #4
      • 1st Standard Grid Sidebar
      • 1st Standard Then Grid 2
      • 1st Standard Then List
      • 1st Standard Then Boxed
      • 1st Classic Then Grid
      • 1st Classic Grid Sidebar
      • 1st Classic Then Grid 2
      • 1st Classic Then List
      • 1st Classic Then Boxed
  • Sliders
    • Slider #1
      • Home with Slider 1
      • Home with Slider 2
      • Home with Slider 3
      • Home with Slider 4
      • Home with Slider 5
      • Home with Slider 6
      • Home with Slider 7
      • Home with Slider 8
      • Home with Slider 9
    • Slider #2
      • Home with Slider 10
      • Home with Slider 11
      • Home with Slider 12
      • Home with Slider 13
      • Home with Slider 14
      • Home with Slider 15
      • Home with Slider 16
      • Home with Slider 17
      • Home with Slider 18
    • Slider #3
      • Home with Slider 19
      • Home with Slider 20
      • Home with Slider 21
      • Home with Slider 22
      • Home with Slider 23
      • Home with Slider 24
      • Home with Slider 25
      • Home with Slider 26
      • Home with Slider 27
    • Slider #4
      • Home with Slider 28
      • Home with Slider 29
      • Home with Slider 30
      • Home with Slider 35
      • Home with Slider 36
      • Home with Slider 37
      • Home with Slider 38
      • Home Penci Slider 1
      • Home Penci Slider 2
  • Features
    • Post Templates
      • Template Style 1
      • Template Style 2
      • Template Style 3
      • Style 3 with Parallax
      • Template Style 4
      • Style 4 with Parallax
      • Template Style 5
      • Style 5 with Parallax
      • Template Style 6
      • Style 6 with Parallax
      • Template Style 7
      • Style 7 with Parallax
      • Template Style 8
      • Style 8 with Parallax
      • Template Style 9
      • Style 9 with Parallax
      • Template Style 10
      • Style 10 with Parallax
    • Headers
      • Header Style 1
      • Header Style 2
      • Header Style 3
      • Header Style 4 (Centerd)
      • Header Style 5 (Centerd)
      • Header Style 6
      • Header Style 7
      • Header Style 8
      • Header Style 9
    • Menu Item Style 2
    • Real Awesome Gallery
    • Post Formats
      • Standard Post
      • Gallery Post
      • Video Post
        • Youtube Post
        • Vimeo Post
      • Audio Post
        • Soundcloud Audio
        • Self-hosted Audio
      • Quote Post
      • Link Post
    • Pages
      • About me
      • Contact
      • Page Left Sidebar
      • Page Full Width
      • Page 404
    • Typography
  • Tech Update
    • Esp8266

      Sending Data from ESP8266 NodeMCU to Google Drive

      May 10, 2018

      Esp8266

      NodeMCU Pinout

      February 11, 2018

      Esp8266

       IOT theft Notification Using Blynk : Door Status

      October 14, 2017

      Esp8266

      Make NodeMCU ESP Web Server

      September 23, 2017

      Esp8266

      Control NodeMCU using Android App

      September 23, 2017

  • VR & Future
  • Portfolio
    • Masonry 3 Columns
    • Masonry 2 Columns
    • Masonry with Sidebar
    • Grid 3 Columns
    • Grid with Sidebar
    • Grid 2 Columns
    • Single Portfolio
  • Shop
Beginners GuideSensors/Modules

Arduino With LCD Full Programming Tutorial

by Alok Shaw October 22, 2017
written by Alok Shaw October 22, 2017
Arduino With LCD Full Programming Tutorial

In many  Arduino or Raspberry pi projects we need to display some messages or text regarding the project’s behavior. Suppose you are making a ‘Digital Thermostat’ that can show both the Temperature and Humidity data from the DHT11 sensor, so in that case for digitally showing these data to the user we need a display that can fetch the data from Arduino and display it on its screen.

Here in this tutorial you will learn how to interface and use a 16X2 LCD with Arduino.

There are two types of 16X2 LCD currently available in the market. One is the native one that have 16 pins and other comes with I2C communication inbuilt. We will talk about them one by one in full details.

LCD Pinout:

 

There are total 16 Pins.

  • First one from left hand side is the Ground(GND) pin. The second pin is the Vcc which we connect to the 5 volts pin of Arduino.
  • Vo pin is for the brightness for the LCD display, on which we can attach a potentiometer for controlling the contrast of the display.
  • The RS pin( Register Select pin) is used for selecting whether we will send commands or data to the LCD. For example if the RS pin is set on High state or 5 volts we are sending data or characters to the LCD and if it is set on low state or zero volts, then we are sending commands to the LCD like: set the cursor to a specific given location, clear the display, turn on-off the display and so on.
  • R/W pin selects the mode whether we want to read or write on the LCD.
  • E pin enables the writing to the registers.
  • D0 to D7 : 8 data pins are use for sending the 8 bits data when we are writing to the registers. For example if we want to see the latter uppercase A on the display we send 0100 0001 to these 8 data pins for writing to the registers according to the ASCII table.
  • A and K pins are for LCD inbuilt back light i.e. Anode and cathode pins respectively.

Here, in this tutorial we will be using only the 4 data pins for writing to only 4 registers. So, we are going to use it in 4 bit Mode.

Connection with Arduino:

Here, Potentiometer is not compulsory to use, it is just for adjusting the brightness.

Basics of LCD Programming:

LCD Programming include a pre-installed LCD library i.e. LiquidCrystal.h that needs to be included in the program for the following LCD function to work.

Here are the list of some of the most common functions along with their uses and briefings.

1. LiquidCrystal()

The LiquidCrystal() function sets the pins which Arduino uses to connect with the LCD. The parameters passed inside the parentheses are in this order:

LiquidCrystal(RS, E, D4, D5, D6, D7)

For example, if we want LCD pin D4 to connect to Arduino pin 3. Just put “3” in place of D7 in the function like this: LiquidCrystal(RS, E, 3, D5, D6, D7). And do this similarly for the other corresponding pins.  This function needs to be placed before the void setup() section of the arduino program.

2. lcd.begin()

Since, here we are using 16X2 LCD screen that can support 32 characters on it in two rows with 16 characters in each of these 2 rows. So, while programing we need to specify the Arduino about the dimensions of the LCD. Therefore we use this function to set the dimensions. The number of rows and columns are specified as lcd.begin(columns, rows). For 16×2 LCD, we would use lcd.begin(16, 2).

3. lcd.setCursor()

It places the cursor (and any printed text) at any specified position on the screen. It can be used in the void setup() or void loop() section of your program.

The cursor position is defined with lcd.setCursor(column, row). The column and row coordinates start from zero (0-15 and 0-1 respectively). For example, using lcd.setCursor(4, 1) in the void setup() section of the “Roboshala India” program above prints “Roboshala India” to the lower line and shifts it to the right four spaces:

4.  lcd.Cursor()

This function is used for  creatng a visible cursor. For turning Off the cursorthe function to be used is  lcd.noCursor().Note that both the  lcd.cursor() and lcd.noCursor() functions can be used together in the void loop() section to make a blinking cursor similar to what you see in many text input fields.

5. lcd.display()

This function is used for turning on any text or cursors that have been printed to the LCD screen. The function lcd.noDisplay() turns off any text or cursors printed to the LCD, without clearing it from the LCD’s main memory.

6. lcd.print()

This function is used for printing message to the LCD and can be used in both the void setup() or the void loop() section of the program.

There are different ways  for printing messages which depends on its type.

For letters and words, place quotation marks (” “) around the text.
For example: lcd.print(“Roboshala!”)
For numbers, no quotation marks are needed. For example : lcd.print(123456789)
lcd.print() can print numbers in different forms like decimal, binary, hexadecimal, and octal bases also. For example:
  1. lcd.print(100, DEC) : prints “100”
  2. lcd.print(100, BIN) : prints “1100100”
  3. lcd.print(100, HEX) : prints “64”
  4. lcd.print(100, OCT) : prints “144”

 

There are many other functions also and you can learn about them by going through the examples code under LCD examples code in Arduino IDE.

Code Section:

/*
  Basic LCD tutorial for Arduino Beginners.
  Visit: www.youtube.com/roboshala for Video tutorials.
* www.roboshala.com
*
*/
#include <LiquidCrystal.h> // includes the LiquidCrystal Library 
LiquidCrystal lcd(1, 2, 4, 5, 6, 7); // Assign the connection pins to LCD | Parameters: (rs, enable, d4, d5, d6, d7) 
void setup() 
{ 
 lcd.begin(16,2); // Initializes the LCD interface , and specifies the dimensions (width and height) of the display 
}
void loop() { 
 lcd.print("www.roboshala.com"); // Prints "www.roboshala.com" on the LCD 
 delay(3000); // 3 seconds delay 
 lcd.setCursor(2,1); // Sets the location at which subsequent text written to the LCD will be displayed 
 lcd.print("Best Tutorial"); // Prints "Best Tutorial" on the LCD 
 delay(3000); 
 lcd.clear(); // Clears the display 
 lcd.blink(); //Displays the blinking LCD cursor 
 delay(4000); 
 lcd.setCursor(7,1); 
 delay(3000); 
 lcd.noBlink(); // Turns off the blinking LCD cursor 
 lcd.cursor(); // Displays an underscore (line) at the position to which the next character will be written 
 delay(4000); 
 lcd.noCursor(); // Hides the LCD cursor 
 lcd.clear(); // Clears the LCD screen 
}

 

0 comment
0
FacebookTwitterGoogle +Pinterest
Alok Shaw

previous post
Raspberry Pi Programming- Most Useful Commands
next post
Make Arduino Piano

Related Posts

Arduino GPS Module Interface

October 10, 2017

Control Relay with Arduino

October 3, 2017

SD Card Module with Arduino : Data Logger

October 3, 2017

Line Follower Robot

September 24, 2017

Reading LDR Value Arduino

September 23, 2017

Universal IR Reciever

September 23, 2017

Leave a Comment Cancel Reply

Save my name, email, and website in this browser for the next time I comment.

Arduino

  • Arduino projects (14)
  • Basic Electronics (2)
  • Beginners Guide (4)
  • DIY Robots (9)
  • Esp8266 (8)
  • Featured (13)
  • Home Automation (7)
  • IOT (3)
  • IOT Projects (5)
  • Projects (1)
  • Raspberry pi (2)
  • Raspberry pi Basics (6)
  • Raspberry Pi Projects (1)
  • School Projects (1)
  • Sensors/Modules (6)
  • Smartphones (6)
  • Social Networks (7)
  • Starter Guide (7)
  • Uncategorized (4)
  • VR & Future (7)

Rasbperry pi

  • Arduino projects (14)
  • Basic Electronics (2)
  • Beginners Guide (4)
  • DIY Robots (9)
  • Esp8266 (8)
  • Featured (13)
  • Home Automation (7)
  • IOT (3)
  • IOT Projects (5)
  • Projects (1)
  • Raspberry pi (2)
  • Raspberry pi Basics (6)
  • Raspberry Pi Projects (1)
  • School Projects (1)
  • Sensors/Modules (6)
  • Smartphones (6)
  • Social Networks (7)
  • Starter Guide (7)
  • Uncategorized (4)
  • VR & Future (7)

IOT

  • Arduino projects (14)
  • Basic Electronics (2)
  • Beginners Guide (4)
  • DIY Robots (9)
  • Esp8266 (8)
  • Featured (13)
  • Home Automation (7)
  • IOT (3)
  • IOT Projects (5)
  • Projects (1)
  • Raspberry pi (2)
  • Raspberry pi Basics (6)
  • Raspberry Pi Projects (1)
  • School Projects (1)
  • Sensors/Modules (6)
  • Smartphones (6)
  • Social Networks (7)
  • Starter Guide (7)
  • Uncategorized (4)
  • VR & Future (7)

Keep in touch

Facebook Twitter Google + Instagram Pinterest Youtube Snapchat RSS

Recent Posts

  • ESP8266 WiFi Dimmer | Control the Speed of Fan using Smartphone

  • GSM Based Notice Board using Arduino and SIM900A

  • General Magic tried to invent a smartphone in the 1990s. This is why it failed.

  • The expensive education of Mark Zuckerberg and Silicon Valley this year

Categories

  • Arduino (22)
    • Beginners Guide (4)
    • DIY Robots (9)
    • Home Automation (7)
    • Sensors/Modules (6)
  • Basic Electronics (2)
  • Featured (13)
  • IOT (10)
    • Esp8266 (8)
  • Projects (20)
    • Arduino projects (14)
    • IOT Projects (5)
    • Raspberry Pi Projects (1)
    • School Projects (1)
  • Raspberry pi (13)
    • Raspberry pi Basics (6)
    • Starter Guide (7)
  • Smartphones (6)
  • Social Networks (7)
  • Uncategorized (4)
  • VR & Future (7)

IMPORTANT LINKS

  • About Us
  • Advertise with us
  • Disclaimer
  • Contact Us
  • RoboShala
  • Typography
  • Page Full Width
  • Portfolio 3 Columns
  • Portfolio 2 Columns
  • Portfolio with Sidebar
  • About Me
  • Contact
  • Grid 2 Columns
  • Grid 3 Columns
  • Grid with Sidebar
  • Gallery

Tags

Arduino arduino data logging web server arduino gsm control relay Arduino Projects arduino temperature logger wifi arduino wireless temperature sensor project blog esp8266 data logger esp8266 datasheet esp8266 direct connect esp8266 firebase tutorial esp8266 iot projects esp8266 iot server esp8266 mongodb esp8266 nodemcu pinout esp8266 pinout esp8266 send data to server esp8266 send data to thingspeak esp8266 send email esp8266 temperature esp8266 tutorial esp8266 web server graph gsm gsm based home automation abstract gsm based home automation ppt gsm based home automation project pdf gsm based home automation using 8051 microcontroller gsm module Home automation new raspberry pi model3b+ nodemcu arduino nodemcu esp8266 pinout nodemcu pinout NodeMCU projects nodemcu send data to server nodemcu tutorial pi model3b+ specification raspberry pi model 3b+ raspberry pi model 3b+ features sim900a sim900a gsm soledad spiffs technology thingspeak arduino example

Subscrbe Newsletter

Subscribe my Newsletter for new blog posts, tips & new photos. Let's stay updated!

  • Facebook
  • Twitter
  • Google +
  • Instagram
  • Linkedin
  • Youtube
  • Snapchat
  • Telegram
RoboShala
  • Home
    • Home #1
      • Infinite Scroll Load More
      • Infinite Load More Posts
      • Home Featured Video
      • Body Boxed Image
      • Body Boxed Color
      • Home with Left Sidebar
      • Home with Sticky Sidebar
      • Standard Layout
      • Classic Layout
    • Home #2
      • Grid Layout
      • Grid with Sidebar
      • Grid 2 Columns Layout
      • List Layout
      • Masonry Layout
      • Masonry with Sidebar
      • Masonry 2 Columns Layout
      • Boxed Layout
      • Overlay Layout
    • Home #3
      • Mixed Layout
      • Mixed Style 2 Layout
      • Photography Layout
      • Magazine Layout 1
      • Magazine Layout 2
      • Magazine Layout 3
      • 1st Overlay Then Grid
      • 1st Overlay Then List
      • 1st Standard Then Grid
    • Home #4
      • 1st Standard Grid Sidebar
      • 1st Standard Then Grid 2
      • 1st Standard Then List
      • 1st Standard Then Boxed
      • 1st Classic Then Grid
      • 1st Classic Grid Sidebar
      • 1st Classic Then Grid 2
      • 1st Classic Then List
      • 1st Classic Then Boxed
  • Sliders
    • Slider #1
      • Home with Slider 1
      • Home with Slider 2
      • Home with Slider 3
      • Home with Slider 4
      • Home with Slider 5
      • Home with Slider 6
      • Home with Slider 7
      • Home with Slider 8
      • Home with Slider 9
    • Slider #2
      • Home with Slider 10
      • Home with Slider 11
      • Home with Slider 12
      • Home with Slider 13
      • Home with Slider 14
      • Home with Slider 15
      • Home with Slider 16
      • Home with Slider 17
      • Home with Slider 18
    • Slider #3
      • Home with Slider 19
      • Home with Slider 20
      • Home with Slider 21
      • Home with Slider 22
      • Home with Slider 23
      • Home with Slider 24
      • Home with Slider 25
      • Home with Slider 26
      • Home with Slider 27
    • Slider #4
      • Home with Slider 28
      • Home with Slider 29
      • Home with Slider 30
      • Home with Slider 35
      • Home with Slider 36
      • Home with Slider 37
      • Home with Slider 38
      • Home Penci Slider 1
      • Home Penci Slider 2
  • Features
    • Post Templates
      • Template Style 1
      • Template Style 2
      • Template Style 3
      • Style 3 with Parallax
      • Template Style 4
      • Style 4 with Parallax
      • Template Style 5
      • Style 5 with Parallax
      • Template Style 6
      • Style 6 with Parallax
      • Template Style 7
      • Style 7 with Parallax
      • Template Style 8
      • Style 8 with Parallax
      • Template Style 9
      • Style 9 with Parallax
      • Template Style 10
      • Style 10 with Parallax
    • Headers
      • Header Style 1
      • Header Style 2
      • Header Style 3
      • Header Style 4 (Centerd)
      • Header Style 5 (Centerd)
      • Header Style 6
      • Header Style 7
      • Header Style 8
      • Header Style 9
    • Menu Item Style 2
    • Real Awesome Gallery
    • Post Formats
      • Standard Post
      • Gallery Post
      • Video Post
        • Youtube Post
        • Vimeo Post
      • Audio Post
        • Soundcloud Audio
        • Self-hosted Audio
      • Quote Post
      • Link Post
    • Pages
      • About me
      • Contact
      • Page Left Sidebar
      • Page Full Width
      • Page 404
    • Typography
  • Tech Update
    • Esp8266

      Sending Data from ESP8266 NodeMCU to Google Drive

      May 10, 2018

      Esp8266

      NodeMCU Pinout

      February 11, 2018

      Esp8266

       IOT theft Notification Using Blynk : Door Status

      October 14, 2017

      Esp8266

      Make NodeMCU ESP Web Server

      September 23, 2017

      Esp8266

      Control NodeMCU using Android App

      September 23, 2017

  • VR & Future
  • Portfolio
    • Masonry 3 Columns
    • Masonry 2 Columns
    • Masonry with Sidebar
    • Grid 3 Columns
    • Grid with Sidebar
    • Grid 2 Columns
    • Single Portfolio
  • Shop

Popular Posts

  • 1

    Wifi Home Automation using NodeMCU

  • 2

     IOT theft Notification Using Blynk : Door Status

  • 3

    ESP8266 WiFi Dimmer | Control the Speed of Fan using Smartphone

  • 4

    Arduino SIM900A Home Automation

  • 5

    GSM Based Notice Board using Arduino and SIM900A

  • 6

    Sending Data from ESP8266 NodeMCU to Google Drive

@2019 - All Right Reserved. Designed and Developed by PenciDesign