LCD interfacing with MSP430 LaunchPad

LCD interfacing with MSP430 LaunchPad, In this MSP430 microcontroller series of tutorials, you will learn how to interfacing 16×2 Liquid crystal display with MSP430G2 launchPad. LCD interfacing with microcontrollers has many applications in embedded systems projects. It is used to display data from sensors on LCD like current sensor, voltage sensor and many others. It is also used to display notification in text format.LCD interfacing with MSP430 LaunchPad

So liquid crystal displays have many applications with microcontroller. If you are learning microcontrollers programming, LCD interfacing will be very handy for you, when you will make projects using MSP430 microcontroller. So now let’s start with basic introduction to liquid crystal display. There are many types of liquid crystal displays available in marker like 16×2, 20×4 etc. But in this tutorial, we will be using 16×2 LCD . But the concept of interfacing MSP430 microcontroller with other types of LCDs will remains same.  LCD 16x2

Introduction to 16X2 LCD

We are going to discuss about the liquid crystal display which is liquid crystal display.  what is the purpose of general displays? and how many types  are available in the market. Based on what our people are going to choose this lcd devices in our electronics applications. Before you learn this device interfacing with MSP430G2 launchPad, you need to understand the pinout of 16×2 LCD.  For details about the 16×2  check this article:

It is abbreviated as liquid crystal display. It is also known from the name of alpha numeric display. It uses small grid of lights to display numbers, letter and digits. 16X2 alphanumeric display which we are using in this tutorial has 32, 5×8 grids and It can display up to 16 characters in one line. So in total it can display 32 character and 16 in each line.  Pictures along with pin description is given below: 16X2 LCD Pinouts

So to display 16 character in one line, we need to control 5 x 8 x 16 grids or dot. But fortunately, this liquid display has build in controller which take care of all these grids control and it provide us pin out to send text and control the display. So we do not need to worry about controlling these light grids to display characters. 16×2 LCD which has on board HD44780U controller which provides us pin out as shown in figure above. Now lets talk about pin out and how to interface it with MSP430 microcontroller. Picture below shows the description of each pin.

16 x 2 LCD pins working

LCD interfacing with MSP430 microcontroller

Now I will talk about how to interface 16×2 LCD with MSP430 microcontroller.  It requires 5 volts dc supply to operate  and  current consumption is approximately 10 milliamps current 16 cross 2 lcd. It has total 16 pins so the 16 pins you have to control.

  • The first pin is ground and second pin is vcc.
  • Third pin is contrast so generally contrast means which is used to adjust the brightness of screen.
  • Next pin four is rs which used for register select
  • Next pin five are R/w which is read or write pin which is used to select a read or write mode.
  •  Pin number six which is enable pin and it is used to enable or display.
  • Data lines from 7 to 14 d0 d1 d2 d3 d4 d5 d6 d7, these data pins are used to send send from microcontroller to liquid crystal display.
  • Pin 15 is a backlight vcc
  • 16th pin is back light ground

So these are complete 16 pins of lcd screen.  First pin and second pin feature for power supply of the device. So with the help of these 2 pins only you are going to provide the power supply. Coming to third pin which is contrast and this contrast pin can connect  with the help of one variable resistor. Variable resistor having three pins generally the first pin is vcc and another pin is ground. Third variable pin you are going to connect with your third pin of the device . By varying the resistance for variable resistor is going to increase or decrease the brightness of screen. Pin number four five six these are the three control lines of lcd device. Description of other pins is given above.

you will learn how to interface LCD with MSP430G2 LanuchPad. Now you are already now about pinouts 16X2 LCD. Now lets see how to connect it with MSP430G2 launchPad. This module has 8 data pins from D0-D7 which will be used to send data from MSP430G2 GPIO pins to LCD. But we have a option to use LCD either in 4 bit mode or 8 bit mode. In 8 bit mode we need to use 8 GPIO pins of MSP430 and in 4 bit mode we need to use only 4 GPIO pins to connect with data pins of display.  So it is always better to use it in 4 bit mode, because we can save GPIO pins of MSP430 for other purpose. We need other purpose pins of MSP430 also to connect with RS pin and Enable pin of LCD module. Always connect R/W pin to ground because we only want to write data only LCD

When R/W = 0  Screen will be in read mode

When R/W = 1 display will be in write mode

Other than these pins we need to connect lcd  Vo pin to potentionmeter as shown in circuit diagram and you already know it is used to adjust the contrast of LCD. Circuit diagram of liquid crystal display interfacing with MSP430 microcontroller is given below: Circuit diagram LCD interfacing with MSP430 microcontroller

Note: one issue while interfacing it with MSP430 microcontroller is that MSP430 microcontroller operate on 3.3 volt and LCD operates on 5 volt. So we need a separate power supply to power this device. But fortunately, MSP430G2 lanuchPad has on board connector for 5 volt with the name of TP1, you can solder a connector to this pin and get 5 volt from there. Data pins of Liquid crystal display has wide operating voltage range from 3 -5 volt. So there will be no issue with them.

Code of LCD interfacing with MSP430G2 LaunchPad

Code for this interfacing is written usign Energia IDE. If you are reading this tutorial first time, I recommend you to check this tutorial first:

#define EN 3
#define D4 4
#define D5 5
#define D6 6
#define D7 7 
LiquidCrystal lcd(RS, EN, D4, D5, D6, D7); //Let the librarey know how we have connected the LCD

void setup()//method used to run the code for once 
{
lcd.begin(16, 2);//LCD order

}
void loop() //used to run the code repeatedly
{
lcd.setCursor(0,0);//Setting the cursor 
lcd.print("IOT LAB ");//prints 
lcd.setCursor(0,1);//Setting the cursor on screen
lcd.print("MSP430 BOARD");//prints on screen
delay(1000);//delay of 1 second
}

For more details about the working of the code, check this video:

So in this example you have learnt how to display text on two lines and how to set cursor values. So now lets see another example to display integer or counter values on liquid crystal display.

Displaying a counter value on liquid crystal display using MSP430 microcontroller

In this example, I will use the same circuit diagram as we used in last example. But we change the code little bit. In this example, a counter value will be increment every one second and its value will be displayed on screen after every one second. Connection of 16×2 is same with MSP430 microcontroller as it were shown in last example of this article. Code is given below:

#include <LiquidCrystal.h>//Library for liquid crystal display
#define RS 2
#define EN 3
#define D4 4
#define D5 5
#define D6 6
#define D7 7
LiquidCrystal lcd(RS, EN, D4, D5, D6, D7); //Let the librarey know how we have connected the
int i=0;
void setup()//method used to run the code for once
{
lcd.begin(16, 2);//order

}

void loop() //used to run the code repeatedly
{
lcd.setCursor(0,0);//Setting the cursor on
lcd.print("Counter value");//prints on
lcd.setCursor(4, 1); // set the cursor to column 0, line
lcd.print(i);
delay(1000);
i++;
lcd.clear(); //Then clean it

}

To get better understanding of working of this code for counter measurement, check this complete video tutorials:

You positive comments are welcome on this series of tutorial on MSP430 microcontroller programming.

Leave a Comment