LCD displays serve as the "eyes" of Arduino projects, transforming code into visible text and graphics. For makers and engineers alike, integrating a display can elevate projects from abstract concepts to interactive experiences. This guide explores how to connect Newhaven's 16×2 character LCD to an Arduino UNO board using both SPI and RS232 TTL serial communication methods.
Character LCDs remain popular for Arduino projects due to their simplicity and effectiveness in conveying information. The 16×2 format (16 characters across 2 lines) provides sufficient space for status messages, sensor readings, or simple user interfaces. Newhaven's NHD-0216K3Z-NSW-BBW-V3 model offers particular advantages with built-in serial interfaces that reduce wiring complexity.
The Newhaven display features two communication ports:
| Pin Number | Symbol | Function |
|---|---|---|
| 1 | RX | RS-232 (TTL) serial input |
| 2 | VSS | Ground |
| 3 | VDD | Power supply (+5.0V) |
| Pin Number | Symbol | Function |
|---|---|---|
| 1 | SPISS | SPI slave select (NC in I2C mode) |
| 2 | SDO | Not connected |
| 3 | SCK/SCL | Serial clock |
| 4 | SDI/SDA | Serial data input (SPI)/Serial data (I2C) |
| 5 | VSS | Ground |
| 6 | VDD | Power supply (+5.0V) |
SPI (Serial Peripheral Interface) offers high-speed synchronous communication ideal for short-distance connections between Arduino (master) and LCD (slave). The connection requires five wires:
| Arduino | LCD | Connection Type |
|---|---|---|
| 5V pin | Pin 6: VDD | Power |
| Ground pin | Pin 5: Ground | Ground |
| Pin 10: Slave Select | Pin 1: SPISS | SPI slave select |
| Pin 11: MOSI | Pin 4: SDI/SDA | Serial data input |
| Pin 12: MISO | Pin 3: SCK/SCL | Serial clock |
Note: Enabling SPI requires opening R1 and shorting R2 on the display PCB as specified in the datasheet.
The Arduino code for SPI communication includes several essential functions:
SPI_Out()
- Transmits commands and data to the LCD
Set_Pins()
- Configures SPI pins as outputs
Set_Contrast()
- Adjusts display contrast
Set_Backlight()
- Controls backlight intensity
Clear_Display()
- Clears the LCD screen
Set_Cursor()
- Manages cursor visibility
For simpler setups, RS232 TTL requires only three connections:
| Arduino | LCD | Connection Type |
|---|---|---|
| 5V pin | Pin 3: VDD | Power |
| Ground pin | Pin 2: Ground | Ground |
| Pin 7: Digital I/O | Pin 1: RX | RS-232 TTL input |
Note: Both R1 and R2 must be open on the display PCB to enable RS232 TTL mode.
When encountering problems with your Arduino-LCD setup, consider these diagnostic steps:
Set_Contrast()
to optimize visibility.
By following these guidelines and understanding both communication methods, makers can effectively integrate LCD displays into their Arduino projects for enhanced functionality and user interaction.