Skip to main content

How to control RGB LED using Arduino Uno

RGB LED is the abbreviation of ‘’Red Green Blue Light Emitting Diode’’. RGB LED is the most amazing type of LED which has the ability to create millions of different shades of light colors using red, green, and blue colors.

How to use LCD with Arduino Uno


Liquid crystal Display 16x2 (LCD) is a widely used electronic device to establish communication between the real world and the electronics-based machine world.
There are multiple devices available in the market such as seven-segment display, graphics display, multi-segment LEDs, and so on but LCD is the most preferred display device because of its amazing features. Liquid crystal display’s unique features are as follows:
  • Consists of two rows, with the capability to display 16 characters in each row.
  • Cable to display alphanumeric characters (means it can display numbers and alphabets).
  •  Low power consumption.
  • Works on the principle of blocking light instead of emitting light.
  • Require less operating voltage.
  •  Each character is built by a 5x8 pixel matrix.
In this tutorial, we will deal with a 16x2 Liquid crystal display that is compatible with the Hitachi Hd44780 driver. Liquid crystal Display 16x2 means, LCD can display total 32 characters through both rows and in other words 16 characters in the first row along with the other 16 characters in the second row. Liquid crystal display has a parallel interface that allows the microcontroller to handle multiple interface pins to control the display at a time. There are 16 pins available on LCD each pin’s work is described as follows:


Pin number

Pin Name
Description
Pin 1
GND or VSS
Ground pin (0 volt).
Pin 2
VDD or VCC
Power supply (4.7 volts to 5.3 volts).
Pin 3
VEE
VEE is used to adjust the brightness of the display with the help of a potentiometer (preset).
Pin 4
RS
RS means register to select which is used to select either data or instruction.
Pin 5
R/W
R/W means read/write which is preferred to select the reading or writing mode.
Pin 6
E
E means enable used to indicate that data is ready to write.
Pin 7  to pin 14
D0  to D7
Data pins.
Pin 15
LED+
The backlight pin is connected to +5 volt (VCC) to control the backlight
Pin 16
LED-
The backlight pin is connected to 0 volt (GND) to control the backlight


Hitachi driver allows LCD to operate in 4-bit mode and 8-bit mode. The 4-bit mode (requires only 4 data lines) needs seven I/O pins and the 8-bit mode (which requires all 8 data lines) needs eleven I/O pins from Arduino Uno. The 4-bit mode has all the capabilities to display text on the LCD screen with the help of Arduino Uno. 

This was all about the LCD and its configuration now I will explain to you two simple projects to understand all the basics about it. The first project will help you to understand how different commands are used in Arduino and how their result shows on the LCD screen. In the second project, I will try to guide you about how rows and columns combination work to display anything on LCD with the help of Arduino.

Required component :

1. 1 x Arduino Uno board..............................BUY
2. 1 x 10 k preset............................................BUY
3. LCD screen................................................BUY
4. 1 x breadboard...........................................BUY
5. Few jumper wires......................................BUY

Circuit description:

For both examples, I used the same circuit configuration to make things easier for you to understand. RS pin of the LCD module is connected with pin 8 of the Arduino Uno board. RW, GND and LED- (backlight pin) pins of the LCD module are connected with the ground pin of the Arduino Uno board. 

VEE pin of the LCD module is connected with a 10 k preset which helps to adjust the brightness of the LCD screen. VDD, LED+ (backlight pin) pins connected with +5 volt pin of the Arduino Uno board.  E pin is connected with pin 2. Preset is a three-terminal 10k register whose one terminal is connected with the 5-volt pin of the Arduino, the second terminal is connected to the ground of the Arduino Uno board and the middle terminal is connected with the VEE of the LCD module. 


For both the projects, I will use 4-bit mode which is sufficient to perform all the LCD functionality with very fewer connection requirements. The 4-bit mode requires only 4 data pins to operate LCD. I have chosen D4, D5, D6, and D7 pins of the LCD module and connected them with pin numbers 7, 6, 5, and 4 of the Arduino Uno board respectively. You can understand the entire connection configuration with the help of the fritzing diagram mentioned below.

Circuit diagram:






Important points about Arduino Uno:

Arduino IDE has multiple sets of standard libraries for frequently used functions such as communication operations and support for some of the most common types of hardware like LCD displays, servo motor, stepper motors, and so on. In both projects, we will use a built-in LiquidCrystal library that is specially designed for the Hitachi Hd44780 driver to perform the interfacing between Arduino Uno and LCD.

In the first example, you will understand how different commands are used to display text on LCD. Here I am providing a short description for each command which will help you to understand the code.


Begin ():

It is used to specify the dimension of the LCD screen. This command is always preferred to be called at the very beginning [in void setup( )] to initialize the interface of the LCD.

Syntax:

ARDUINO_LCD.begin(col, row)


Parameter:

ARDUINO_LCD: a variable of type Liquidcrystal.

col: number of columns.

row: number of rows.



home():

This command is used to point the position of the cursor in the upper left corner of the LCD screen.


Syntax:
ARDUINO_LCD.home()

Parameter:
ARDUINO_LCD: a variable of type Liquidcrystal.

Print():
This command is used to print the text on the LCD screen.

Syntax:
ARDUINO_LCD. Print(data)
ARDUINO_LCD. Print(data, BASE)

Parameter:
ARDUINO_LCD: a variable of type Liquidcrystal.
Data: data to be print(it can be char, byte, int, etc.)
BASE: it is optional and used to print the base of the numbers.

setCursor():
This command is used to set the position of the cursor to display the text.

Syntax:
ARDUINO_LCD.setCursor (col, row)

Parameter:
ARDUINO_LCD: a variable of type Liquidcrystal.
col: column number at which the cursor will display text.
row: row number at which the cursor will display text.

display():
This command used to turn on the display.

Syntax:
ARDUINO_LCD.display()

Parameter:
ARDUINO_LCD: a variable of type Liquidcrystal.

noDisplay():
This command is used to turn off the display. This is used to blank the screen without losing the text. It means when we use this command then previously displayed text is not cleared but it is still preserved.

Syntax:
ARDUINO_LCD.noDisplay()

Parameter:
ARDUINO_LCD: a variable of type Liquidcrystal.

clear():
This command is used to clear the LCD screen and set the cursor to the upper left corner of the screen.

Syntax:
ARDUINO_LCD.clear()

Parameter:
ARDUINO_LCD: a variable of type Liquidcrystal.

blink():
This command is used to turn on the blink block-style cursor.

Syntax:
ARDUINO_LCD. blink()

Parameter:
ARDUINO_LCD: a variable of type Liquidcrystal.

noBlink():
This command is used to turn off the blink block-style cursor.

Syntax:
ARDUINO_LCD. noBlink()

Parameter:
ARDUINO_LCD: a variable of type Liquidcrystal.

cursor():
This command is used to display the underscore-style cursor at the position at which the next text will be displayed.

Syntax:
ARDUINO_LCD.cursor()

Parameter:
ARDUINO_LCD: a variable of type Liquidcrystal.

noCursor():
This command is used to hide the underscore-style cursor.

Syntax:
ARDUINO_LCD.noCursor()

Parameter:
ARDUINO_LCD: a variable of type Liquidcrystal.

Code: Click here


Output:


In the second example, I have tried to explain to you how to set the cursor to a different location by arranging the perfect row and column combination. This is a very basic example that will help you a lot to understand how an LCD screen location arrangement can be done. In this example, I had tried to display 1 to 9 numbers one by one in two different manners starting from the upper left corner along with the lower right corner. You will understand the output by watching the video.

Code: Click here

Output:











Comments

  1. Thanks for sharing such an amazing article, really informative

    Visit here : Digital signage Singapore

    ReplyDelete
  2. Such beautifully written. And the information provided is very useful. Thanks for sharing such informative and interesting article. Check this out too sensored lights.Thanks!

    ReplyDelete

Post a Comment

Popular posts from this blog

Smart Plant Watering System Using ARDUINO UNO

As we all know, plants play an important role in our life, there are countless benefits we get from plants but the most important is fresh air and the pleasant atmosphere on the earth. Hence,   It is not only our social duty as well as the responsibility that we should plant trees as much as we can and also take care of them. But  the biggest challenge we face, is, taking care of them,

How to operate soil moisture sensor with Arduino

The soil moisture sensor is the most amazing sensor used to measure the quantity of water present in the soil and defines the moisture level of the soil as the output. Because of its amazing operating principle, this sensor is used in applications such as automatic irrigation systems, agriculture research applications, landscape irrigation, indoor planting system, and lawns. I have also made an advanced level project  "Smart Plant Watering System" using a soil moisture sensor.

ad

ad