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

How To Connect PC With 16×2 LCD Using Arduino- (Part 13/49)

By Ajish Alfred July 1, 2013

 The serial port of the microcontroller provides the easiest way by which the user and the microcontroller can write their data in the same medium and both can read each other’s data. The LCD module makes an embedded system completely independent with which the system can take analog or digital input on its input pins and display the corresponding output in its own screen along with generating other kind of outputs.The serial communication port is one of the communication medium available in almost all microcontrollers. It is the most effective communication method available with a microcontroller. The serial port of the microcontroller provides the easiest way by which the user and the microcontroller can write their data in the same medium and both can read each other’s data. When the serial port of the microcontroller is connected to the PC and the incoming and outgoing data is monitored using software and displayed in a window, it forms the simplest text user interface (TUI) setup for the microcontroller.

It is possible to connect the serial port of the PC with the LCD module through the Arduino board. In such a system the user can send the data from the PC to the Arduino’sserial port using software running in the PC, and can view the same data in the LCD module connected to the Arduino board. This project demonstrates how to connect the PC with 16*2 LCD module using Arduino board in such a way that what all things a user type in the PC’s keyboard will appear in the LCD module.

 


 

The Arduino board is built around an AVR microcontroller and it has all the required circuitary to get the built-in AVR microcontroller running. The Arduino can communicate with the other devices using its digital I/O, serial port, I2C port, SPI port etc. Any AVR microcontroller based board which follows the standard Arduino schematic and is flashed with the Arduino bootloader can be called an Arduino board. The Arduino IDE is so simple to use that anyone who has basic knowledge of c programming can quickly get started with it. The project on Getting started with Arduino explains about the steps required to get start with an Arduino board.

The Arduino board used in this project is the Arduino pro-mini board and the IDE version of the Arduino is 1.0.3 for windows. The image of the Arduino pro-mini board and the Arduino IDE are shown below; 
Typical Arduino Pro-Mini Board
Fig. 2: Typical Arduino Pro-Mini Board
 
 
Arduino IDE Software Window
Fig. 3: Arduino IDE Software Window
 
Since the Arduino pro-mini board has no circuitary for interfacing it with the serial port or the USB port of the PC, an external USB to TTL converter board is required to connect it with the PC. This hardware helps in programming the Arduino board and also helps in the serial communication with the USB port of the PC.

 External USB To TTL Converter Board For Programming Arduino And Serial Communication

Fig. 4: External USB to TTL converter board for programming Arduino and serial communication

It is assumed that the reader has gone through the project how to get started with the Arduino and tried out all the things discussed there.
This project uses function for accessing LCD module available from the library <LiquidCrystal.h> as explained in the previous project on how to interface the 4 bit LCD with Arduino board. The serial communication functions are also used in this project which is already discussed in a previous project on how to receive and send serial data using Arduino. Apart from those functions this project make use of two more functions for the LCD namely lcd.clear() and lcd.write() and the details of them are discussed in the following section.
lcd.clear()
This function is used to clear all the current data in the LCD screen. Making a call to this function will make the LCD screen blank. It also set the cursor to the very first position (0, 0) in the LCD screen. The function is normally before writing a new data to the LCD so as to prevent overwriting.
lcd.write()
Thelcd.write() also a function which is used to print the data to the LCD screen like the lcd.print() function does. Unlike the lcd.print() function the lcd.write() function directly write the value to the LCD screen without formatting it as ASCII. This function is analogues to the Serial.write() function discussed in the project how to receive and send serial data using Arduino.
THE CODE
The code initializes the LCD library as per the connection of the LCD with the Arduino board using the function LiquidCrystallcd(). The function lcd.begin() is used to initialize the LCD module in four bit mode with two line display.
The serial port is initialized with 9600 baud rate using the function Serial.begin(). The function Serial.available() is used in the code to check whether a serial data is available to read or not. 
The Serial.read() function is used to read the serial data coming from the PC which is then stored to a variable and is displayed on the LCD using the function lcd.write(). The lcd.clear() is used to clear the LCD screen each time before a new data is written and the lcd.setCursor() function is used to set the cursor at the middle of the LCD screen.
// include the library code:
#include <LiquidCrystal.h>
// initialize the library with the numbers of the interface pins
LiquidCrystallcd(12, 11, 5, 4, 3, 2);
// give the pin a name:
int led = 6;
// incoming byte
charinByte;
void setup()
{
  // initialize the led pin as an output.
pinMode(led, OUTPUT);
  // set up the LCD’s number of columns and rows:
lcd.begin(16, 2);
  // initialize the serial communications:
Serial.begin(9600);
}
void loop()
{
  // if we get a valid byte, read analog ins:
if(Serial.available())
  {
    // get incoming byte:
inByte = Serial.read();         
    // send the same character to the LCD
lcd.clear();
lcd.setCursor(7, 0);
lcd.write(inByte);
    // glow the LED    
digitalWrite(led, HIGH);      
delay(200);
  }
else
digitalWrite(led, LOW);  
}
Whenever a key is pressed in the keyboard the code receives the data byte and sends the same byte to display it in the LCD screen. The code also blinks an LED each time it transmits a data to the serial port using the functions pinMode (), digitalWrite () and delay (). The details of those functions are already discussed in the previous project on How to use digital input and digital output of the Arduino board. Once the coding is finished one can verify and upload the code to the Arduino board as explained in the project how to get started with the Arduino.

Project Source Code

###




/*================================= EG LABS =======================================

 Receive a character through the serial port of the PC and display the same cahracter

 in a 16*2 LCD along with glowing an LED each time

 

 The circuit:

 * LED attached from pin 5 to ground through a 1K resistor


 LCD:

 * LCD RS pin to digital pin 12

 * LCD Enable pin to digital pin 11

 * LCD D4 pin to digital pin 5

 * LCD D5 pin to digital pin 4

 * LCD D6 pin to digital pin 3

 * LCD D7 pin to digital pin 2

 * LCD R/W pin to ground

 * 10K resistor:

 * ends to +5V and ground

 * wiper to LCD pin 3

 * LED anode attached to digital output 6

 * LED cathode attached to ground through a 1K resistor

//================================= EG LABS =======================================*/


// include the library code:

#include <LiquidCrystal.h>


// initialize the library with the numbers of the interface pins

LiquidCrystal lcd(12, 11, 5, 4, 3, 2);



// give the pin a name:

int led = 6;

// incoming byte

char inByte;


void setup()

{

  // initialize the led pin as an output.

  pinMode(led, OUTPUT); 

  // set up the LCD's number of columns and rows: 

  lcd.begin(16, 2);

  // initialize the serial communications:

  Serial.begin(9600);

}


void loop()

{

  // if we get a valid byte, read analog ins:

  if(Serial.available())

  {

    // get incoming byte:

    inByte = Serial.read();          

    // send the same character to the LCD

    lcd.clear();

    lcd.setCursor(7, 0);

    lcd.write(inByte);

    // glow the LED     

    digitalWrite(led, HIGH);       

    delay(200);

  }

  else

    digitalWrite(led, LOW);   

}


###

 


Circuit Diagrams

Circuit-Diagram-Connecting-PC-16×2-LCD-Using-Arduino

Project Components

  • Arduino Pro Mini
  • LCD
  • LED
  • Resistor

Project Video


Filed Under: Arduino Projects
Tagged With: Arduino, lcd, PC
 

Next Article

← Previous Article
Next Article →

Questions related to this article?
👉Ask and discuss on EDAboard.com and Electro-Tech-Online.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

  • RF-DC rectifier impedance matching
  • 12VAC to 12VDC 5A on 250ft 12AWG
  • Precision CAD Drafting Services for Architectural & Engineering Projects
  • SPI speed pic18f66j15
  • I/O constraint for Hold check

RSS Electro-Tech-Online.com Discussions

  • LED circuit for 1/6 scale diorama
  • stud mount Schottky diodes
  • Hi Guys
  • using a RTC in SF basic
  • Can I use this charger in every country?

Featured – Designing of Audio Amplifiers part 9 series

  • Basics of Audio Amplifier – 1/9
  • Designing 250 Milli Watt Audio Power Amplifier – 2/9
  • Designing 1 Watt Audio Power Amplifier – 3/9
  • Designing a Bass Boost Amplifier – 4/9
  • Designing a 6 Watt Car Audio Amplifier – 5/9
  • Design a low power amplifier for headphones- 6/9

Recent Articles

  • Fischer connector system adds ratchet locking system designed for 300g shock resistance
  • Littelfuse introduces tactile switch with enhanced bracket peg design for mounting strength
  • Infineon releases GaN switch with monolithic bidirectional design
  • Sienna Semiconductor data converters feature sample rates from 20 to 250 Msps
  • Delta’s 5,500 W power supplies achieve 97.5% energy efficiency for AI servers

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