Here we interface a 16x2 alphanumeric LCD with ATmega16 which is a AVR controller.
Pin configuration is written behind this LCD as...
1 - GND
2 - VCC (+5V)
3 - VEE (FOR CONTRAST)
4 - RS (REGISTER SELECT)
5 - RW (READ/WRITE)
6 - EN (ENABLE)
7-14 - DATA PINS D0-D7
15 - LED PLUS
16 - LED MINUS
----------------------------------------------------------------------------------------------------------------------
#include <mega16.h>
// Alphanumeric LCD Module functions
#asm
.equ __lcd_port=0x15 ;PORTC
#endasm
#include <lcd.h>
void main(void)
{
// LCD module initialization
lcd_init(16);
while (1)
{
lcd_gotoxy(0,0);
lcd_putsf("ashish");
}
}
-----------------------------------------------------------------------------------------------------------------------
Proteus simulation of both codes :-
Note :- If you have problem to see characters in LCD then reduce the contrast level of LCD by increasing the resistance of 10k variable resistor.
1 - GND
2 - VCC (+5V)
3 - VEE (FOR CONTRAST)
4 - RS (REGISTER SELECT)
5 - RW (READ/WRITE)
6 - EN (ENABLE)
7-14 - DATA PINS D0-D7
15 - LED PLUS
16 - LED MINUS
Components required :-
- 10k ohm registance
- 10k ohm variable registance
- 8 MHZ crystal oscilltor
- 16x2 LCD
- ATmega16 IC
- 12v battery
- Toggle button
- 7805 IC
- 330 ohm resistance
- 1N4007 diode
- 1000uf capacitor
- Green LED
Circuit diagram : -
In 4-bit mode ground the first 4 data pins of LCD means pin 7-11. make the connections as shown above.
Code (compiled in AVR studio 4) :-
(see.. AVR STUDIO 4 TUTORIAL)
Note :- In AVR studio 4 for compiling the program a makefile is necessary to create.
(see.. HOW TO CREATE A MAKEFILE)
Add this makefile in STUDIO 4. This makefile and lcd.c and lcd.h files must be in the same folder of project. Click below links go to file>download.
-----------------------------------------------------------------------------------------------------------------------
#include<avr/io.h>
#include<util/delay.h>
#include"lcd.h"
int main(void)
{
lcd_init(LCD_DISP_ON);
lcd_clrscr();
while(1)
{
lcd_gotoxy(3,0);
lcd_putc('E');
_delay_ms(500);
lcd_gotoxy(6,0);
lcd_puts("FOR");
_delay_ms(500);
lcd_gotoxy(3,1);
lcd_puts("ENGINEERS");
_delay_ms(500);
}
}
-----------------------------------------------------------------------------------------------------------------------
Code (compiled in CVAVR) :-
(see.. CVAVR TUTORIAL (CODE VISION AVR))
Note :- In CVAVR program window delete all the lines and paste the code given below. because there are so much unnecessary lines.
#include <mega16.h>
// Alphanumeric LCD Module functions
#asm
.equ __lcd_port=0x15 ;PORTC
#endasm
#include <lcd.h>
void main(void)
{
// LCD module initialization
lcd_init(16);
while (1)
{
lcd_gotoxy(0,0);
lcd_putsf("ashish");
}
}
-----------------------------------------------------------------------------------------------------------------------
Proteus simulation of both codes :-
Note :- If you have problem to see characters in LCD then reduce the contrast level of LCD by increasing the resistance of 10k variable resistor.
4 comments:
Cant get anything on LCD.
Tried changing Contrast. Gets only 1 Line black dots continuosly. Connections are exactly as mentioned.
I m using Atmega16L. Frequency of system is 8MHz. No ossicilators i have used.
Plz help me.
Which compiler u are using. ?
you can have hand in both 4 bit and 8 bit working perfectly with proteus simulation. here i found some post while looking up over net.
http://www.mechaterrain.com/lcd-interfacing4bit-mode
you can have hand in both 4 bit and 8 bit working perfectly with proteus simulation. here i found some post while looking up over net.
http://www.mechaterrain.com/lcd-interfacing4bit-mode
Post a Comment