SlideShare uma empresa Scribd logo
1 de 3
#include<avr/io.h> //include avr header file
#include<util/delay.h> //include delay header file
#define LCD_PRT PORTC // define portb as a lcd port
#define LCD_DDR DDRC //define ddr for lcd
/*#define LCD_PIN PINB
#define LCD_RS 0
#define LCD_RW 1
#define LCD_EN 2*/
void lcdcommand( unsigned char cmnd )
{
//to send higher bit of cmnd to LCD_PRT
LCD_PRT=(LCD_PRT & 0X0F) | (cmnd & 0XF0); //masking of portb in nibbles
LCD_PRT = (LCD_PRT&0b11111100); //FOR MAKING RS=0, RW=0
LCD_PRT = (LCD_PRT|0b00000100); //FOR MAKING EN=1
_delay_us(100);
LCD_PRT = (LCD_PRT&0b11111011); //FOR MAKING EN=0
_delay_us(500);
//to send lower bit of cmd to LCD_PRT
LCD_PRT=(LCD_PRT & 0X0F) | (cmnd << 4);
LCD_PRT = (LCD_PRT|0b00000100);/*FOR MAKING EN=1*/
_delay_us(100);
LCD_PRT = (LCD_PRT&0b11111011);/*FOR MAKING EN=0*/
_delay_us(500);
}
void lcddata( unsigned char data ) //Function to send data to LCD
{
LCD_PRT = (LCD_PRT & 0x0F) | (data & 0xF0); //to send higher bit of cmnd to
LCD_PRT
LCD_PRT = (LCD_PRT|0b00000001); /*FOR MAKING RS=1*/
LCD_PRT = (LCD_PRT&0b11111101); /*FOR MAKING RW=0*/
LCD_PRT = (LCD_PRT|0b00000100); /*FOR MAKING EN=1*/
_delay_us(100);
LCD_PRT = (LCD_PRT&0b11111011); /*FOR MAKING EN=0*/
_delay_us(500);
LCD_PRT = (LCD_PRT & 0x0F)|(data<<4); //to send lower bit of data to
LCD_PRT
LCD_PRT = (LCD_PRT|0b00000100); /*FOR MAKING EN=1*/
_delay_us(100);
LCD_PRT = (LCD_PRT&0b11111011); /*FOR MAKING EN=0*/
_delay_us(500);
}
void lcd_init() //Function to initialize the LCD
{
LCD_DDR=0xFF; //LCD port as output port
LCD_PRT = (LCD_PRT&0b11111011); //FOR MAKING EN=0
lcdcommand(0x33);
_delay_us(1000);
lcdcommand(0x32);
_delay_us(1000);
lcdcommand(0x28); //these three command are for 4 bit LCD
mode
_delay_us(1000);
lcdcommand(0x0E); //display on cursor on
_delay_us(1000);
lcdcommand(0x01); //to clear display
_delay_us(1000);
lcdcommand(0x06); //shift the cursor to right
_delay_us(1000);
}
void lcd_gotoxy(unsigned char x,unsigned char y) // Function to set a
starting position on 16x2 LCD
{
unsigned char firstcharadr[]={ 0x80, 0xC0};
lcdcommand(firstcharadr [y-1]+x-1);
_delay_us(2000);
}
void lcd_puts(char *str) // Function to send a string to LCD
{
unsigned char i=0;
while(str[i]!=0)
{
lcddata(str[i]);
_delay_ms(1000);
i++;
}
}
void lcd_clr(void) // Function to clear the lcd
{
lcdcommand(0x01);
_delay_ms(2000);
}
int main(void)
{
lcd_init();
while(1)
{
lcd_gotoxy(1,1);
lcd_puts("E&C");
_delay_ms(2000);
_delay_ms(100);
lcd_gotoxy(1,2);
lcd_puts("SRMSCET");
_delay_ms(9000);
lcd_clr();
}
}

Mais conteúdo relacionado

Mais procurados

PWM based motor speed control using LPC 1768
PWM based motor speed control using LPC 1768PWM based motor speed control using LPC 1768
PWM based motor speed control using LPC 1768Omkar Rane
 
20170127 tokyoserversideswiftmeetup資料
20170127 tokyoserversideswiftmeetup資料20170127 tokyoserversideswiftmeetup資料
20170127 tokyoserversideswiftmeetup資料jugemjugemjugem
 
Stevens HFC2009
Stevens HFC2009Stevens HFC2009
Stevens HFC2009jzw200
 
C++ hello world
C++ hello worldC++ hello world
C++ hello worldAL- AMIN
 

Mais procurados (6)

PWM based motor speed control using LPC 1768
PWM based motor speed control using LPC 1768PWM based motor speed control using LPC 1768
PWM based motor speed control using LPC 1768
 
20170127 tokyoserversideswiftmeetup資料
20170127 tokyoserversideswiftmeetup資料20170127 tokyoserversideswiftmeetup資料
20170127 tokyoserversideswiftmeetup資料
 
Gray code
Gray code Gray code
Gray code
 
Stevens HFC2009
Stevens HFC2009Stevens HFC2009
Stevens HFC2009
 
Codigo
CodigoCodigo
Codigo
 
C++ hello world
C++ hello worldC++ hello world
C++ hello world
 

Semelhante a Atmega lcd programing_with_header_file

Microcontroladores: programas de CCS Compiler.docx
Microcontroladores: programas de CCS Compiler.docxMicrocontroladores: programas de CCS Compiler.docx
Microcontroladores: programas de CCS Compiler.docxSANTIAGO PABLO ALBERTO
 
codings related to avr micro controller
codings related to avr micro controllercodings related to avr micro controller
codings related to avr micro controllerSyed Ghufran Hassan
 
code for DTMF and bluetooth based digital switch board
code for DTMF and bluetooth based digital switch boardcode for DTMF and bluetooth based digital switch board
code for DTMF and bluetooth based digital switch boardNilgiri publicity
 
Embedded Systems Project 3rd Year
Embedded Systems Project 3rd YearEmbedded Systems Project 3rd Year
Embedded Systems Project 3rd YearAndrew Kozik
 
Gsm modem interfacing with pic microcontroller
Gsm modem interfacing with pic microcontrollerGsm modem interfacing with pic microcontroller
Gsm modem interfacing with pic microcontrollerYonas Andualem
 
Gaztea Tech Robotica 2016
Gaztea Tech Robotica 2016Gaztea Tech Robotica 2016
Gaztea Tech Robotica 2016Svet Ivantchev
 
Quanta ze7 r1b_schematics
Quanta ze7 r1b_schematicsQuanta ze7 r1b_schematics
Quanta ze7 r1b_schematicsDATACORP
 
#include LPC17xx.h#include Lights.h#include traffic_fo.docx
#include LPC17xx.h#include Lights.h#include traffic_fo.docx#include LPC17xx.h#include Lights.h#include traffic_fo.docx
#include LPC17xx.h#include Lights.h#include traffic_fo.docxajoy21
 
DEF CON 23 - Rodringo Almeida - embedded system design from electronics
DEF CON 23 - Rodringo Almeida - embedded system design from electronics DEF CON 23 - Rodringo Almeida - embedded system design from electronics
DEF CON 23 - Rodringo Almeida - embedded system design from electronics Felipe Prado
 
Linux Serial Driver
Linux Serial DriverLinux Serial Driver
Linux Serial Driver艾鍗科技
 
Microcontroller Programming Assignment
Microcontroller Programming AssignmentMicrocontroller Programming Assignment
Microcontroller Programming Assignmentbabak danyal
 
PWM wave generator using microcontroller
 PWM wave generator using microcontroller  PWM wave generator using microcontroller
PWM wave generator using microcontroller Swapnil2515
 

Semelhante a Atmega lcd programing_with_header_file (20)

PIC and LCD
PIC and LCDPIC and LCD
PIC and LCD
 
LCD_Example.pptx
LCD_Example.pptxLCD_Example.pptx
LCD_Example.pptx
 
Microcontroladores: programas de CCS Compiler.docx
Microcontroladores: programas de CCS Compiler.docxMicrocontroladores: programas de CCS Compiler.docx
Microcontroladores: programas de CCS Compiler.docx
 
131080111003 mci
131080111003 mci131080111003 mci
131080111003 mci
 
codings related to avr micro controller
codings related to avr micro controllercodings related to avr micro controller
codings related to avr micro controller
 
code for DTMF and bluetooth based digital switch board
code for DTMF and bluetooth based digital switch boardcode for DTMF and bluetooth based digital switch board
code for DTMF and bluetooth based digital switch board
 
Embedded Systems Project 3rd Year
Embedded Systems Project 3rd YearEmbedded Systems Project 3rd Year
Embedded Systems Project 3rd Year
 
LCD Keypad Shield
LCD Keypad ShieldLCD Keypad Shield
LCD Keypad Shield
 
Gsm modem interfacing with pic microcontroller
Gsm modem interfacing with pic microcontrollerGsm modem interfacing with pic microcontroller
Gsm modem interfacing with pic microcontroller
 
Direct analog
Direct analogDirect analog
Direct analog
 
Gaztea Tech Robotica 2016
Gaztea Tech Robotica 2016Gaztea Tech Robotica 2016
Gaztea Tech Robotica 2016
 
_LCD display-mbed.pdf
_LCD display-mbed.pdf_LCD display-mbed.pdf
_LCD display-mbed.pdf
 
Quanta ze7 r1b_schematics
Quanta ze7 r1b_schematicsQuanta ze7 r1b_schematics
Quanta ze7 r1b_schematics
 
#include LPC17xx.h#include Lights.h#include traffic_fo.docx
#include LPC17xx.h#include Lights.h#include traffic_fo.docx#include LPC17xx.h#include Lights.h#include traffic_fo.docx
#include LPC17xx.h#include Lights.h#include traffic_fo.docx
 
DEF CON 23 - Rodringo Almeida - embedded system design from electronics
DEF CON 23 - Rodringo Almeida - embedded system design from electronics DEF CON 23 - Rodringo Almeida - embedded system design from electronics
DEF CON 23 - Rodringo Almeida - embedded system design from electronics
 
Linux Serial Driver
Linux Serial DriverLinux Serial Driver
Linux Serial Driver
 
Microcontroller Programming Assignment
Microcontroller Programming AssignmentMicrocontroller Programming Assignment
Microcontroller Programming Assignment
 
Lampiran 1.programdocx
Lampiran 1.programdocxLampiran 1.programdocx
Lampiran 1.programdocx
 
PWM wave generator using microcontroller
 PWM wave generator using microcontroller  PWM wave generator using microcontroller
PWM wave generator using microcontroller
 
Pwm wave
Pwm wave Pwm wave
Pwm wave
 

Mais de ABHISHEK MAURYA

Data_storage_Flash_Memory.pptx
Data_storage_Flash_Memory.pptxData_storage_Flash_Memory.pptx
Data_storage_Flash_Memory.pptxABHISHEK MAURYA
 
Installation process of Arduino
Installation process of ArduinoInstallation process of Arduino
Installation process of ArduinoABHISHEK MAURYA
 
Basic electronics component
Basic electronics componentBasic electronics component
Basic electronics componentABHISHEK MAURYA
 
An industrial training ppt at Hal lucknow
An industrial training ppt at Hal lucknowAn industrial training ppt at Hal lucknow
An industrial training ppt at Hal lucknowABHISHEK MAURYA
 

Mais de ABHISHEK MAURYA (6)

Data_storage_Flash_Memory.pptx
Data_storage_Flash_Memory.pptxData_storage_Flash_Memory.pptx
Data_storage_Flash_Memory.pptx
 
ATMEGA 328
ATMEGA 328ATMEGA 328
ATMEGA 328
 
IMAGE PROCESSING
IMAGE PROCESSINGIMAGE PROCESSING
IMAGE PROCESSING
 
Installation process of Arduino
Installation process of ArduinoInstallation process of Arduino
Installation process of Arduino
 
Basic electronics component
Basic electronics componentBasic electronics component
Basic electronics component
 
An industrial training ppt at Hal lucknow
An industrial training ppt at Hal lucknowAn industrial training ppt at Hal lucknow
An industrial training ppt at Hal lucknow
 

Último

Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxpurnimasatapathy1234
 
result management system report for college project
result management system report for college projectresult management system report for college project
result management system report for college projectTonystark477637
 
UNIT-III FMM. DIMENSIONAL ANALYSIS
UNIT-III FMM.        DIMENSIONAL ANALYSISUNIT-III FMM.        DIMENSIONAL ANALYSIS
UNIT-III FMM. DIMENSIONAL ANALYSISrknatarajan
 
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Serviceranjana rawat
 
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
Introduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxIntroduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxupamatechverse
 
Extrusion Processes and Their Limitations
Extrusion Processes and Their LimitationsExtrusion Processes and Their Limitations
Extrusion Processes and Their Limitations120cr0395
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130Suhani Kapoor
 
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSHARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSRajkumarAkumalla
 
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlysanyuktamishra911
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSKurinjimalarL3
 
UNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its PerformanceUNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its Performancesivaprakash250
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escortsranjana rawat
 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxAsutosh Ranjan
 
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...roncy bisnoi
 
Introduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxIntroduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxupamatechverse
 
Introduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxIntroduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxupamatechverse
 

Último (20)

Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptx
 
result management system report for college project
result management system report for college projectresult management system report for college project
result management system report for college project
 
UNIT-III FMM. DIMENSIONAL ANALYSIS
UNIT-III FMM.        DIMENSIONAL ANALYSISUNIT-III FMM.        DIMENSIONAL ANALYSIS
UNIT-III FMM. DIMENSIONAL ANALYSIS
 
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
 
Roadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and RoutesRoadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and Routes
 
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
 
Introduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxIntroduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptx
 
Extrusion Processes and Their Limitations
Extrusion Processes and Their LimitationsExtrusion Processes and Their Limitations
Extrusion Processes and Their Limitations
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
 
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSHARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
 
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghly
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
 
UNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its PerformanceUNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its Performance
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptx
 
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
 
Introduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxIntroduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptx
 
Introduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxIntroduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptx
 

Atmega lcd programing_with_header_file

  • 1. #include<avr/io.h> //include avr header file #include<util/delay.h> //include delay header file #define LCD_PRT PORTC // define portb as a lcd port #define LCD_DDR DDRC //define ddr for lcd /*#define LCD_PIN PINB #define LCD_RS 0 #define LCD_RW 1 #define LCD_EN 2*/ void lcdcommand( unsigned char cmnd ) { //to send higher bit of cmnd to LCD_PRT LCD_PRT=(LCD_PRT & 0X0F) | (cmnd & 0XF0); //masking of portb in nibbles LCD_PRT = (LCD_PRT&0b11111100); //FOR MAKING RS=0, RW=0 LCD_PRT = (LCD_PRT|0b00000100); //FOR MAKING EN=1 _delay_us(100); LCD_PRT = (LCD_PRT&0b11111011); //FOR MAKING EN=0 _delay_us(500); //to send lower bit of cmd to LCD_PRT LCD_PRT=(LCD_PRT & 0X0F) | (cmnd << 4); LCD_PRT = (LCD_PRT|0b00000100);/*FOR MAKING EN=1*/ _delay_us(100); LCD_PRT = (LCD_PRT&0b11111011);/*FOR MAKING EN=0*/ _delay_us(500); } void lcddata( unsigned char data ) //Function to send data to LCD { LCD_PRT = (LCD_PRT & 0x0F) | (data & 0xF0); //to send higher bit of cmnd to LCD_PRT LCD_PRT = (LCD_PRT|0b00000001); /*FOR MAKING RS=1*/ LCD_PRT = (LCD_PRT&0b11111101); /*FOR MAKING RW=0*/ LCD_PRT = (LCD_PRT|0b00000100); /*FOR MAKING EN=1*/ _delay_us(100); LCD_PRT = (LCD_PRT&0b11111011); /*FOR MAKING EN=0*/ _delay_us(500); LCD_PRT = (LCD_PRT & 0x0F)|(data<<4); //to send lower bit of data to LCD_PRT LCD_PRT = (LCD_PRT|0b00000100); /*FOR MAKING EN=1*/ _delay_us(100); LCD_PRT = (LCD_PRT&0b11111011); /*FOR MAKING EN=0*/ _delay_us(500); } void lcd_init() //Function to initialize the LCD { LCD_DDR=0xFF; //LCD port as output port
  • 2. LCD_PRT = (LCD_PRT&0b11111011); //FOR MAKING EN=0 lcdcommand(0x33); _delay_us(1000); lcdcommand(0x32); _delay_us(1000); lcdcommand(0x28); //these three command are for 4 bit LCD mode _delay_us(1000); lcdcommand(0x0E); //display on cursor on _delay_us(1000); lcdcommand(0x01); //to clear display _delay_us(1000); lcdcommand(0x06); //shift the cursor to right _delay_us(1000); } void lcd_gotoxy(unsigned char x,unsigned char y) // Function to set a starting position on 16x2 LCD { unsigned char firstcharadr[]={ 0x80, 0xC0}; lcdcommand(firstcharadr [y-1]+x-1); _delay_us(2000); } void lcd_puts(char *str) // Function to send a string to LCD { unsigned char i=0; while(str[i]!=0) { lcddata(str[i]); _delay_ms(1000); i++; } } void lcd_clr(void) // Function to clear the lcd { lcdcommand(0x01); _delay_ms(2000); } int main(void) { lcd_init(); while(1) { lcd_gotoxy(1,1); lcd_puts("E&C");