Jul 18, 2012 - Projects    Comments Off

LCD Display (LM016L) (2×16)

The LCD Display is one of the most important projects which can help you to display your project result clearly. the LCD which we are using in this project is: LM016L which comes in 2 rows and 16 columns.

Note: before you connect the Physical LCD to your PIC, make sure to read the correct port number on the Back of the LCD and don’t connect it as shown in figure – as the ports on physical Hardware are on different location.

Software Needed:

  1. mikroC – for code writing
  2. Protues – for hardware simulation


Hardware Needed:

  1. Power 5 Volts DC
  2. 10 K-Ohm Variable resistor (to change display contrast)
  3. Ground
  4. PIC 16F877
  5. Oscillator 1 MHz (or any other number)
  6. LCD LM016L (2×16)


Software Idea & Code:

the idea of this project is to display 2 lines of solid text, ROW1: will display: “Welcome Embedded” which is already 16 characters which is the maximum number of characters on each row.

on ROW2 we will display “Students” which is 8 characters, and we will let this word to be scrolling from location 1 to the end of the screen.

since the screen width is 16 characters, and we want to display the word STUDENTS which is 8 characters, so we should do small calculation to know the last position: 16-8 = 8 <- so we can scroll from position 1 to position 8 only !

in this code we will do 2 loops, the 1st loop to move the word students from position 0 to position 8, then the 2nd loop will move the same word from position 8 to position 0 … if we keep infinite loop for both then the word will be scrolling continuously.



// LCD module connections
   sbit LCD_RS at RB2_bit;
   sbit LCD_EN at RB3_bit;
   sbit LCD_D4 at RB4_bit;
   sbit LCD_D5 at RB5_bit;
   sbit LCD_D6 at RB6_bit;
   sbit LCD_D7 at RB7_bit;
   sbit LCD_RS_Direction at TRISB2_bit;
   sbit LCD_EN_Direction at TRISB3_bit;
   sbit LCD_D4_Direction at TRISB4_bit;
   sbit LCD_D5_Direction at TRISB5_bit;
   sbit LCD_D6_Direction at TRISB6_bit;
   sbit LCD_D7_Direction at TRISB7_bit;
// End LCD module connections

//Start the program
void main()

   TRISB=0;   //set port B as output

   PORTB=0;   //initialize port B to output

   int i,j;   

   //Infinite Loop

      //1st for loop to move the word Students from position 1 to position 8
for (i=1; i<10; i++)


         Lcd_Init();   // Initialize LCD
         Lcd_Cmd(_LCD_CLEAR);   //Clear the Screen
         Lcd_Out(1,1,”Welcome Embedded”);   //position: row=1 & column=1 , text=”Welcome Embedded”
         Lcd_Out(2,i,”Students”);    //position: row=2 & column= i (variable number from 1 to 9) , text=”Students”
         Lcd_Cmd(_LCD_CURSOR_OFF);   //Set Cursor Square OFF (Hidden)
 delay_ms(300);    //delay for 300 mili seconds
      //2nd for loop to move the word student backward
for (j=9; j>=1; j–)

         Lcd_Init(); // Initialize LCD
         Lcd_Cmd(_LCD_CLEAR);  //Clear the Screen
         Lcd_Out(1,1,”Welcome Embedded”);   //position: row=1 & column=1 , text=”Welcome Embedded”
         Lcd_Out(2,j,”Students”);   //position: row=2 & column=j (variable number from 9 to 1) , text=”Students”
         Lcd_Cmd(_LCD_CURSOR_OFF);   //Set Cursor Square OFF (Hidden)
  delay_ms(300);  //delay for 300 meli seconds
  }   //end while loop
}  //end void main



Engineer Nawaf



Powered by Facebook Comments

Comments are closed.