Advertisement
microrobotics

LCD 16x2 Character Display 3.3V I2C

May 11th, 2023
1,705
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2. To interface a 16x2 LCD with ESP32, you can use the LiquidCrystal_I2C library. Here's a simple example:
  3.  
  4. Assuming the following connection:
  5.  
  6. SDA => GPIO21
  7. SCL => GPIO22
  8. */
  9.  
  10. #include <Wire.h>
  11. #include <LiquidCrystal_I2C.h>
  12.  
  13. // Set the LCD address to 0x27 for a 16 chars and 2 line display
  14. LiquidCrystal_I2C lcd(0x27, 16, 2);
  15.  
  16. void setup()
  17. {
  18.   lcd.begin(16,2); // initialize the lcd
  19.  
  20.   lcd.backlight();
  21.   lcd.setCursor(0,0); // go to the top left corner
  22.   lcd.print("Hello, world!");
  23.   lcd.setCursor(0,1); // go to the 2nd line
  24.  
  25.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement