i2c protocol driver lcd1602

1. Development board

Arduino nano(168p)

 2. screen

 lcd1602, if you don't add an adapter board, it will take up a lot of io, and you need to add an adjustable resistor to adjust the contrast.

 3. Adapter board

The pcf8574T adapter board is used here, which only occupies two io ports through the i2c protocol, and integrates adjustable resistors, which is very convenient to use.

 4. Libraries and Code

Download lcd_i2c in Arduino, pay attention to the author, don't make a mistake.

 The code is in the example, you can modify it yourself.

#include <LCD_I2C.h>

LCD_I2C lcd(0x27, 16, 2); // Default address of most PCF8574 modules, change according

void setup()
{
    lcd.begin(); // If you are using more I2C devices using the Wire library use lcd.begin(false)
                 // this stop the library(LCD_I2C) from calling Wire.begin()
    lcd.backlight();
}

void loop()
{
    lcd.print("     Hello"); // You can make spaces using well... spaces
    lcd.setCursor(5, 1); // Or setting the cursor in the desired position.
    lcd.print("World!");
    delay(500);

    // Flashing the backlight
    for (int i = 0; i < 5; ++i)
    {
        lcd.backlight();
        delay(50);
        lcd.noBacklight();
        delay(50);
    }

    lcd.backlight();
    lcd.clear();
    delay(500);
}

5. Connection

development board Screen
A4 SDA
A5 SCL
GND GDN
3.3-5V VCC

6. Video presentation

Guess you like

Origin blog.csdn.net/qq_66813359/article/details/129716723