Escolar Documentos
Profissional Documentos
Cultura Documentos
LCD INTERFACING
Introduction
What is the basic difference between 8-bit mode and 4bit mode?
How to write code for LCD interfacing in C language
and what are the basic commands used for LCD
programming.
It also includes how to program LCD and sends
command/ data to LCD.
Hardware requirements:
Atmega32
16x2
ic
lcd display
Breadboard
8Mhz
crystal oscillator
Power
supply
Software requirements:
AVR
studio 4
WHAT IS LCD?
PIN NO.
PIN NAME
DESCRIPTION
Supply pin (+5V
VCC
VDD
Ground pin
VEE
Contrast pin
DC)
Register
selection pin
(either data or
4
RS
command)RS=0:
PIN NO.
PIN NAME
DESCRIPTION
Selects Read or
Write
RW
operationRW=0: for
write
RW=1: for read
Enable pin
D0
Data pin 0
D1
Data pin 1
D2
Data pin 2
10
D3
Data pin 3
#include<avr/delay.h>
command_write (unsigned char);
data_write (unsigned char);
ready();
main();
delay();
{
unsigned char command[]={0x38,0x01,0x0e,0x06,0x80};
unsigned char data[]={'V','B','I','T'};
unsigned char i;
DDRA=0xFF;
DDRB=0x07;
for(i=0;i<=4;i++)
// for loop execution 4 times
{
command_write(command[i]); //command write from unsigned
char command
_delay_ms(2);
// 2ms delay
}
for(i=0;i<=7;i++)
{
data_write(data[i]);
}
}
//subroutine
command_write (unsigned char m)
{
_delay_ms(5);
PORTA=m;
m
//5ms delay
// port A is equal to unsigned char
//2ms delay
data_write(unsigned char n)
{
_delay_ms(5);
PORTA=n;
//5ms delay
// port A is equal to unsigned char
n
PORTB=PORTB | 0x01;
PORTB=PORTB | 0x04;
_delay_ms(2);
//2ms delay
Void ready()
{
DDRB=DDRA & 0xFF;
PORTB=PORTB | 0x02;
_delay_ms(2);
//2ms delay
PORTB=PORTB | 0x04;
while( PORTB&0x08);
DDRA=DDRA|0x01;
Clear screen
0x02
return home
0x04
Cursor decrement
0x05
0x07
0x08
0x10
COMMANDS
0x80
0x0C
0XC0
DESCRIPTION
Move cursor to the beginning
of first line
Display ON, cursor OFF
Move cursor to the beginning
of second line
0x0A
0x0E
0x30
0x20
THANK YOU