/*---------------------------------------------------------------- -------------------- HEADER FILES ------------------------------- -----------------------------------------------------------------*/ #include #include #include /*---------------------------------------------------------------- ------------- DEFINITIONS ------------------------------------- -----------------------------------------------------------------*/ #define DATA_DDR DDRC // ENTER THE PORT WHICH CONTROLS #define DATA_PORT PORTC // THE DATA PINS D0 TO D7 #define CONTROL_DDR DDRD // ENTER THE PORT WHICH CONTROLS #define CONTROL_PORT PORTD // THE CONTROL PINS #define Enable 2 // CoNNECTION OF ENABLE TO PIN OF ABOVE PORT #define RS 0 // CoNNECTION OF RegisterSelect TO PIN OF ABOVE PORT #define RW 1 // CoNNECTION OF Read/~Write TO PIN OF ABOVE PORT #define CONTROL_MASK 0X07 // CHANGE THIS VALUE CONSIDERING THE PINS ABOVE AS HIGH /*---------------------------------------------------------------- -------------CONTROL BITS OF LCD -------------------------------- -----------------------------------------------------------------*/ #define Set_Enable CONTROL_PORT |=_BV(Enable) // THE MACROS HERE ARE #define Clear_Enable CONTROL_PORT &=~_BV(Enable) //SELF EXPLANATORY #define Write_Lcd CONTROL_PORT &=~_BV(RW) // #define Read_Lcd CONTROL_PORT |=_BV(RW) // #define Select_InstructionRegister CONTROL_PORT &=~_BV(RS) // #define Select_DataRegister CONTROL_PORT |=_BV(RS) // #define Data_Lcd(b) DATA_PORT=b // #define delay(b) _delay_ms(b) // /*---------------------------------------------------------------- -----------------FUNCTION DECLARATIONS --------------------------- -----------------------------------------------------------------*/ void Init_Ports(void); // Initialise Ports , Necessary for selecting input output pins in the MCU void Init_Lcd(void); // Initialise LCD , Necessary for starting and clearing LCD screen void Lcd_Send(unsigned char a); // For sending a character to the LCD void newline(void); // For printing characters on the next line in the LCD /*---------------------------------------------------------------- ----------------MAIN FUNCTION-------------------------------------- -----------------------------------------------------------------*/ void main() { int len,len1,len2; char str1[] = "Ankit Daftery"; // String to be printed in 1st line char str2[] = "'Tronix & Proud"; // String to be printed in 2nd line Init_Ports(); Init_Lcd(); len1=strlen(str1); len2=strlen(str2); for (len=0;len