Step-By-Step LCD Wiring (4 Bit Mode) and Programming Examples for Arduino: 8 Steps

4 programming

Step-By-Step LCD Wiring (4 Bit Mode) and Programming Examples for Arduino

Introduction: Step-By-Step LCD Wiring (4 Bit Mode) and Programming Examples for Arduino

This instructable will guide a user step-by-step in wiring and programming a Hitachi HD44780 (or a compatible) chipset LCD screen to an Arduino, using the LiquidCrystal Library. Programming examples are provided for all the Library calls.

2 – Solderless Breadboard

3 – An Hitachi HD44780 or compatible LCD panel

4 – Current limiting resistor for the backlight (10 Ohm)

5 – 10K trim pot for the contrast

6 – 16 pin Male 0.01 Headers

Step 1: Pin Configurations May Vary

The Hitachi HD44780 chipset or compatible LCD’s generally have a very standard pin set. Those without backlights may have only 14 pins, omitting the final two pins powering the light. Please refer to the datasheet for your unit to make sure they match up.

3. Contrast adjustment (VO)

4. Register Select (RS). RS=0: Command, RS=1: Data

5. Read/Write (R/W). R/W=0: Write, R/W=1: Read

6. Clock (Enable). Falling edge triggered

7. Bit 0 (Not used in 4-bit operation)

8. Bit 1 (Not used in 4-bit operation)

9. Bit 2 (Not used in 4-bit operation)

10.Bit 3 (Not used in 4-bit operation)

Step 2: Get the Backlight Working

Solder the headers onto the LCD panel and insert the LCD Panel into a solderless breadboard.

Step 3: Add Power and Display Contrast

1 – Wire GND to pin 1 and 5 (Pin 5 jumper not shown in photo)

2 – Wire 5V to Pin 2

3 – Wire one of the outer legs of the 10K trim pot to 5V and the other to GND (Both wires Yellow in Photo)

4 – Wire the middle leg of the 10K trim pot to pin 3 (Brown in photo)

Step 4: Control Wires and Data Wires

Add the control connections

2 – Jumper pin 6 on the LCD to Digital IO 7 on the Arduino

2 – Jumper pin 12 on the LCD to Digital IO 10 on the Arduino

3 – Jumper pin 13 on the LCD to Digital IO 11 on the Arduino

4 – Jumper pin 14 on the LCD to Digital IO 12 on the Arduino

Step 5: Download the LiquidCrystal Library

The LiquidCrystal Library is a core library for Arduino – there should be no need to install it. If you need to install it for some reason, visit the Arduino site.

Step 6: Uploading the “Hello, World!” Sketch

Create a new sketch window enter the information below. If you display is not a 16 character by 2 line display, please modify

#define LCDRows 2

#define EnablePin 7

#define LCDRows 2

lcd.begin(LCDColumns, LCDRows); //Configure the LCD

Step 7: Understanding “Hello, World!” Using the LiquidCrystal Library

LiquidCrystal(rs, enable, d4, d5, d6, d7) – Creates a variable of type LiquidCrystal. You are asked to define the Ardunio pins the LCD is connected to.

#define EnablePin 7

#define LCDColumns 16

#define LCDRows 2

LiquidCrystal lcd(RSPin, EnablePin,DS4,DS5,DS6,DS7);

begin(cols, rows) – Specifies the dimensions (width in coolumns and height in rows) of the display. In this example, I am using a 16 Character by 2 line display. We used define statements to set these values and called begin() in the setup() routine.

#define LCDRows 2

Step 8: Advanced LiquidCrystal

Load the sketch provided below. It extends the “Hello, World!” example by including all of the LiquidCrystal command and allowing you to uncomment various sections to explore the functionality of thelibrary. Most of the commands available are there for you to play with!

I finally did it! Thank you man.. I can feel your passion through this post as you’ve made sure, not only to give all of the basic info, but also interesting extra stuff that helps with specific projects. The step by step explanation did me a lot of good, my failure was due to the fact that my LCD doesn’t have backlight implemented and instead of documenting myself on each individual pin I would just blindly try to make it look like in the pictures provided by other guides, ending up connecting data pins 13 and 14 to vcc and ground.

You man, are awesome! Please keep up the good work,

sharing is caring!

Thnx mate, great tutorial! not only the build but also the explanation.

Just to quickly say thank you! The example that comes with the Arduino editor didn’t work and found your tutorial, which worked first time 🙂

what if i using lcd shield. same or not?

I know this is a bit late, but it appears it will work. According to the link you had in your comment “Pins 4, 5, 6, 7, 8, 9 and 10 are used to interface with the LCD”, so you’d just change the code to say “LiquidCrystal lcd(4, 5, 6, 7, 8, 9)”. According to the manual linked on the same page, pin 10 is the backlight control, so you’d just set pin 10 high. You could also dim the display by using the analogWrite function on pin 10. Hopefully this helps!

what if i using lcd shield. same or not?

About This Instructable


Let your inbox help you discover our best projects, classes, and contests. Instructables will help you learn how to make anything!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.