You are on page 1of 2

#include <avr/io.

h>
#include <util/delay.h>
#include <string.h>
#define dataport PORTB
#define commport PORTD
#define RS PD4
#define WR PD5
#define EN PD6
int
int
int
int

lcd_init(void);
lcd_senddata(unsigned char *);
WRcomm(void);
WRdata(void);

// this function to initialization lcd


int lcd_init(){
dataport=0x38;
WRcomm();
dataport=0x01;
WRcomm();
dataport=0x0E;
WRcomm();
dataport=0x80;
WRcomm();
return 1;}
// this function to send data
int lcd_senddata(unsigned char*s){
unsigned char*j=s;
e data
int i;
//strlen()#############
for(i=0;i<strlen(j);i++){
dataport=j[i];
WRdata();
}
return 1;
}
// this function to writ or read command
int WRcomm(void){
// commport=PORTD
commport&=~(1<<RS);
ruction
commport&=~(1<<WR);
commport|=(1<<EN);
writing data
commport&=~(1<<EN);
er ending from writing data
_delay_ms(100);
return 1;
}
// this function to writ or read data
int WRdata(void){
// commport=PORTD
commport|=(1<<RS);
a to lcd

//2line and 5*7 matrix


//writ instruction
// clear lcd
//writ instruction
// display on cursor
//writ instruction
// cursor at line 1 postion 1
//writ instruction

// defin matrix for stored th

//loop for send data


//sned data to lcd
// writ data to lcd

// setting RS =0 to send inst


//WR=0 for writ data to lcd
//EN=1 , Enable the LCD for
//EN=0 ,######## the LCD aft
//wait 10ms delay

// setting RS =1 for send dat

commport&=~(1<<WR);
commport|=(1<<EN);
iting data
commport&=~(1<<EN);
er ending from writing data
_delay_ms(100);
return 1;
}
int main(void){
DDRB=0xff;
a
DDRD=(1<<PD4)|(1<<PD5)|(1<<PD6);
t for send instruction
while(1){
lcd_init();
lcd_senddata("ibrahim abdullah");
dataport=0xc0;
this instruction"
WRcomm();
lcd_senddata("abdalrhman saleh");}
return 1;}

//WR=0 for writ data to lcd


//EN=1 Enable the LCD for wr
//EN=0 ,######## the LCD aft
//wait 10ms delay

//PORTB is output to writ dat


//PORTD 'PD4-PD5-PD6'is outpu
//infint loop
//initialization lcd
//send data to lcd
//display on and cursor off "
//to send instruction
//send data to lcd

You might also like