Electronic Components
- Home|
- LCD Displays|
- 1602 LCD Display with I2C Backpack
1602 LCD Display with I2C Backpack
White characters on blue background. 2 lines, 16 characters per line. Can be used with many different micro-controllers with I2C capabilities In-built pot for contrast control.
- Code
- Questions & Answers
- Specifications
basic Print to LCD screen
Prints a string to the first line, and adds a counter that counts 10 steps and intervals of 1 second
#include <Wire.h> #include <LiquidCrystal_I2C.h> // Set the LCD address to 0x3F for a 16 chars and 2 line display LiquidCrystal_I2C lcd(0x3F, 16, 2); void setup() { // initialize the LCD lcd.begin(); // clear the screen lcd.clear(); // Turn on the blacklight and print a message. lcd.backlight(); // set the cursor to position 0 line 0 // (counts 0 as the first position) lcd.setCursor(0, 0); lcd.print("Automation Bros"); lcd.setCursor(0, 1); lcd.print("Counter: "); } void loop() { // start with i at 0 and count up while i is less than 10 for (int i = 0; i < 10; i++ ) { // wait 1 second delay(1000); // if i hits 10 then: if (i > 9) { // make i = 0 i = 0; } else { // set the cursor position lcd.setCursor(9, 1); // // print the current value lcd.print(i); } } }
1602 LCD Display with I2C Backpack
Controller Pins (I2C Device): 5v (VCC) / GND (GND) / SCL (SCL) / SDA (SDA) The code below requires Wire.h and LiquidCrystal_I2C.h libraries.