{"id":8775,"date":"2018-04-16T02:18:23","date_gmt":"2018-04-16T06:18:23","guid":{"rendered":"https:\/\/qxf2.com\/blog\/?p=8775"},"modified":"2018-04-25T03:02:16","modified_gmt":"2018-04-25T07:02:16","slug":"arduino-tutorials-testers-lcd-display","status":"publish","type":"post","link":"https:\/\/qxf2.com\/blog\/arduino-tutorials-testers-lcd-display\/","title":{"rendered":"Arduino Tutorials for Testers: LCD Display"},"content":{"rendered":"<p>In this tutorial, you will learn about how to interface LCD Display with Arduino and display a message on LCD Display. This is the fourth post of our hands-on, Arduino tutorial series. Follow along and you will produce something useful at the end of each tutorial. We also cover just enough electronics theory for you to be able to understand and troubleshoot any problems you may face.<\/p>\n<hr \/>\n<h3>Components Required:<\/h3>\n<ol>\n<li>Arduino Board<\/li>\n<li>Resistor (330 ohms)<\/li>\n<li>Potentiometer (10K)<\/li>\n<li>Jumper wires<\/li>\n<li>\u00a016&#215;2 LCD Display (HD44780)<\/li>\n<\/ol>\n<p><strong>Note:<\/strong> You can get these components fairly easily at many places (including online). We bought for our engineers this <a href=\"https:\/\/www.amazon.in\/dp\/B01KNR581U\/ref=ox_ya_os_product\">Arduino super-starter kit<\/a>.<\/p>\n<hr \/>\n<h3>Pinout Details of LCD Display:<\/h3>\n<figure id=\"attachment_8781\" aria-describedby=\"caption-attachment-8781\" style=\"width: 300px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2018\/03\/lcd-16x2-pinout-300x196.png\" data-rel=\"lightbox-image-0\" data-rl_title=\"\" data-rl_caption=\"\" title=\"\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-8781 size-full\" src=\"https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2018\/03\/lcd-16x2-pinout-300x196.png\" alt=\"LCD Display 16x2 Pinout\" width=\"300\" height=\"196\" \/><\/a><figcaption id=\"caption-attachment-8781\" class=\"wp-caption-text\">Fig. 1 LCD Display 16&#215;2 Pinout<\/figcaption><\/figure>\n<ul>\n<li>Vcc and GND: Power to the LCD Display<\/li>\n<li>Contrast pin (Vo): Control the display contrast<\/li>\n<li>Register Select (RS) pin: Decides mode of operation (Instruction mode or character mode). To know more about the mode of operation refer link <a href=\"http:\/\/www.learningaboutelectronics.com\/Articles\/HD44780-LCD-register-select-RS-pin\">here<\/a><\/li>\n<li>Read\/Write (R\/W): Selects reading mode or writing mode<\/li>\n<li>Enable pin (En): Enables writing to the registers<\/li>\n<li>8 data pins (D0 -D7): Bi-directional data bus to read and write data<\/li>\n<li>Backlight (+)and Backlight (-) pins: Turn on\/off the LED backlight<\/li>\n<\/ul>\n<p><span style=\"font-weight: 400;\">Note: LCDs can be controlled in two modes: 4-bit or 8-bit. The 4-bit mode requires seven I\/O pins(4 data lines + ctrl signals RS, R\/W, En) from the Arduino, while the 8-bit mode requires 11 pins<\/span><span style=\"font-weight: 400;\">(8 data lines + ctrl signals RS, R\/W, En)<\/span><span style=\"font-weight: 400;\">. For this tutorials, we will be using 4-bit mode as we are going to display only the data on LCD and that will require only 7 I\/O pins (Indirectly, you can say, we are saving 4 I\/O lines for other uses).<\/span><\/p>\n<hr \/>\n<h3>Interfacing of LCD Display to Arduino:<\/h3>\n<figure id=\"attachment_8788\" aria-describedby=\"caption-attachment-8788\" style=\"width: 732px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2018\/03\/lcd_interfacing.png\" data-rel=\"lightbox-image-1\" data-rl_title=\"\" data-rl_caption=\"\" title=\"\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-8788 size-full\" src=\"https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2018\/03\/lcd_interfacing.png\" alt=\" Interfacing of LCD Display with Arduino Uno\" width=\"732\" height=\"452\" srcset=\"https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2018\/03\/lcd_interfacing.png 732w, https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2018\/03\/lcd_interfacing-300x185.png 300w\" sizes=\"auto, (max-width: 732px) 100vw, 732px\" \/><\/a><figcaption id=\"caption-attachment-8788\" class=\"wp-caption-text\">Fig. 2 Interfacing of LCD Display with Arduino Uno<\/figcaption><\/figure>\n<p>Refer above fig 2 and below wiring details to interface LCD Display with Arduino UNO.<\/p>\n<p><strong>Wiring Details:<\/strong><\/p>\n<ul>\n<li>Connect LCD Vcc\/Vdd pin to Vcc pin of Arduino<\/li>\n<li>Connect LCD GND pin to GND pin of Arduino<\/li>\n<li>Connect LCD RS pin to digital pin 12 of Arduino<\/li>\n<li>Connect LCD Enable pin to digital pin 11 of Arduino<\/li>\n<li>Connect LCD R\/W pin to GND pin of Arduino because we are going to do &#8216;write&#8217; action only.<\/li>\n<li>Connect LCD D4 pin to digital pin 5\u00a0of Arduino<\/li>\n<li>Connect LCD D5 pin to digital pin 4\u00a0of Arduino<\/li>\n<li>Connect LCD D6 pin to digital pin 3\u00a0of Arduino<\/li>\n<li>Connect LCD D7 pin to digital pin 2\u00a0of Arduino<\/li>\n<li>Connect LCD Contrast pin Vo to wiper (pin 2) of 10K POT and connect pin\u00a01 of POT to Vcc and pin 3 to GND<\/li>\n<li>Connect LCD Backlight(+) pin to Vcc along with current limiting resistor of 220 Ohm<\/li>\n<li>Connect LCD Backlight(-) pin to GND<\/li>\n<\/ul>\n<p>Once you are done with the connection, please cross check\u00a0the connection to confirm all connections are OK or not.<\/p>\n<hr \/>\n<h3>Write a code to display a message on LCD Display:<\/h3>\n<p>Code: Please go through below code and comments line by line to understand the code and flow of the complete code.<\/p>\n<pre lang=\"Arduino\">#include <LiquidCrystal.h>  \/\/ include the library code\r\n\r\n\/* initialize the library by associating any needed LCD interface pin with the arduino pin number it is connected to *\/\r\nconst int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2; \/\/ Declare variables to hold pin numbers\r\nLiquidCrystal lcd(rs, en, d4, d5, d6, d7); \/\/ Create lcd object to control LCD Display\r\n\r\nvoid setup() {\r\n  \/\/ put your setup code here, to run once:\r\n  lcd.begin(16, 2);                \/\/ set up the LCD's number of columns and rows:\r\n  lcd.print(\"Welcome to\");   \/\/ Print a message to the LCD.\r\n}\r\n\r\nvoid loop() {\r\n  \/\/ put your main code here, to run repeatedly:\r\n  lcd.setCursor(0, 1); \/\/set the cursor to column 0, line 1 (line 1 is the 2nd row, since counting begins with 0)\r\n  lcd.print(\"Qxf2 Services\"); \/\/Print a message to second line of LCD\r\n  \r\n  lcd.noDisplay();  \/\/ Turn off the display\r\n  delay(500);        \/\/ wait for 500 msec\r\n  \r\n  lcd.display();      \/\/ Turn on the display\r\n  delay(500);       \/\/ wait for 500 msec\r\n}\r\n\r\n<\/pre>\n<p>In above sketch, we used Liquid Crystal Library to control the LCD Display. We created &#8216;lcd&#8217;\u00a0object and used begin(), print(), setCursor(), display(), noDisplay() functions to display message and control LCD Display. To know more about the library and supported functions, refer to the link <a href=\"https:\/\/www.arduino.cc\/en\/Reference\/LiquidCrystal\">here<\/a>.<\/p>\n<p>Upload above sketch on your Arduino Uno Board and you can see a message &#8220;Welcome to Qxf2 Services&#8221; displayed on LCD Screen. Look at below fig. 3 to see how a message\u00a0will be displayed.<\/p>\n<figure id=\"attachment_8807\" aria-describedby=\"caption-attachment-8807\" style=\"width: 761px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2018\/03\/LCD_Interfacing_001.png\" data-rel=\"lightbox-image-2\" data-rl_title=\"\" data-rl_caption=\"\" title=\"\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-8807 size-full\" src=\"https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2018\/03\/LCD_Interfacing_001.png\" alt=\"Print Message on LCD Display\" width=\"761\" height=\"476\" srcset=\"https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2018\/03\/LCD_Interfacing_001.png 761w, https:\/\/qxf2.com\/blog\/wp-content\/uploads\/2018\/03\/LCD_Interfacing_001-300x188.png 300w\" sizes=\"auto, (max-width: 761px) 100vw, 761px\" \/><\/a><figcaption id=\"caption-attachment-8807\" class=\"wp-caption-text\">Fig.3 Print Message on LCD Display<\/figcaption><\/figure>\n<hr \/>\n<h3>Practice Task:<\/h3>\n<ul>\n<li>Print POT values (any input\/sensor values) on LCD Display<\/li>\n<li>Print the position of Servo Motor on LCD Display<\/li>\n<\/ul>\n<hr \/>\n<p>Hope you like the tutorial. In this tutorial, you learned about how to interface with an LCD Display and print messages, sensor or actuator values using Arduino. In our next tutorial <a href=\"https:\/\/qxf2.com\/blog\/arduino-tutorials-for-testers-serial-monitor\/\">here<\/a>, you will learn about Serial Monitor and how it will make our life easy to print messages along with sensors\/actuator values and get values in\u00a0different data types from a user.\u00a0If you follow along, at the end of this <a href=\"https:\/\/qxf2.com\/blog\/arduino-tutorial-series-for-testers\/\">series<\/a>, you will distinguish how hardware devices\/instruments\/products are designed, you can also guess how they were programmed, you will get ideas about how to test hardware and you can build and help others in building products.<\/p>\n<p><strong>Learn more <a href=\"https:\/\/qxf2.com\/blog\/about-qxf2\/\">about Qxf2 Services<\/a>.<\/strong><\/p>\n<hr>\n","protected":false},"excerpt":{"rendered":"<p>In this tutorial, you will learn about how to interface LCD Display with Arduino and display a message on LCD Display. This is the fourth post of our hands-on, Arduino tutorial series. Follow along and you will produce something useful at the end of each tutorial. We also cover just enough electronics theory for you to be able to understand [&hellip;]<\/p>\n","protected":false},"author":12,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[159,117],"tags":[119,161],"class_list":["post-8775","post","type-post","status-publish","format-standard","hentry","category-arduino","category-hardware-testing","tag-arduino","tag-lcd-display"],"_links":{"self":[{"href":"https:\/\/qxf2.com\/blog\/wp-json\/wp\/v2\/posts\/8775","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/qxf2.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/qxf2.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/qxf2.com\/blog\/wp-json\/wp\/v2\/users\/12"}],"replies":[{"embeddable":true,"href":"https:\/\/qxf2.com\/blog\/wp-json\/wp\/v2\/comments?post=8775"}],"version-history":[{"count":14,"href":"https:\/\/qxf2.com\/blog\/wp-json\/wp\/v2\/posts\/8775\/revisions"}],"predecessor-version":[{"id":9308,"href":"https:\/\/qxf2.com\/blog\/wp-json\/wp\/v2\/posts\/8775\/revisions\/9308"}],"wp:attachment":[{"href":"https:\/\/qxf2.com\/blog\/wp-json\/wp\/v2\/media?parent=8775"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/qxf2.com\/blog\/wp-json\/wp\/v2\/categories?post=8775"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/qxf2.com\/blog\/wp-json\/wp\/v2\/tags?post=8775"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}