How to connect an I2C LCD Display to an Arduino MEGA 2560




Schematic diagram



1. Connect the Black jumper cable from the GND pin on the LCD to the GND pin on the MEGA
2.  Connect the Red jumper cable from then VCC pin on the LCD to the 5V pin on the MEGA
3. Connect the Green jumper cable from the SDA pin on the LCD to the SDA pin on the MEGA
4. Connect the Yellow jumper cable from the SCL pin on the LCD to the SCL pin on the MEGA

Arduino Sketch


//YWROBOT
//Compatible with the Arduino IDE 1.0
//Library version:1.1
#include <Wire.h> 
#include <LiquidCrystal_I2C.h>

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

void setup()
{
  lcd.init();                      // initialize the lcd 
  lcd.init();
  // Print a message to the LCD.
  lcd.backlight();
  lcd.setCursor(3,0);
  lcd.print("Hello, world!");
  lcd.setCursor(2,1);
  lcd.print("Ywrobot Arduino!");
   lcd.setCursor(0,2);
  lcd.print("Arduino LCM IIC 2004");
   lcd.setCursor(2,3);
  lcd.print("Power By Ec-yuan!");
}


void loop()
{
}

ความคิดเห็น