AVR ATmega32 Mini Development Board – Interfacing LCD
AVR ATmega32 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 “.SchematicSample 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 85 |
/************************************************************************************** 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 configured as output */ DDRD = 0X60; /* Control lines(RS-PD5,EN-PD6) configured as output */ _delay_us(15); Command(0x30); /* LCD Specification Command */ _delay_us(5); Command(0x30); /* LCD Specification Commands */ _delay_us(2); Command(0x30); /* LCD Specification Command */ Command(0x38); /* Double Line Display Command */ Command(0x06); /* Auto Increment Location Address */ Command(0x0C); /* Display ON Command */ Command(0x01); /* Clear Display Command */ _delay_us(1200); for(i=0; i<=16; i++) { Data(Array1[i]); /* Display Array1 */ } Command(0xC0); /* LCD command for display second row */ for(i=0; i<=16; i++) { Data(Array2[i]); /* Display Array2 */ } while(1); } /************************************************************************************** * Function : Command * * Description : Function to give a command to LCD * * Parameters : cmd - Command to be given ***************************************************************************************/ void Command(unsigned char cmd) { PORTD |= 0X40; /* RS-0 for command register,E-1,Enable pin made high*/ PORTB = cmd; /* Command loaded to data lines */ _delay_us(50); PORTD = 0X00; /* E-0, Enable pin made low */ } /************************************************************************************** * Function : Data * * Description : Function to display a character on LCD * * Parameters : dat - Character to be displayed ***************************************************************************************/ void Data(unsigned char dat) { PORTD |= 0X60; /* RS-1 for data register,E-1,Enable pin made high */ PORTB = dat; /* Data loaded to data lines */ _delay_us(50); PORTD = 0X00; /* E-0, Enable pin made low */ } /************************************************************************************** END OF PROGRAM ***************************************************************************************/ |
Topics related to AVR ATmega32 Mini Development Board
- AVR ATmega32 Mini Development Board – Overview
- AVR ATmega32 Mini Development Board – Interfacing LED
- AVR ATmega32 Mini Development Board – Interfacing LCD
- AVR ATmega32 Mini Development Board – Serial communication(USART)
- AVR ATmega32 Mini Development Board – Interfacing Switch
- AVR ATmega32 Mini Development Board – Interfacing Buzzer
- AVR ATmega32 Mini Development Board – Interfacing POT(ADC)
- AVR ATmega32 Mini Development Board – Interfacing Temperature sensor
- AVR ATmega32 Mini Development Board – Interfacing Servo Motor
- AVR ATmega32 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
Support
Please share your ideas with us, visit our forum for discussion
Leave a Reply
You must be logged in to post a comment.