Engineers Garage

  • Electronics Projects and Tutorials
    • Electronic Projects
      • Arduino Projects
      • AVR
      • Raspberry pi
      • ESP8266
      • BeagleBone
      • 8051 Microcontroller
      • ARM
      • PIC Microcontroller
      • STM32
    • Tutorials
      • Audio Electronics
      • Battery Management
      • Brainwave
      • Electric Vehicles
      • EMI/EMC/RFI
      • Hardware Filters
      • IoT tutorials
      • Power Tutorials
      • Python
      • Sensors
      • USB
      • VHDL
    • Circuit Design
    • Project Videos
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • Electronic Product News
    • Business News
    • Company/Start-up News
    • DIY Reviews
    • Guest Post
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • DigiKey Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Learn
    • eBooks/Tech Tips
    • Design Guides
    • Learning Center
    • Tech Toolboxes
    • Webinars & Digital Events
  • Resources
    • Digital Issues
    • EE Training Days
    • LEAP Awards
    • Podcasts
    • Webinars / Digital Events
    • White Papers
    • Engineering Diversity & Inclusion
    • DesignFast
  • Guest Post Guidelines
  • Advertise
  • Subscribe

Difference between Commands and Data Send to 16×2 Character Lcd

By EG Projects April 13, 2019

All the character lcd’s of any size 8×1, 8×2 , 10×2 , 16×1 , 16×2 , 16×4 , 20×2 , 20×4 , 24×2 , 30×2 , 32×2 , 40×2, 40×4 contains HD44780 lcd controller in them. If not HD4478 then a controller compatible to it. HD44780 is responsible to accept data from external controller, verify data if correct then recognize if its a data to display on lcd screen or its a command to set lcd parameters. HD44780 has fixed and countable commands to initialize character lcd.

Valid statements accepted by HD44780 Lcd controller

The only thing we must be concerned of is what character/data we can send to lcd?size of data and data type. Well we can send two types of statements to lcd. One is command and the other one is data. Since all the character lcd’s provide 8 data lines for communication so both the command and data size must not exceed 8 bits.  

Valid Data accepted by HD44780 lcd controller

we can send alphabets upper and lower case, some Chinese and Japanese language characters and numeric characters to display them to lcd. We can only display the characters shown below on our lcd screen. Below characters are defined in the flash of hd44780 controller.   
HD44780 lcd controller supported Characters

HD44780 lcd controller supported Characters

Special characters accepted by Hd44780 ccontroller

Hd44780 reserves a space of 64 bytes in its ROM(read only memory). We can generate special 8 custom characters in this ram and invoke them to display on lcd when desired. The size of individual custom character is a 5×8 matrix. Where 5 represents number of coulombs and 8 represents number of rows. Custom characters are independent of shape we can make a shape of our desired look in 5×8 dot matrix.   
16x2 lcd custom 5x8 character generator

16×2 lcd custom 5×8 character generator

Character lcd can display characters in 5×8 and 5×10 dimension only(In the above picture from datasheet of HD44780 controller you can find some characters of size 5×10). If you want to display characters in any other dimension than better use a graphical lcd. Graphical lcd’s are some what independent of the size constraint. For example a 128×64 size of graphical lcd has 64 rows and 128 coulombs. Each row and coulomb intersection represents a dot or pixel. Hencce we can display character of our size on graphical lcd. But we can’t display character bigger than the size of character lcd. 
Some of the tutorial/projects related to this tutorial are  

  • How to Use Character Lcd in 4-bit Mode ?
  • Lcd in 4-bit mode with Pic Microcontroller
  • Lcd in 4-bit mode with Arduino

Valid commands accepted by HD44780 lcd controller

Any embedded electronic device can not work with out initialization and settings. So HD44780 also has a set of pre-defined commands. Which sets the lcd parameters. Like back light on/off, scroll characters, move forward/backward display scroll bar etc. The former parameters are all set by commands. Every parameter has its own fixed command.     
16x2-lcd-hd44780-controller-command-set

16×2-lcd-hd44780-controller-command-set

Their are two registers in every character lcd Data and Command. When we want to send data we have to send it to Data register of lcd. When we want to send commands we have to send it to command register of 16×2 lcd. To switch between data and command register of lcd we only need to control one pin on lcd(I will talk about it later in tutorial). 

Now how to send data and commands/data to lcd? Below is a small code which can help you to understand the difference between commands and data send to lcd.

The scenario is that i have microcontroller. Lcd rs(register select) ,rw(read/write) ,en(enable) pins are connected to pins 5 , 6 , 7 of  microcontroller.

sbit rs = P3^7;             //External controller Pin    
sbit rw = P3^5;            
//External controller Pin               
sbit en = P3^6;            //External controller Pin 

  • lcdcmd() function is sending commands to lcd.
  • lcddata() function  is sending data to lcd.

Their is only just difference between the function names and the rs(register select) pin statement. In command function it is 0. In data function it is 1. This is the main difference which you have to understand read the text below very carefully.

Commands and Data send to Lcd

Command and Data send to Lcd Difference with example

 lcd commands

void lcdcmd(unsigned char value)
  {
    P1 = value;      
    rs = 0;
    rw = 0;
    en = 1;            
    MSDelay(50);
    en = 0;
MSDelay(50);
  }

when we call the lcdcmd() function we put our command in the function such as lcdcmd(0x38). 0x38 is command its description is below. This is an 8-bit command. Its equivalent binary is 01011000.
​
This 8-bit value is send to Port 1 . Port 1 is connected to eight data pins of lcd D0-D7.

when rs(register set) is zero 0 it means that we selected command register and  their is command on the data pins of lcd.

 lcd data

void lcddata(unsigned char value)
  {
    P1 = value;  
    rs = 1;
    rw = 0;
    en = 1;          
    MSDelay(50);
    en = 0;
    MSDelay(50);

  }

when we call the lcddata() function we put our data in the function such as lcddata(‘a’). ‘a’ is a character. This is also an 8-bit data.

​
This 8-bit value is send to Port 1 . Port 1 is connected to eight data pins of lcd D0-D7.

when rs(register set) is one 1 it means that we selected data register and their is data on data pins..

Then comes the stroke pin en(enable). Enable pin provides a push/pulse signal to display what is on data lines of lcd. Initially it is zero but when we put data on data pins and initialize rs 0(for command) or 1(for data) and initialize rw with 1(to read from lcd) or 0(to write to lcd). Then we made en pin high 1. This provides lcd a pulse stroke signal which prints the data or command what ever is present on data pins of lcd. After providing stroke wait for some micro seconds to fully provide enough pulse which can push/move data and can display it on lcd screen. After providing stroke again we must brought en(enable) back to low in order to make it ready to give another pulse to lcd to display another character.


Filed Under: Knowledge Share, Microcontroller Projects

 

Next Article

← Previous Article
Next Article →

Questions related to this article?
👉Ask and discuss on Electro-Tech-Online.com and EDAboard.com forums.



Tell Us What You Think!! Cancel reply

You must be logged in to post a comment.

EE TECH TOOLBOX

“ee
Tech Toolbox: Internet of Things
Explore practical strategies for minimizing attack surfaces, managing memory efficiently, and securing firmware. Download now to ensure your IoT implementations remain secure, efficient, and future-ready.

EE Learning Center

EE Learning Center
“engineers
EXPAND YOUR KNOWLEDGE AND STAY CONNECTED
Get the latest info on technologies, tools and strategies for EE professionals.

HAVE A QUESTION?

Have a technical question about an article or other engineering questions? Check out our engineering forums EDABoard.com and Electro-Tech-Online.com where you can get those questions asked and answered by your peers!


RSS EDABOARD.com Discussions

  • Getting Started with Electronics: What Helped You the Most in the Beginning?
  • De-coupling capacitors with 50 V rating
  • DC/DC Converter with wide range input
  • 12VAC to 12VDC 5A on 250ft 12AWG
  • LVS Mismatch Error in Simple Layout

RSS Electro-Tech-Online.com Discussions

  • Refrigeration System Reliability in Harsh Aussie Conditions
  • Chinese Tarrifs – 104%!?!
  • can a AT89C51 be used as a rom?
  • Telegram Based Alarm - Sensor cable protection
  • An Update On Tarrifs

Featured – Designing of Audio Amplifiers part 9 series

  • Controller Chip Selection for Developing USB Enabled Device (Part 6/6)
  • Signal and Encoding of USB System (Part 5/6)
  • USB Requests and Stages of Control Transfer (Part 4/6)
  • USB Descriptors and their Types (Part 3/6)
  • USB Protocol: Types of USB Packets and USB Transfers (Part 2/6)
  • Introduction to USB: Advantages, Disadvantages and Architecture (Part 1/6)

Recent Articles

  • Renesas launches 64-bit RZ/A3M with built-in 12 8MB memory
  • Hexagon’s Septentrio introduces 23 mm x 16 mm GNSS modules compatible with PX4 and ArduPilot
  • Basics of Audio Amplifier – 1/9
  • Designing 250 Milli Watt Audio Power Amplifier – 2/9
  • Designing 1 Watt Audio Power Amplifier – 3/9

EE ENGINEERING TRAINING DAYS

engineering

Submit a Guest Post

submit a guest post
Engineers Garage
  • Analog IC TIps
  • Connector Tips
  • Battery Power Tips
  • DesignFast
  • EDABoard Forums
  • EE World Online
  • Electro-Tech-Online Forums
  • EV Engineering
  • Microcontroller Tips
  • Power Electronic Tips
  • Sensor Tips
  • Test and Measurement Tips
  • 5G Technology World
  • Subscribe to our newsletter
  • About Us
  • Contact Us
  • Advertise

Copyright © 2025 WTWH Media LLC. All Rights Reserved. The material on this site may not be reproduced, distributed, transmitted, cached or otherwise used, except with the prior written permission of WTWH Media
Privacy Policy

Search Engineers Garage

  • Electronics Projects and Tutorials
    • Electronic Projects
      • Arduino Projects
      • AVR
      • Raspberry pi
      • ESP8266
      • BeagleBone
      • 8051 Microcontroller
      • ARM
      • PIC Microcontroller
      • STM32
    • Tutorials
      • Audio Electronics
      • Battery Management
      • Brainwave
      • Electric Vehicles
      • EMI/EMC/RFI
      • Hardware Filters
      • IoT tutorials
      • Power Tutorials
      • Python
      • Sensors
      • USB
      • VHDL
    • Circuit Design
    • Project Videos
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • Electronic Product News
    • Business News
    • Company/Start-up News
    • DIY Reviews
    • Guest Post
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • DigiKey Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Learn
    • eBooks/Tech Tips
    • Design Guides
    • Learning Center
    • Tech Toolboxes
    • Webinars & Digital Events
  • Resources
    • Digital Issues
    • EE Training Days
    • LEAP Awards
    • Podcasts
    • Webinars / Digital Events
    • White Papers
    • Engineering Diversity & Inclusion
    • DesignFast
  • Guest Post Guidelines
  • Advertise
  • Subscribe