Saturday, 24 August 2013

INTERFACING LCD WITH ATMEGA16/32.....

Posted by Unknown On 18:11 | No comments

LCD INTERFACING WITH ATmega16 by RAJ PRAJAPATI


THIS IS THE CODE WRITTEN BY ME FOR THE 8 BIT MODE FOR LCD INTERFACING...


/*HEADER FILE TO USE LCD IN 8 BIT MODE
  PORTA FOR DATA PINS OF LCD
                                                PA0=DB0
                                                PA1=DB1
                                                PA2=DB2
                                                PA3=DB3
                                                PA4=DB4
                                                PA5=DB5
                                                PA6=DB6
                                                PA7=DB7
                PORTB
                                                PB0=RS
                                                PB1=RW
                                                PB2=RN
  DESIGNED BY:-                RAJ PRAJAPATI (NAGPUR INSTITUTE OF TECHNOLOGY, NAGPUR)
*/
/*---------------------------------------------------------------------------------------------------*/
                                                                //HEADER FILES
#include<avr/io.h>
#include<util/delay.h>
#include<stdlib.h>
/*----------------MACROS--------------------*/
#define rs 0
#define rw 1
#define en 2





/*---------------PIN CONFIGURATION--------------------------------*/
//PORTA =DATA PIN
//PORTB.0=rs
//PORTB.1=rw
//PORTB.2=en
/*--------------FUNCTION PROTOTYPE--------------------------------*/
void lcd_init_raj();
void lcd_cmd_raj(unsigned char);
void lcd_data_raj(unsigned char);
void enable_raj();
void lcd_puts_raj(unsigned char *);
void lcd_clrscr_raj();
void lcd_gotoxy_raj(unsigned char,unsigned char);
void delay(unsigned int);
void lcd_shift_left_raj(unsigned int);
void lcd_shift_right_raj(unsigned int);
void lcd_value_raj(long double int);
void busy_raj(void);
#endif

/*--------------FUNCTION DEFINITIONS-----------------------------*/
void lcd_value_raj(long double int x)
{
                                                unsigned char buf[16];
                                                sprintf(buf,"%le",x);
                                                lcd_puts_raj(buf);
                                                delay(100);

}




void busy_raj(void)
{
                unsigned int bit,X;
                DDRA=0b01111111;
                X=PINB;
                PORTB&=~(1<<rs);
                PORTB|=(1<<rw);
                PORTB&=~(1<<en);
                delay(2);
                PORTB|=(1<<en);
                bit=0x80&X;
                while(bit==0x80);
                DDRA=0xff;
                DDRB=0xff;
               
}

void lcd_shift_left_raj(unsigned int i)
{
                for(int x=1;x<=i;x++)
                {             
                                lcd_cmd_raj(0x18);
                                delay(300);
                }
}
void lcd_shift_right_raj(unsigned int i)
{
                for(int x=1;x<=i;x++)
                {             
                                lcd_cmd_raj(0x1c);
                                delay(300);
                }
}


CONTACT FOR FULL CODE :.......

0 comments:

Post a Comment

Blogroll

Copyright © 2013 RAJ PRAJAPATI (raj@electronicsrj.com)

Comments

About Projects

We also Provide support in making Electronics Projects at different level at Cheapest price. Contact Us for the further help.