Lesson 7

LCD Screen

So far, we have activated a servo motor and a buzzer. Now it’s time to move on and activate our LCD screen!

The blue screen included in the race control unit is called “LCD 1602.”

What does 1602 mean?
It is named this because the screen can show two lines of text, and each line can consist of 16 characters—otherwise, it is a screen that allows 16 letters/symbols on each of 02 rows of text.


Our LCD screen consists of 32 small boxes. Each box can contain one character.

Each box has a unique address. Let’s explore what the box addresses are. Then, we will begin to instruct Arduino to display characters in them.

The next photo explains the addresses of the boxes.
Notice the number order by row (left) and column (bottom):

It might seem strange, but in programming, counting begins at 0 and not from 1. The first row of boxes is called row 0, and the second row is row 1.

The same principle applies to columns. The first box in each row is called box 0. Then, the second box is box 1, and so on until box 15 (which is the last box -a total of 16 boxes in each row, from 0 to 15).

The image below has a box marked with an “x.” If we want to display something in this box, we will need to tell Arduino that “row 1, box 6” is the box’s address.

Now that we understand the theory, it’s time to start displaying text on our LCD screen!

Step 1: Install PlayRobotics mBlock extension

While you can already use your computer to program Arduino, your kit also includes some advanced components that mBlock doesn’t support on its own. We need to add the PlayRobotics extension to mBlock for what we are going to do.

Install the extension as shown in the video below. Notice it is a two-step process: we download the extension, then install it.

After installing the extension, you will see new menus added to mBlock (as shown at the end of the video).

Step 2: Display message

To use the LCD screen, we first need to configure it using the “Setup LCD Screen” block. This block tells Arduino that we will be using the LCD screen in our code.

When we set up the buzzer and servo, we did not need a setup block. But for the LCD screen, we need to include a setup block, then display our messages.

Make the changes to the code that you see in the video below. Notice that you’ll find all of the LCD screen blocks in the LCD-1602 menu:


This is the result you should get:

Step 3: Change mesasge

Now let’s display two different messages, one after the other:

1) Display “Hello Welcome”
2) Wait 2 seconds
3) Display “PlayRobotics”

Can you make the needed changes before watching the video? Give it a try! (Only use the setup block one time at the beginning of your messages. There is no need to include setup blocks between messages.)

This is the result you should get:

Step 4: Race start messages

Now, let’s display these race start messages: -On Your Marks
-Get Set
Change the code as shown in the video below:

This is the result you should get:

Step 5: Adding decoration

We can also use specials characters to make our messages look better.
Update your code with the following messages:

=On Your Marks!=
====Get Set=====
Go ! Go ! Go !!!

Copy and paste the messages above, or type them into your code.

Did you notice? Each of these messages is exactly 16 characters in length: the maximum message length our LCD can display!


This is the result you should get. Of course, you can get creative and decorate the messages with any characters you like! (such as #, *, ~)

Let’s continue!

Our code is getting better and better! In the next lesson, we will use a button to start our races (so we won’t have to restart Arduino to race anymore).