Sunday, January 13, 2013

LCD Display with Microcontroller


Here I have described how to connect a 16 by 2 LCD display to a microcontroller. Here I have demostrated it with very common pic 16F877A. This is the circuit diagram.

Soldering LCD pins

Here I haven't showed the power supply and oscillator connection for pic and LCD. LCD normally have 16 pins. If you carefully observed you can see number 1 or 16 have printed near the related pin. First let's start with power. LCD display mainly two 5V DC power supplies. Main power supply should connect to VSS and VDD pins. Other power supply is for turn on backlight. Those pins are pin 15 and 16. They haven't been shown in the figure. Backlight power supply is not necessary if we are not going to work in a dark environment. Ok now power supply is done. VEE pin should supply 5Vs through a preset(Variable resistor). By adjusting preset we can change the supply power to the VEE pin. It controls the brightness of the displayed text. If you are not connected this supply some times you may not see text on LCD. D4 to D7 are data pins. We only need 4 pins from them at this stage(D0 to D3). RS, E and D0 to D3 pins should be connected to the earth. 

Connecting LCD to the microcontroller   

Select any port(Eg.  PORTB, PORTC whatever) from microcontroller. Connect pins shown in the figure to any pin as you want on that port. Connection dont't want to be same as the figure. You can use any configuration. We can use microC pro code to initialize microcontroller pins for LCD pins.

Initializing code have shown here.


// LCD module connections

// 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

Here we can see that since RS pin have been connected to the RB2 pin sbiv LCD_RS at RB2_biy; code give instruction to microcontroller to control it as thr RS pin. Others are also same. So you can use any microcontroller pin to connect ant LCD pin.

You can use other LCD library in microC pro to send characters to the LCD. They have explained in microC pro help file. If you have any questions about above things please comment here. 

4 comments:

  1. hi there, is it a must to connect microcontroller to lcd display in a circuit?

    ReplyDelete
    Replies
    1. Yes. Otherwise there is no way to print our required text on the display.

      Delete
  2. Hi,
    After reading this blog I would say It is a work of Magician.
    Hats off.

    Regards,
    Shiva K Rao.
    Engineer at Vashi Electricals

    ReplyDelete
  3. Hii thanks For Sharing such an Informative Article. It Was Very Informative Learnt a lot Today.

    thanks and regards
    Kumar from https://www.eleczo.com/

    ReplyDelete