Display Text on LCD
In this project, we will learn how to display text on an LCD using Arduino. This is useful for many electronics and robotics projects.
Supplies
Arduino Uno
16x2 LCD
Breadboard
Jumper wires
Potentiometer
1k Resistor
Arduino Uno and Breadboard
Take Arduino Uno and Breadboard
Power Supply to Breadboard
First, connect the 5V pin of the Arduino to the positive rail of the breadboard. This will supply power to all components on the board.
Then connect the GND pin of the Arduino to the negative rail of the breadboard. This provides the ground connection needed for the circuit.
LCD Backlight Power
Mount the LCD on the breadboard from a15 to a30.
Take a jumper wire and connect the positive rail of the breadboard to point h29. This brings power closer to the LCD's pin 15.
Now place a 1,00 ohm resistor from D29 to G29 across the center bridge of the breadboard. This resistor supplies power to pin 15 of the LCD, which controls the backlight.
Next, connect a jumper wire from the negative rail of the breadboard to pin 16 of the LCD located at E30. This completes the backlight connection.
Connect LCD Data Pins to Arduino
Now, let's begin wiring the LCD data pins to the Arduino.
First, connect pin 14 of the LCD to digital pin 2 on the Arduino.
For this, use a jumper wire from E28 on the breadboard to digital pin 2 on the Arduino.
Now connect pin 13 of the LCD to digital pin 3 on the Arduino. Connect a jumper wire from D27 on the breadboard to digital pin 3.
Next Connect pin 12 of the LCD to digital pin 4 on the Arduino by connecting a jumper wire from C26 on the breadboard to digital pin 4.
Connect pin 11 of the LCD to digital pin 5 on the Arduino by using a wire from B25 on the breadboard to digital pin 5.
Adding Potentiometer to Breadboard
Potentiometer Wiring:
Middle pin (wiper) connected to LCD pin 3 to adjust contrast.
One terminal connected to breadboard positive rail.
Other terminal connected to breadboard negative rail.
LCD Control Pins Connection
Now connect pin 1 of the LCD which is the ground pin to the negative rail of the breadboard. Use a jumper wire from B15 to the negative rail.
Then Connect pin 2 of the LCD. Use a jumper wire from B16 to F16.
Then connect pin 3 of the LCD located at C17 to the wiper pin of the potentiometer at F17. This wire adjusts the LCD contrast.
Now connect pin 4 of the LCD, which is the register select RS pin to digital pin 12 on the Arduino. Use a jumper wire from C18 to digital pin 12.
Connect pin 5 of the LCD, which is the R/W pin, to GND. Use a jumper wire from C19 to the negative rail of the breadboard. This ensures the LCD is always in Write mode.
Now, the last connection that is for the enable pin, use jumper wire from D20 to digital pin 11 of the Arduino.
Powering Potentiometer
Connect one of the terminal pins of the potentiometer from F16 to the positive rail of the breadboard. This powers the potentiometer.
Lastly, connect the remaining terminal of the potentiometer from J18 to the negative rail of the breadboard. This completes the potentiometer circuit.
Now the potentiometer and all essential LCD control pins are successfully connected.
Arduino Code Structure and Functionality
- Library Inclusion:
- Uses the LiquidCrystal library, which provides LCD control functions.
- LCD Object Initialization:
- Specifies Arduino pins connected to LCD as: RS on pin 12, Enable on pin 11, and data pins D4 to D7 on pins 5, 4, 3, and 2 respectively.
- LCD Setup:
- Initializes LCD with 16 columns and 2 rows matching the physical display.
- Positions cursor at (0,0) and prints "hello" on the first line.
- Moves cursor to (0,1) and prints "world" on the second line.
- Loop Function:
- Left empty since no dynamic updates are required after initial display.
Uploading Code to Arduino
Select the correct board type (Arduino Uno) from the Tools > Board menu.
Select the appropriate serial port (varies by OS; e.g., COM on Windows, /dev/cu.* on macOS).
Verify code by clicking the checkmark icon to detect syntax errors.
Upload code by clicking the right arrow icon.
Upon successful upload, LCD displays the programmed message.
OUTPUT
Once uploaded, the LCD will display your message. Hello on the first line and World!! on the second.
Your LCD project is now complete and working.