You are on page 1of 12

Search Products

Find
(../../../default.asp)
SUPPORT (../../../SUPPORT.ASP) CONTACT
ALERTS
7 0
LOGIN (../../../LOGIN.ASP)
USB Blaster
For Altera
Devices
(../../../products/USB-
Blaster -
For -Alt era-
Dev ices)
USB Logic
Analyzer
24MHz 8
Channels
(../../../products/USB-
Logic-
Analyzer -
24MHz-8-
Channel s)
USB to TTL
Module using
CH340
(../../../products/USB-
t o-TTL-
Module-
using-
CH340)
Debugger
Programmer
for ST
Microcontrollers
(../../../products/Debugger-
Progr ammer-
for -ST-
Mi crocontrollers)
Intel Galileo
Board
(../../../pr oduct s/Intel -
Galil eo-
Boar d)
Richduino
UNOBasic
For Arduino
with Female
Headers
(../../../products/Richduino-
UNOBasi c-
For -
Arduino-
wit h-
Femal e-
Headers)
Development
Boards
8051
(../../../Products/8051-
Development-
Board)
Arduino
(../../../Products/Arduino-
Development-
Boards)
ARM11
(../../../Products/ARM11-
Development-
Board)
ARM7
(../../../Products/ARM-
Development-
Boards)
ARM9
(../../../Products/ARM9-
Development-
Boards)
ATmega
AVR
(../../../Products/AVR-
Development-
Board)
Cortex A8
(../../../Products/Cortex-
Home (../../../) / Products (../../../Products) / 89V51RD2 Starter Kit
(../../../Products/89V51RD2-Starter-Kit) / Tutorials
(../../../Products/89V51RD2-Starter-Kit) / LCD 2nd Line interfacing with
89V51RD2 Microcontroller
Tutorial - LCD 2nd Line interfacing with 89V51RD2
Microcontroller
Post ed on : Monday, Februar y 28, 2011 For Product: 89V51RD2
Starter Kit (../../../products/89V51RD2-Starter-Kit) Pri ce: 2079 |
Quantity di scount av ail abl e (../../../pr oduct s/89V51RD2-Starter-Kit)
LCD Interfacing - 2nd line
interfacing of LCD with
89V51RD2
Product Tutorial by
Tech-Support Team @ www.EmbeddedMarket.com
Copyright Article
A8-
Development-
Board)
Cortex M0
(../../../Products/Cortex-
M0-
Development-
Board)
Cortex M3
(../../../Products/ARM-
Cortex-
M3-
Development-
Board)
Cortex M4
(../../../Products/ARM-
Cortex-
M4-
Development-
Board)
Intel
Boards
(../../../Products/Intel-
Development-
Boards-
India)
MSP430
(../../../Products/MSP430-
Development-
Board)
pcDuino
(../../../Products/pcDuino-
Boards)
Raspberry
Pi
(../../../Products/Raspberry-
Pi-
Boards)
TI Piccolo
(../../../Products/Ti-
Piccolo-
Microcontroller-
Board-
Texas-
Instruments)
Vinculum
Boards
(../../../Products/Vinculum-
Boards)
WiFi
The program is written using Keil - Eval version.
Simple functions are used to interface 16x2 line LCD with 89V51RD2.
The full program is divided into following functions:
void Init_LCD(void);
This function is used for initialization.
void Clear_LCD(void);
Use it to Clear Text on LCD
void Wait_LCD(void);
Used while writing text to LCD
void Write_Char(unsigned char c,int x, int y);
Used to write a single character at specified location. Variable x is zero
based number, use it from 0 to 15 to specify the character location in
horizontal line. Use variable y (1 o 2) to specify the line number for the
character to be displayed.
To complete the assignment you will need:
1. 89V51RD2 Starter Kit (../)
2. Single Pin Connectors - 3 (Included with the Kit)
3. 9VDC Adapter (Included in the Kit)
Connections;
1. Connect P0 of 89V51RD2 to Data port of LCD (D0 to D7) (Use single
pin connectors provided with the product)
2. Connect P2.0, P2.1 & P2.2 to RS, RW & EN pins of LCD respectively
(Use single pin connectors provided with the product)
3. Connect Power supply
Write, compile & Download the below code to see results.
#include <reg52.h> /* special function register declarations */
/* for the intended 8051 derivative */
#include <stdio.h> /* prototype declarations for I/O functions */
#define PDATA P0
sbit RS =P2^0;
sbit RW =P2^1;
Development
Board
(../../../Products/WiFi-
Development-
Boards)
Programmers &
Analyzer
8051
Programmer
(../../../Products/8051-
Programmers)
AVR
Programmer
(../../../Products/ATMEL-
AVR-
Programmer)
FPGA
Programmer
(../../../Products/FPGA-
Programmer)
NXP ARM
Programmer
(../../../Products/NXP-
ARM-
Programmer)
PIC
Programmer
(../../../Products/Microchip-
PIC-
Programmer)
Signal
Analyzer
(../../../Products/Signal-
Analyzer)
ST
Programmer
(../../../Products/ST-
Programmer)
Programmable
Logic Controller
PLC Unit
(../../../Products/PLC-
Unit-With-
Software)
Globally Popular
Intel
(../../../Products/Intel-
sbit EN =P2^2;
sbit D7 =P0^7;
void Init_LCD(void);
void Clear_LCD(void);
void Wait_LCD(void);
void Write_Char(unsigned char c,int x, int y);
void main (void) {
Init_LCD();
Clear_LCD();
Write_Char('H',0,1); //Write char H at 0th block on First Row
Write_Char('e',1,1); //Write char e at 1st block on First Row
Write_Char('l',2,1); //Write char l at 2nd block on First Row
Write_Char('l',3,1); //Write char l at 03rd block on First Row
Write_Char('o',4,1); //Write char o at 4th block on First Row
Write_Char(' ',5,1); //Write space at 5th block on First Row
Write_Char('W',6,1); //Write char W at 6th block on First Row
Write_Char('o',7,1); //Write char o at 7th block on First Row
Write_Char('r',8,1); //Write char r at 8th block on First Row
Write_Char('l',9,1); //Write char l at 9th block on First Row
Write_Char('d',10,1); //Write char d at 10th block on First Row
Write_Char('!',11,1); //Write char ! at 11th block on First Row
Write_Char('!',12,1); //Write char ! at 12th block on First Row
Write_Char('!',13,1); //Write char ! at 13th block on First Row
Write_Char('.',14,1); //Write char . at 14th block on First Row
Write_Char('.',15,1); //Write char . at 15th block on First Row
Write_Char('E',0,2); //Write char E at 0th block on Second Row
Write_Char('m',1,2); //Write char m at 1st block on Second Row
Write_Char('b',2,2); //Write char b at 2nd block on Second Row
Write_Char('e',3,2); //Write char e at 03rd block on Second Row
Write_Char('d',4,2); //Write char d at 4th block on Second Row
Write_Char('d',5,2); //Write char d at 5th block on Second Row
Write_Char('e',6,2); //Write char e at 6th block on Second Row
Write_Char('d',7,2); //Write char d at 7th block on Second Row
Write_Char('M',8,2); //Write char M at 8th block on Second Row
Write_Char('a',9,2); //Write char a at 9th block on Second Row
Write_Char('r',10,2); //Write char r at 10th block on Second Row
Write_Char('k',11,2); //Write char k at 11th block on Second Row
Write_Char('e',12,2); //Write char e at 12th block on Second Row
Write_Char('t',13,2); //Write char t at 13th block on Second Row
Write_Char('.',14,2); //Write char . at 14th block on Second Row
Write_Char('.',15,2); //Write char . at 15th block on Second Row

while(1); //End less while so that programe never ends
}
Embedded-
Boards)
pcDuino
(../../../Products/pcDuino-
Boards-
Accessories)
Raspberry
Pi
(../../../Products/Raspberry-
Pi-
Boards-
Accessories)
Arduino
Accessories
(../../../Products/Accessories-
Arduino)
ICs
(../../../Products/Arduino-
IC)
Main
Board
(../../../Products/Arduino-
Board)
Shield
(../../../Products/Arduino-
Shield)
Modules
Accelerometers
(../../../Products/Accelerometer-
Modules)
ADC
(../../../Products/ADC-
Interfacing-
Boards)
Bluetooth
(../../../Products/Bluetooth-
Communication-
Modules)
Converters
(../../../Products/Converter-
Module)
Current
Sensor
(../../../Products/Current-
Sensor-
Module)
DAC
(../../../Products/DAC-
void Init_LCD(void)
{
RS =0; //CLR RS
PDATA =0x34; //MOV PDATA,#00110100b
EN =1; //SETB EN
EN =0; //CLR EN
Wait_LCD(); //LCALL WAIT_LCD
RS =0; //CLR RS
PDATA =0x3C; //MOV PDATA,#00111100b
EN =1; //SETB EN
EN =0; //CLR EN
Wait_LCD(); //LCALL WAIT_LCD
RS =0; //CLR RS
PDATA=0x0C; //MOV PDATA,#0Ch
EN =1; //SETB EN
EN =0; //CLR EN
Wait_LCD(); //LCALL WAIT_LCD

RS =0; //CLR RS
PDATA=0x06; //MOV PDATA,#06h
EN=1; //SETB EN
EN=0; //CLR EN
Wait_LCD(); //LCALL WAIT_LCD
}
void Clear_LCD(void)
{
RS =0; //CLR RS
PDATA =0x01; //MOV PDATA,#01h
EN =1; //SETB EN
EN =0; //CLR EN
Wait_LCD(); //LCALL WAIT_LCD

}
void Wait_LCD(void)
{
EN =0; //CLR EN
RS =0; //CLR RS
RW =1; //SETB RW
D7 =1; //MOV PDATA,#0FFh
EN =1; //SETB EN
while(D7)
{
EN =0;
Converter-
Module)
Displays
(../../../Products/Display-
Breakout-
Module)
Ethernet
(../../../Products/Ethernet-
Interfacing-
Module)
Extension
Boards
(../../../Products/Extension-
Board-
Module)
Fingerprint
Sensor
(../../../Products/Fingerprint-
Sensor-
Modules-
With-
Source-
Code)
General
Purpose
(../../../Products/General-
Purpose-
Modules)
Keypads
(../../../Products/Matrix-
Keypad)
Motor
driver
(../../../Products/Motor-
Driver-
Board)
Power
Supply
(../../../Products/DC-
Power-
Supply)
Relay
(../../../Products/Relay-
Interfacing-
Circuits)
RFID
(../../../Products/RFID-
Modules-
Cards)
RJ 45
EN =1;
}
//MOV A,PDATA
//J B ACC.7,WAIT_LCD
EN =0; //CLR EN
RW =0; //CLR RW
}
void Write_Char(unsigned char c,int x, int y) //x is 0 to 15 horizontal
position of character. y is 1 for first line, 2 for second line
{
int location;
if(y==1)
{
location =0x80 +x;
}
if(y==2)
{
location =0x80 +0x40 +x;
}
RS =0; //CLR RS
PDATA=location; //MOV PDATA,#0C4h
EN =1; //SETB EN
EN=0; //CLR EN
Wait_LCD(); //LCALL WAIT_LCD

RS =1; //SETB RS
PDATA =c; //MOV PDATA,A
EN =1; //SETB EN
EN =0; //CLR EN
Wait_LCD(); //LCALL WAIT_LCD
}
Download this full project code (LCD-Interfacing.zip)
(../../../Products/RJ 45-
Interfacing-
Module)
RS232
(../../../Products/RS232-
Interfacing-
Module)
RS485
(../../../Products/RS485-
Modules-
Boards)
SD MMC
Card
(../../../Products/SD-
Card-
Interfacing-
Module)
Touch
(../../../Products/Touch-
Modules-
Boards)
USB
(../../../Products/USB-
Interfacing-
Module)
WiFi
Modules
(../../../Products/WiFi-
Interfacing-
Modules)
SMD to DIP
FFC
(../../../Products/FFC-
To-DIP-
Converter)
QFP to
DIP
Adapter
(../../../Products/QFP-
To-DIP-
Converter)
SOIC to
DIP
Adapter
Converter
(../../../Products/SOIC-
To-DIP-
Converter)
SOT23 to
DIP
Adapter
Converter
(../../../Products/SOT23-
To-DIP-
Converter)
SSOP to
DIP
Adapter
Converter
(../../../Products/SSOP-
To-DIP-
Converter)
TSOP
(../../../Products/TSOP-
To-DIP-
Converter)
Communication
Bluetooth
(../../../Products/Bluetooth-
Modules-
For-
Interfacing)
RFID
(../../../Products/RFID-
Communication-
Boards)
TCP/IP
Ethernet
(../../../Products/TCP-
IP-
Ethernet-
Communication-
Modules)
WiFi
(../../../Products/WiFi-
Communication-
Boards)
Enclosure
Arduino
(../../../Products/Enclosure-
For-
Arduino)
Raspberry
Pi
(../../../Products/Enclosure-
For-
Raspberry-
Pi)
Spares
Board
Connectors
(../../../Products/Board-
Connectors)
Cables
Connectors
(../../../Products/Cables-
Connectors)
Crystal
(../../../Products/Crystal-
Quartz)
Diode
(../../../Products/Electronics-
Spares-
Diode)
Displays
(../../../Products/Displays-
LCD-LED-
Touch)
Interface
ICs
(../../../Products/Interfacing-
ICs)
LEDs
(../../../Products/LED)
Logic
Gates
and
Buffers
(../../../Products/ICs-
for-Logic-
Gates-
Buffers)
Microcontroller
ICs
(../../../Products/Microcontroller-
ICs)
Passive
Components
(../../../Products/Passive-
Components)
Power
Supplies
(../../../Products/Power-
Supply)
Relays
(../../../Products/Relays-
Leone-
Goodsky-
Other-
Brands)
Sensors
(../../../Products/Sensors)
Voltage
Regulator
ICs
(../../../Products/Voltage-
Regulator-
ICs)
Antistatic
Products
Component
Handling
(../../../Products/ESD-
Safe-
Component-
Handling)
Conductive
Storage
(../../../Products/Conductive-
Storage-
Boxes)
Craft & Hobby
Craft Kits
(../../../Products/Craft-
Kits)
Hobby
Kits
(../../../Products/Hobby-
Kits)
Hobby Robotics
Accessories
(../../../Products/Hobby-
Robot-
Accessories)
Boards
(../../../Products/Robotics-
Board)
Motors
(../../../Products/DC-
Servo-
Motors-
For-
Robotics)
Sensors
(../../../Products/Robotics-
Sensors)
Information
List of Brands
(../../../Brands)
Order Tracking
(../../../login.asp)
How to Order?
(../../../Information/How-
To-Order.asp)
Quick Delivery
(../../../Information/Delivery.asp)
Payment Options
(../../../Information/Payment.asp)
Proforma Invoice
(../../../Information/Proforma-
Invoice.asp)
Warranty T&C
(../../../Information/Warranty.asp)
Contact Details
(../../../About-
Us/contact.asp)
About us
(../../../About-
Us/About-
Embedded-
Market.asp)
Starter Kit for
Arduino
Workshop
(../../../Products/Arduino-
Workshop-
Starter-Kit-For-
India/)
Head Office:
Embedded
Market
205, Decision
Tower, Next To
CityPride,
Satara Road,
Pune 411037 India
Phone Numbers
(During working
hours)
For Sales :
+91 70 57 57 56
13
Accounts &
Dispatch:
+91 20 24228818
Mon-Fri : 9.30 am
to 5.00 pm
Sat: 9.30 am to
12.30 pm
For Support :
Login
(http://www.embeddedmarket.com/Login.asp)
Holiday : Sunday,
National holidays &
few local festival
days
Online or der is
compulsory f or
ev eryone.
EmbeddedMarket.com has deliv ered product s to various cities in India including ,
chennai, kharagpur, pune, Abu road, Agartala, Agra, Ahmedabad, Ahmedabad-380058,
Ahmednagar, Aizawl, Ajmer, Akola, Alappuzha, Alapuzha, Alibag, Aligarh, Allahabad, Alleppey,
Alto-dabolim, Aluva, Alwar, Ambala, Ambernath, Ambikapur, Amravati, Amritsar, Anand,
Anantapur, Andheri, Andheri east, Angamaly, Angul, Ankleshwar, Aruppukottai, Asansol,
Auranagabad, Aurangabad , Aurangabad. , Austin, Baddi, Bagalkot, Balngalore, Banagalore,
Banaglore, Bandel, Bangalore, Baramati, Baroda, Barshi, Bathinda, Belgaum, Bellary,
Bengaluru, Benguluru, Berhampur, Bhadravati, Bhandara, Bharatpur, Bharuch, Bhavnagar,
Bhavnagar-364 001, Bhilai, Bhilai, distt - durg, Bhilwara, Bhimavaram, Bhiwandi, Bhiwani,
Bhopal, Bhubaneswar, Bhubaneswer, Bhubhaneswar, Bhuj, Bilaspur, Boisar, Bolpur, Bombay,
Bongaon, Borsad, Bulandshahr, Burdwan, Calicut, Cannanore, Carson city, Chakan,pune ,
Chanchal, Chandigarh, Chas, Chengalpattu, Chennai, Chennai, india, Chennau, Chidambaram,
Chinchwad, Chittoor, Cochin, Coimbatore, Coimbatore ,, Coos bay, Coppet, Csir road,
taramani, chennai, Csm nagar, Cuddalore, Cuddalore district, Cuttack, Dabhoi, Dakor,
Dakpathar, Deharadun, Dehradun, Delhi, Dhamtari, Dhanbad, Dharmanagar, Dharwad, Dhule,
Dibrugarh, Dindigul, District- kurukshetra, Dombivili, Dombivli, Durg, Durgapur, Ernakulam,
Ernakulum, Ernamkulam, Erode, Faizabad, Faridabad, Faridkot, G.b. nagar, Gandhinagar,
Gandhinagar - , Gangtok, Gauttam budhha nagar, Gaziabaad, Gazibad, Ghaziabad, Goa,
Golaghat, Gorakhpur, Greater noida, Gujarat, Guna, Guntur, Gurdaspur, Gurgaon, Guwahati,
Gwalior, Hapur, Hardwar, Haridwar, Harihara, Haripura, Hassan, Hauzkhas, Hazaribagh,
Himatnagar, Ho chi minh, Hodal, Hoshiarpur, Howrah, Hubli, Hukkeri, Hydarabad, Hyderabad,
Hyderabad., Hyderbad, Ichalkaranji, India, Indore, J abalpur, J aipur, J akarta selatan, J alandhar,
J alandhar city, J algaon, J ammu, J amnagar, J amshedpur, J aspur, J aysingpur, J hunjhunu,
J odhpur, J unagadh, Kadampanad, Kadi, Kahangad, Kaithal, Kakinada, Kalamassery, kochi,
Kalambaste, Kalpakkam, Kalyan, Kalyan east , Kalyan west, Kancheepuram, Kanchipuram,
Kannur, Kannur., Kanpur, Kanyakumari district, Karad, Karaikal, Karaikudi, Karkala, Karnal,
Karunagappally, Kasaragod, Katpadi, Kesinga, Khammam, Khandwa, Khanna, Kharagpur,
Khopoli, Kochi, Kochi,, Kolahpur, Kolar gold field, Kolhapur, Kolkata, Kolkata,, Kollam,
Komarapalayam, Kopargaon, Kopergaon, Kota, Kota jn, Kotkapura, Kottayam, Kozhikode,
Kumarganj, dakshin dinajpur, Kurnool, Kurukshetra, Lalitpur, Lashkar gwalior, Latur, Lausanne,
Lonavala, Lonavla, London, Lucknow, Ludhiana, Machilipatnam, Madhyamgram, Madurai,
Madurai-2, Mahadevapura, bangalore, Mahape, navi mumbai, Mahesana, Malappuram, Malviya
nagar, Mandi, Mangalore, Mangalore, surathkal, Manglore, Manipal, Manipal, udupi, Mapusa,
Marcela, Margao , Margaon, Mathura, Meerut, Mehsana, Melur, Mettur dam, Mhow, Mhow,
district - indore, Miraroad, thane, Modinagar (ghaziabad), Mohali, Moradabad, Morjim, Moti
nagar, Mumbai, Mumbai thane , Mysore, Nadiad, Nagpur, Nalgonda, Nalla sopara, Namakkal
district, Namrup, Nanded, Nandyal, kurnool-district, Nashik, Nasik, Navi mumbai, Navsari,
Nazareth, Nazira, Neemuch, Nellore, Nellore dt, New delhi, New mumbai, New perungalathur,
Neyveli, Neyveli-3, Nipani, Nit faridabad, Noida, Noida / gautam budh nagar, Ongole,
Osmanabad, Palakkad, Palamaner, Pampady, Panaji, Panajim, Panchkula, Panjim, Pantnagar,
Panvel, Parkala, udupi district, Parwanoo, Patan, Patan(north gujarat), Pathankot, Patiala,
Patna, Payyanur, Penugonda, Petlad, Phagwara, Pilani, Pimple nilakha, pune, Pollachi, Ponda,
Pondicherry, Ponkunnam, Porvorim, Powai, Puducherry, Pudukkottai, Pun, Pune, Pune /
maharashtra, Pune 37, Pune, maharashtra, Punr, Puri, Raebareli, Raigarh, Raipur,
Rajahmundry, Rajapalayam, Rajkot, Rajsamand, Ramachandrapuram, Ramgarh cantt.,
Ramnthapuram, Rampur, Ranchi, Raniganj, Ratnagiri, Renigunta, Ribandar, Rishikesh, Rohtak,
Roorkee, Rourkela, Saharanpur, Salem, Samalkot, Sangli, Sangola, Sas nagar, mohali,
Saswad, Satara, Sector 82, noida, Secunderabad, Secunderbad, Secundrabad, Shahdara,
Shevgaon, Shimoga, Shirpur,dhule, Siliguri, Silvassa, Sindhanur, Singapore, Siolim, Sivakasi,
Sivasagar, Sojitra, Solan, Solapur, Sonepat, Sonipat, South goa, Sriharikota, Srinagar, Srinagar
garhwal, Surat, Surathkal, Suratkal, Surendranagar, Talegaon dabhade, Talod, Tamluk,
Tanuku, Tezpur, Thalassery, Thane, Thane (w), Thane [ west ] 400607, Thane west,
Thane(west), Thane-west, Thanjavur, Theni, Thiruvalla, Thiruvallore, Thiruvananthapuram,
Thiruvanathapuram, Thiruvannamalai, Thiruvannamalai district, Thookkupalam , Thrissur,
Tiruchengode, Tiruchirapalli, Tiruchirappalli, Tirunelveli, Tirupati, Tirupur, Tirupur., Tirur,
Tiruvannamalai, Trichur, Trichur, , Trichy, Trivandrum, Tumkur, Tuticorin, Udaipur, Udupi,
Ujjain, Ulhasnagar, Up, V. v. nagar, Vadodara, Vadododara, Vallab vidya nagar, Vallabh
vidyanagar, Valsad, Vapi, Varanasi, Vasai, Vasai east , thane district, Vasai road, Vasai road
(west), Vasc-da-gama, Vasco, Vasco da gama, Vasco-da-gama, Vashi, navi mumbai, Vellore,
Verna, Vidisha, Vijapur, Vijayawada, Virar (west), Virudhunagar, Visakhapatnam, Vithalwadi(w),
Vizianagaram, Warangal, Wardha, Warje malwadi,pune, Yamuna nagar, Yamunanagar, Yeola,
Zirakpur, Zuari nagar, Zuarinagar

You might also like