Display Text in LCD Using AVR ATmega16 Mini Development Board
AVR ATmega16 Mini Development Board is interfaced with a LCD module (2×16) operating at 5V. The voltage at the third pin of the LCD can be varied by potentiometer to adjust contrast. LCD can work either in 4 or 8 bit mode. Here, the circuit is designed to work in 8-bit mode. Control lines RS & E are connected to port pins PD5 & PD6 respectively and data lines (D0-D7) to PORTB in 8-bit mode. For reliable Performance, LCD has to be initialized with certain basic. On powering, microcontroller sends initialization commands to LCD. The sample code below gives the LCD display, in line1 “Rhydo Technology” and in line 2 “ Cochin-17 “.
Schematic
Sample Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
/************************************************************************************** HEADER FILES ***************************************************************************************/ #define F_CPU 8000000UL #include<avr/io.h> #include<util/delay.h> /************************************************************************************** FUNCTION DECLARATIONS ***************************************************************************************/ void Command(unsigned char cmd); void Data(unsigned char dat); /************************************************************************************** VARIABLE DECLARATIONS ***************************************************************************************/ unsigned char Array1[]="Rhydo Technology"; unsigned char Array2[]=" Cochin-17 "; int i; /************************************************************************************** MAIN FUNCTION ***************************************************************************************/ int main() { DDRB = 0xFF; /* LCD data lines */ DDRD = 0X60; /* LCD Control lines(RS(PD5),RW(GND),EN(PD6) */ _delay_us(15); /* Minimum Delay To Power On LCD - Recieve Mode */ Command(0x30); /* LCD Specification Cmdmands */ _delay_us(5); Command(0x30); /* LCD Specification Commands */ _delay_us(2); Command(0x30); /* LCD Specification Commands */ Command(0x38); /* LCD Double Line Display Comdmand */ Command(0x06); /* LCD Auto Increment Location Address Cmdmand */ Command(0x0C); /* LCD Display ON Cmdmand */ Command(0x01); /* LCD Display Clear Cmdmand */ _delay_us(1200); for(i=0;i<=16;i++) { Data(Array1[i]); /* LCD display function */ } Command(0xC0); /* LCD command for display secod raw */ for(i=0;i<=16;i++) { Data(Array2[i]); /* LCD display function */ } while(1); } /*************************************************************************************** * Function : Command * Description : Function to send a command to LCD * Parameters : cmd, contains the command to be send ***************************************************************************************/ void Command(unsigned char cmd) { PORTD |= 0X40; /* contol line RS-0(cmd register),R/W-GND(write), E-1(enable) */ PORTB = cmd; /* command loaded to data port */ _delay_us(50); /* Minimun Delay For Hold On Data */ PORTD = 0X00; /* contol line RS-0(cmd register),R/W-GND(write), E-0(enable) */ } /************************************************************************************** * Function : Data * Description : Function to send a data to LCD * Parameters : dat, contains the data to be send ***************************************************************************************/ void Data(unsigned char dat) { PORTD |= 0X60; /* contol line RS-1(data register),R/W - GND(write), E-1(enable) */ PORTB = dat; /* data loaded to data port */ _delay_us(50); /* Minimun Delay For Hold On Data */ PORTD = 0X00; /* contol line RS-0(data register),R/W - GND(write), E-0(enable) */ } /************************************************************************************** END OF PROGRAM ***************************************************************************************/ |
Topics related to AVR ATmega16 Mini Development Board
- AVR ATmega16 Mini Development Board – Overview
- AVR ATmega16 Mini Development Board - Interfacing LED
- AVR ATmega16 Mini Development Board – Interfacing LCD
- AVR ATmega16 Mini Development Board – Serial communication(USART)
- AVR ATmega16 Mini Development Board – Interfacing Switch
- AVR ATmega16 Mini Development Board – Interfacing Buzzer
- AVR ATmega16 Mini Development Board - Interfacing POT(ADC)
- AVR ATmega16 Mini Development Board – Interfacing Temperature sensor
- AVR ATmega16 Mini Development Board – Interfacing Servo Motor
- AVR ATmega16 Mini Development Board – Interfacing μRFID
Resources
How to buy?
- Click here to buy rhydoLABZ AVR ATmega16 Development Board-Mini
- Click here to buy rhydoLABZ AVR ATmega32 Development Board-Mini
SupportPlease share your ideas with us, visit our forum for discussion