Search Code

Kosakola ya LCD1602 na Interface ya I2C - Malakisi ya Arduino

Kosakola ya LCD1602 na Interface ya I2C - Malakisi ya Arduino

Boyekoli oyo emonisi ndenge ya kosangisa display ya LCD1602 na Arduino na kosalela module ya I2C, oyo esalisi ekeseni na bobongisi ya connection na yango na ndenge ya kala ya parallel wiring. Na ba connexions minei kaka (VCC, GND, SDA, SCL), okoki kokamba display yango mpe kolakisa texte to ba données ya capteur na ba projets na yo ya Arduino.

LCD1602-I2C display module with 4 wires

Makomi nyonso ya code, ba schémas ya câblage, mpe ba liens ya téléchargement ya bibliothèque ezali awa na nsé ya article oyo.

LCD1602 na I2C ezali nini?

LCD1602 ezali display ya ba caractères 16, na ba lignes 2, oyo esalelamaka mingi na ba systèmes embarqués. Na ndenge ya kala, esengaka ba pins 6 kino 10 mpo na kosala, kasi na kobakisa module ya I2C, esengaka kaka ba lignes ya données mibale (SDA na SCL) mpo na communication. Oyo ekitisi mingi bobongisi ya câblage mpe etikeli ba pins ebele ya Arduino mpo na ba composants mosusu.

Câblage ya LCD1602 na Arduino

Arduino wirng for LCD1602 with I2C
Arduino wirng for LCD1602 with I2C

Tala ndenge ya kosangisa LCD1602 na module ya I2C na Arduino Uno:

  • VCC- 5V

  • GNDGND

  • SDAA4

  • SCL -A5

Légende: LCD1602 esangisami na Arduino na nzela ya I2C na kotalela kaka ba fils minei.

- Explication ya Code mpo na Kolakisa Texte na LCD

Code oyo ezali na nsé ebandisi LCD, efungoli backlight, mpe ekomaka texte na boucle.

cppCopyEdit#include <Wire.h> 
#include <LiquidCrystal_I2C.h>

// Set the LCD address to 0x27 for a 16 chars and 2 line display
LiquidCrystal_I2C lcd(0x27, 16, 2);

  • Wire.h: Esengeli mpo na communication ya I2C.

  • LiquidCrystal_I2C.h: Bibliothèque mpo na kokamba LCD na kosalela I2C.

  • lcd(0x27, 16, 2): Ebandisi LCD na adresse 0x27 na ba colonnes 16 mpe ba lignes 2.

cppCopyEditvoid setup()
{
  lcd.begin();       // Initialize LCD
  lcd.backlight();   // Turn on backlight
}

  • lcd.begin() elengisaka LCD mpo na kosalela.

  • lcd.backlight() efungolaka backlight ya display.

cppCopyEditvoid loop()
{
  lcd.clear();                 // Clear previous content
  lcd.print("Robojax");        // Print on first line
  lcd.setCursor(0,1);          // Move cursor to beginning of second line
  lcd.print("Hello World!");   // Print on second line
  delay(500);                  // Wait for 0.5 seconds
}

  • Écran yango ezongisamaka na mbala na mbala na seconde katikati.

  • Okoki mpe kolakisa ba données mosusu, lokola ngonga to ba valeurs ya capteur.

Kotiya Bibliothèque oyo Esengeli

Esengeli okotisa bibliothèque ya LiquidCrystal_I2C:

  1. Fungola Arduino IDE

  2. Kende na Sketch > Include Library > Manage Libraries

  3. Luka LiquidCrystal_I2C

  4. Finá na Install

Nsima ya kotiya yango, okoki kobanda na compilation mpe upload ya code.

Ba Chapitres ya Vidéo

  • 00:00 - Ebandeli

  • 00:35 -Explication ya LCD1602 mpe Module ya I2C

  • 04:37 -Explication ya Câblage

  • 05:35 -Kokitisa Bibliothèque ya LCD1602-I2C

  • 07:13 -Explication ya Code mpo na LCD1602

 

 

Images

Arduino wirng for LCD1602 with I2C
Arduino wirng for LCD1602 with I2C
LCD1602-I2C display module with 4 wires
LCD1602-I2C display module with 4 wires
LCD1602-I2C display module with 4 wires
LCD1602-I2C display module with 4 wires
LCD1602-I2C display module with 4 wires
LCD1602-I2C display module with 4 wires
LCD1602-I2C display module with 4 wires
LCD1602-I2C display module with 4 wires
LCD1602-I2C display module with 4 wires
LCD1602-I2C display module with 4 wires
LCD1602-I2C display module with 4 wires
LCD1602-I2C display module with 4 wires
63-This is code for an LCD1602 display with an I2C module.
Langue: C++
/*
This is code for LCD1602 Display with I2C module
 * Watch the video for this code https://youtu.be/q9YC_GVHy5A
 
 * Permission granted to share this code given that this
 * note is kept with the code.
 * Disclaimer: this code is "AS IS" and for educational purposes only.
 * This library is based on work done by DFROBOT (www.dfrobot.com).
 */
/*
 *  This code has been modified from the Arduino library
 *  Updated by Ahmad Nejrabi on Jan 20, 2018 at 11:09
 *  in Ajax, Ontario, Canada
 *  for Robojax.com
 *  
 *  This is code for LCD1602 Display with I2C module
 *  which can display text on the screen.
 */
#include <Wire.h> 
#include <LiquidCrystal_I2C.h>

// Set the LCD address to 0x27 for a 16 chars and 2 line display
LiquidCrystal_I2C lcd(0x27, 16, 2);

void setup()
{
  // Robojax code for LCD with I2C
	// initialize the LCD, 
	lcd.begin();
 
	// Turn on the backlight and print a message.
	lcd.backlight();
  // Robojax code for LCD with I2C


}

void loop()
{
  
  //start of loop Robojax code for LCD with I2C
  lcd.clear();
  lcd.print("Robojax");
  lcd.setCursor (0,1); // go to start of 2nd line
 lcd.print("Hello World!");
  //lcd.print(millis() / 1000);
  delay(500);
 //end of loop Robojax code for LCD with I2C
}

Nko o na nki.

Fichiers📁

Maktabat ya Arduino (zip)

Fritzing File