Arduino - lcd.print()

Description

Prints text to the LCD.

Syntax

There are two ways:

  • lcd.print(data)
  • lcd.print(data, BASE)

Parameters

  • lcd: a variable of type LiquidCrystal
  • data: the data to print (char, byte, int, long, or string)
  • BASE: (optional) the base in which to print numbers: BIN for binary (base 2), DEC for decimal (base 10), OCT for octal (base 8), HEX for hexadecimal (base 16).

Returns

  • Return the number of bytes written, though reading that number is optional

Example

Hardware Required

1×Arduino UNO or Genuino UNO
1×USB 2.0 cable type A/B (for USB-A PC)
1×USB 2.0 cable type C/B (for USB-C PC)
1×LCD
1×Potentiometer
1×(Alternative) Potentiometer Kit
1×(Alternative) Potentiometer Module with Knob
1×Breadboard
1×Jumper Wires
1×(Recommended) Screw Terminal Block Shield for Arduino Uno
1×(Recommended) Breadboard Shield For Arduino Uno
1×(Recommended) Enclosure For Arduino Uno
Disclosure: Some links in this section are Amazon affiliate links. If you make a purchase through these links, we may earn a commission at no extra cost to you.
Additionally, some links direct to products from our own brand, DIYables.

Wiring Diagram

Arduino LCD Wiring Diagram

This image is created using Fritzing. Click to enlarge image

Arduino Code

#include <LiquidCrystal.h> LiquidCrystal lcd(11, 12, 2, 3, 4, 5); void setup() { lcd.begin(16, 2); // set up the LCD 16x2 lcd.print("hello, world!"); // print a message to the LCD } void loop() {}

ARDUINO BUY RECOMMENDATION

Arduino UNO R3
Arduino Starter Kit

※ OUR MESSAGES