Arduino/C2/Arduino-with-LCD/English-timed

From Script | Spoken-Tutorial
Revision as of 12:25, 23 October 2018 by Sandhya.np14 (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
Time Narration
00:01 Welcome to the Spoken Tutorial on Interfacing Arduino with LCD.
00:07 In this tutorial, we will learn to:

connect an LCD to Arduino board,

write a program to display a text message on the LCD.

00:18 To follow this tutorial, you should have:

basic knowledge of electronics and basic knowledge of C or C++ programming language.

00:30 Here I am using:

Arduino UNO Board,

Ubuntu Linux 14.04 operating system and

Arduino IDE.

00:40 We also require some external devices such as:

LCD 16 by 2, Potentiometer, Breadboard, Pin header, Jumper Wires,

00:55 Soldering Iron,

Soldering Stand, Soldering Lead and Soldering Paste.

01:04 Now, let us see the details of the circuit connection.
01:09 Here, we see that there are 16 pins in the LCD.
01:14 Pin 1 is the ground pin represented by GND.

Pin 2 is the power supply pin of 5 volts which is represented by VCC.

01:29 VO is the LCD contrast pin. Here you have to connect a potentiometer.

This will allow a variable voltage to control the contrast of the LCD.

01:42 RS stands for Register Select.

It can be used as a command register or a data register.

01:52 Command register is used for placing the command to be displayed.

And, the data register is used to place the data.

02:02 RW is a Read Write pin.

We can either read data from the LCD or write to the LCD.

02:12 E represents the Enable pin. This enables LCD to accept information.
02:20 These are data pins. The data and commands are sent to the LCD through these pins.
02:29 These are LCD Backlight pins. These are used to power the LCD, control the display contrast, turn on or off the LCD backlight etc.
02:43 Pin 15 is the Anode of the backlight LCD.

Pin 16 is the Cathode of the backlight LCD.

02:53 So far, we have seen the pin details of the LCD.
02:58 Let us switch to the soldering stations to see how we can do the soldering.
03:04 Here, we have 16 by 2 LCD.

This means, it can display 16 characters per line and there are 2 such lines.

03:16 Extension pin which needs to be soldered to LCD so that we can connect easily to the breadboard.

Soldering iron which is already powered, Solder paste and Solder wire.

03:33 First, put the external pin on the LCD as shown.
03:38 Next, apply the solder paste to the tip of the external pins as shown in the video.
03:46 Then connect it again.
03:49 Place the LCD with the external pin firmly on the flat surface, as shown.

Then it will not shake while we do the soldering.

04:02 Take the solder rod with little paste and touch the tip of the wire as shown.
04:09 Hold it for few seconds so that the wire melts and apply to the external pin, as shown.
04:19 I have done soldering for two pins. See the close up of the soldering done for the two pins.
04:27 Likewise, do the soldering for the rest of the pins.
04:32 Let us now switch to the circuit diagram for this experiment.
04:37 Potentiometer is connected as shown to control the contrast of the LCD.
04:44 Potentiometer is a small sized electronic component used to measure voltage.
04:51 Pin number 11 is connected to Enable and pin number 12 is connected to register select.
05:00 Read write pin is connected to ground which means we are writing to the LCD.
05:07 We are using only 4 data lines for our experiment.

Pin 15 and Pin 16 are connected for the backlight of the LCD. Connect Pin15 to VCC and pin16 to ground as shown here.

05:27 I have setup the Arduino and LCD as per the circuit diagram.

Our aim is to write two strings on the LCD display.

05:38 Now we will write the program in the Arduino IDE.

Switch to Arduino IDE.

05:46 First we will go through the reference manual for the Liquid crystal library.
05:52 In the Menu bar, click Help and then Reference.

This will open an offline page.

06:00 Under Reference section, click on Libraries.
06:04 Then scroll down to see the available Standard Libraries.
06:10 Click on LiquidCrystal. Read the description to know more about the available functions.
06:18 It says, it works with 4 bit or 8 bit data lines.
06:24 Next, let us see the LiquidCrystal function and its parameters.
06:30 It is always a good practice to refer to the manual for its functions.

Click on LiquidCrystal function.

06:39 The syntax shows how it is used for 8 bit or for 4 bit.
06:46 For our experiment, we will use the first line syntax.
06:51 Switch to the Arduino IDE.
06:54 First, we will include the Liquid crystal library here.
06:59 In the Menu bar, click Sketch and Include Library.

Then select LiquidCrystal. This will insert the LiquidCrystal.h file as shown.

07:14 Now, type the code as shown. Let me explain the parameters.
07:21 lcd is a variable of type Liquid crystal.
07:26 First parameter is Register Select.

Register Select is connected to pin 12 of Arduino board.

07:35 Second parameter is Enable. It is connected to pin 11.
07:41 The next 4 parameters are data lines of LCD.
07:46 d4, d5, d6 and d7 of LCD are connected to pins 5, 4, 3 and 2 of the Arduino board.
07:58 We are initializing the library with pins. This line of code can be outside the void setup function.
08:07 In the void setup function, we will write the initial setups required for the experiment.

There is a function called begin.

08:18 Let us see the manual for the description and the parameters for this function.

Switch back to the reference manual.

08:27 The manual says-

1. Initializes the interface to the LCD screen.

2. Specifies the dimensions (width and height) of the display and

3. Needs to be called before any other LCD library commands.

08:45 Now, let us see the parameters.

lcd: A variable of type liquid crystal,

cols: the number of columns that the display has.

08:58 We have 16 columns in our LCD.

rows: the number of rows that the display has.

We have 2 rows.

09:09 Switch back to the Arduino IDE.
09:13 Now, type: lcd.begin open bracket 16 comma 2 close bracket semicolon.
09:23 Set Cursor command will position the cursor in the specified row and column in the LCD.
09:30 Zero comma zero means zeroth row and zeroth column.
09:36 There is another command called print which will print text on the LCD.
09:44 Type: lcd.print and enter some text, say “First Row”.
09:52 Let me explain the program.
09:55 This program will print on a 16 by 2 configuration LCD.

Set the cursor to first position.

lcd.print will print the text “First row” in the LCD.

10:12 Let us compile and upload the program.
10:19 We can see the output “First row” displayed on the first line.
10:25 There is nothing displayed on the second row.
10:29 Let us change the program to print on the second line also.
10:34 Copy and paste the code. Remove the line “lcd.begin” as it is initialized at the starting of the program.
10:46 Change the setcursor command to 0th column and 1 row as shown.
10:54 Change the print command text to “second row”.
10:59 Now, let us compile and upload the program.
11:06 The text is displayed in the second row as well.
11:10 We didn't use any code in the void loop.

But, still we need to keep the loop template.

This is because a loop function is required by the Arduino syntax.

11:24 Once the text is sent, it is there forever.
11:29 Let us change the cursor position to the 3rd column in the second line.
11:34 Again, compile and upload the program.
11:38 Note the change in the column position in the second row.
11:43 Switch back to our function list in the manual.
11:47 We can see there are many more functions such as scrollDisplayLeft, scrollDisplayRight etc.

Explore these functions on your own.

12:01 This brings us to the end of this tutorial. Let us summarize.
12:06 In this tutorial, we learnt to:

connect an LCD to Arduino board and

write a program to display a text message on LCD

12:18 Do the following assignment.

Change the same program to display the text “Hello World” in the second row. Place the cursor in the 4th column. Compile and upload the program. Observe the text displayed in the LCD.

12:40 The video at the following link summarizes the Spoken Tutorial project.

Please download and watch it.

12:48 The Spoken Tutorial Project team:

conducts workshops and gives certificates. For more details, please write to us.

12:58 Please post your timed queries in this forum.
13:02 Spoken Tutorial project is funded by NMEICT, MHRD, Government of India.

More information on this mission is available at this link.

13:13 This tutorial has been contributed by FOSSEE and Spoken Tutorial Project, IIT Bombay.

Thanks for watching.

Contributors and Content Editors

Pratik kamble, Sandhya.np14