Display your results with LCD 🖥️ 


LCDs are screens that can be found in devices that we commonly use in our daily lives. Many monitors and TVs have LCD screens, however, the one we're using today is smaller and more closely resembles the screen on a the car's radio or an air conditioning remote. Let us explore more.

Overview


The LCD (Liquid Crystal Display) consists of a number of rectangular areas that define the size of the LCD. The one used in this tutorial is a 16x2 LCD, which means it has two rows of 16 rectangular areas, each of which comprises of smaller ones that lights up like a pixel to print out the character.


The LCD has a background light, which is usually blue or green.


In this tutorial, we use an I2C module, which makes it a lot easier to connect the LCD to the Arduino. Let's see together!


Getting the items


For this project you will need the following components: 

Sale Off
Voltaat Arduino Uno R3 (Voltaat Version)
45 QAR
Sale Off
Voltaat 2x16 LCD with I2C Module
29 QAR
Sale Off
Voltaat Jumper Wires - Male to Female (40 Pack)
10 QAR

Wiring it up


The connection is really simple; with just four jumper wires, we can light the LCD and display data on it; The image demonstrates how to connect the wires between the LCD and the Arduino. Once the LCD and the Arduino are connected to each other, connect the Arduino to your computer using the USB cable.


Connections from the Arduino to the LCD:


• Arduino GND pin → I2C module GND pin

• Arduino VCC pin → I2C module VCC pin

• Arduino pin A4 → I2C module SDA pin

• Arduino pin A5 → I2C module SCL pin


Coding


This sketch's function is to print a string on the LCD and use the delay function to create basic animations.


To make the code work, you must first download the liquid crystal I2C and wire.h libraries. Libraries are files that you can download and copy them to the Arduino IDE Software files so the Arduino can recognize different sensors. You can download the library files from the resources section and then install it by following this tutorial.


Make certain that you are using a 16x2 LCD with an I2C module.


  1. /*
  2.   Voltaat learn (https://www.voltaat.com)
  3.   Link for full tutorial: https://www.voltaat.com/blogs/tutorials/print-on-lcd-easily-with-arduino-using-i2c-module-simple-animation-and-more
  4.   Link for libraries:
  5.   LiquidCrystal I2C Library: https://cdn.shopify.com/s/files/1/2822/2674/files/LiquidCrystal_I2C-1.1.2.zip?v=1661086526
  6.   Wire Library: https://cdn.shopify.com/s/files/1/2822/2674/files/AceWire-develop.zip?v=1661086928
  7.  
  8.   The function of this sketch is to print a string on the LCD and use the delay function to make simple animations.
  9.  
  10.   Components Needed:
  11.   1-Arduino Uno R3 (Voltaat Version)
  12.   https://www.voltaat.com/products/voltaat-uno-r3-board
  13.   2-2x16 LCD with I2C Module
  14.   https://www.voltaat.com/products/2x16-lcd-with-i2c-module
  15.   3-Jumper Wires - Male to Female (40 Pack)
  16.   https://www.voltaat.com/products/jumper-wires-male-to-female-40-pack
  17.  
  18.   Connections from the Arduino to the LCD:
  19.   Arduino GND pin → I2C module GND pin
  20.   Arduino VCC pin → I2C module VCC pin
  21.   Arduino pin A4 → I2C module SDA pin
  22.   Arduino pin A5 → I2C module SCL pin
  23.  
  24. */
  25.  
  26. // This library allows you to connect with I2C/TWI devices.
  27. #include < Wire.h >
  28.  
  29. // The library allows you to control I2C displays using functions that are quite similar to those found in the LiquidCrystal library.
  30. #include < LiquidCrystal_I2C.h >
  31.  
  32. // LCD instance (0x27 is the I2C address), 16 is 16 number of columns, 2 is number of rows.
  33. // make sure you are using 16x2 LCD with I2C module.
  34. LiquidCrystal_I2C lcd(0x27,16,2);
  35.  
  36.  
  37. void setup()
  38. {
  39. // initialize the lcd
  40. lcd.init();
  41.  
  42. // turn on the LCD backlight.
  43. lcd.backlight();
  44.  
  45. }
  46.  
  47.  
  48. void loop()
  49. {
  50. // Clear what is displayed on the LCD
  51. lcd.clear();
  52.  
  53. // Delay for 800 milli second to make simple animation you can change this value to get a To get a different response.
  54. delay(800);
  55.  
  56. // set the cursor of the LCD to column 2, line 1
  57. lcd.setCursor(2,0);
  58.  
  59. // Print "Voltaat Store" on the LCD
  60. lcd.print("Voltaat Store");
  61.  
  62. // Delay for 1200 milli second to make simple animation you can change this value to get a To get a different response.
  63. delay(1200);
  64.  
  65. // set the cursor of the LCD to column 0, line 1
  66. lcd.setCursor(0,1);
  67.  
  68. // Print "You are welcome!" on the LCD
  69. lcd.print("You are welcome!");
  70.  
  71. // Delay for two second to make simple animation you can change this value to get a To get a different response.
  72. delay(2000);
  73.  
  74. }

Testing it out


When you upload the code to your Arduino board and connect the LCD with I2C module, you will see the LCD show the word "Voltaat Store" starting at the third column and first row since we made this function lcd.setCursor(2, 0);

The second row then prints "You are welcome!" starting from the first column.


The delay function was used to animate it. This makes the words appear and disappear at different times; play with different delay settings by altering the code and have fun!


Resources 


Arduino Code

LiquidCrystal I2C Library
Wire Library

Fritzing Wiring file

Related Tutorials


How to become very good 

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et 

How to become very good 

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et 

How to become very good 

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et 

Liquid error: Could not find asset snippets/zend_pre_order_theme_snippet.liquid
Liquid error: Could not find asset snippets/uploadkit.liquid