

Also send 28 in hex to set it in the 2 line, 15x7 matrix pixels in 4-bit mode. Then set the LCD in the 4-bit mode by sending 02 in hex. Here, the PORT is set as OUTPUT so set FF. Initially set the PORT direction for LCD to interface. Now in the main function, the LCD is initialized. void lcdCommand( unsigned char commands )

The one packets will be Upper Nibble (4-bit) and other packet will be Lower Nibble (4-bit). Since we are using the 4-bit Mode of LCD, the byte (8-bit) will be sent in two packets. The Hex Commands are used to define the function of LCD. Next step is to construct a function which will accept a command by passing a parameter. #define lcdDirection DDRA #define lcdPort PORTA #define en PA3 #define rs PA2Īlso define that which PORT of Atmega16 will be used to interface LCD. The RS Pins is used to select the data and command register.

#include ĭefine RS and EN pin of LCD in the program. Initially define the CPU Frequency and include the necessary libraries which comes with Atmel Studio Package such as for accessing IO pins and for generating delay in the program. Complete Program and Working Video is given at the end of the project, just upload the program in Atmega16 and rotate 10k POT to adjust the brightness of LCD. Here the Atmega16 is programmed using USBASP and Atmel Studio7.0. Programming doesn’t require any external libraries.
