Scrolling text on LCD using MSP430 microcontroller

Scrolling text on LCD using MSP430 microcontroller, this tutorial is about how to scroll text on liquid crystal display using MSP430 series of microcontrollers. I will be using MSP430G2 launchpad in this tutorial. You must have came across digital displays where you have seen messages going left and right on seven segment displays or digital screens. You must have wondered how people do this. So you will get the answer of this question in this article. I will show you how to move text on 16×2 LCD in any direction.scrolling text on LCD using msp430 microcontroller

As you know like all microcontroller, MSP430 microcontroller also have general purpose input output pins. These GPIO pins are used to connect with other devices which send or receive data through digital pins. If you don’t know how to use GPIO pins of MSP430 microcontroller,I advise you to check these two tutorials:

How to interface LCD with MSP430 microcontroller

To understand how to scroll text or message on Liquid crystal display, you first have a concepts on how to interface any LCD with microcontroller. In the last tutorial on series of tutorials on MSP430 LaunchPad, I have posted a tutorial on this. You should check this article, before going further in this article:

How to interface LCD with MSP430 microcontroller

In above article, I have explained about LCD pin configuration and how to connect it with microcontroller. I have also through programming part of it. I have given two examples. One example on how to display a simple message and one example on how to display a counter data on LCD. So I have extended the same tutorial with how to scroll text or how to make text move in left or right direct.

How to scroll text on LCD with MSP430 microcontroller

Connection of MSP430 microcontroller is same as we used in last article.  Connection diagram is shown below:

Circuit diagram LCD interfacing with MSP430 microcontroller

For demonstration purpose, we will first write a text “IOT LAB” on first line and text ” MSP430 BOARD” on second line of LCD. After that we move this text towards right for 10 positions and then towards left for 10 positions.  Now lets see how to do it.

Code of scrolling text on LCD

Code is written using energia IDE. We’re going to use the same code as we use in Lcd interfacing tutorial. But this cod has difference of two function lcd.scrollDisplayRight() and lcd.scrollDisplayLeft(). Complete code for scrolling or moving text is given at the end of article. At the start of code, we have included library of LCD using ” LiquidCrystal.h”. After that #define directives are used to give names to MSP430 microcontroller pins. Last line is used to define which of the pins of microcontroller are connected with LCD pins as shown in above connection diagram.

#include <LiquidCrystal.h>
#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);

Inside the setup function, we have initialized liquid crystal display and set the cursor to first row. After that print the string “IOT LAB” in first row and similarly cursor is move to second row and string “MSP430 BOARD” printed on it. This is a same task we did in last tutorial. Now we will scroll this text left and right using built in two functions of Energia IDE.

void setup()//method used to run the code for once
{
lcd.begin(16, 2);//LCD order
lcd.setCursor(0,0);//Setting the cursor on LCD
lcd.print("IOT LAB ");//prints on LCD
lcd.setCursor(0,1);//Setting the cursor on LCD
lcd.print("MSP430 BOARD");//prints on LCD
delay(1000);//delay of 1 second
}

As I mentioned earlier, two functions lcd.scrollDisplayRight() and lcd.scrollDisplayLeft() are used to move text left and right respectively. If we call any one of the function one it will move the text one time left or right. For example if you use lcd.scrollDisplayRight() function in your code, one time it will move the text towards right one time. But if you want to move text for multiple positions, you have to call this function again and again or you can use a loop for same number of times as we did in this code. lcd.scrollDisplayLeft() function also works similar tolcd.scrollDisplayRight() function.

void loop() //used to run the code repeatedly
{
for(int PositionCount=0; PositionCount<6; PositionCount++)
{
lcd.scrollDisplayRight(); //builtin command to scroll right the text
delay(450);//delay of 150 msec
}
for(int PositionCount=0; PositionCount<6; PositionCount++)//loop for scrolling the text
{
lcd.scrollDisplayLeft();//builtin command to scroll the text left again
delay(450);//delay of 150 msec
}
}

So this is how you can scroll text on lcd using MSP430 microcontroller. If you have any complications while using this, you can check this video:

1 thought on “Scrolling text on LCD using MSP430 microcontroller”

Leave a Comment