Introduction: PacMan and Custom Characters on Arduino With a 16x2 LCD I2C YwRobot LCM1602 IIC V1

Picture of PacMan and Custom Characters on Arduino With a 16x2 LCD I2C YwRobot LCM1602 IIC V1

Hello everybody, this is my first instructables!

I made this guide because I had a lot of problems to drive the YwRobot LCD I2C with Arduino because of problems related to software libraries.

After much research and testing, at the end, I found some libraries that are compatible and fully working. I have also experimented them using custom characters and so I decided to share my experience with you.

In the end I made a simple animation with a pacman custom charcter that eats all the pills on the lcd...

Step 1: Wiring: Connect LCD to Arduino

Picture of Wiring: Connect LCD to Arduino

there is no need to connect the wires to a breadboard, in fact we will connect them directly to Arduino.

It's quite simple since there are only 4 wires to connect:

Gnd to Gnd

5v to 5v

SDA to SDA

SCL to SCL

see the pictures above for reference

Step 2: Get Libraries and Write Some Custom Characters Code

Download this library and import into your Arduino Ide.

I got this library from DFRobot.com web site.

Step 3: Testing the Display

Picture of Testing the Display

First of all turn on your Arduino and see the display...

with a screwdriver, adjust the brightness by turning the potetiometer screw on its back, until you will see some boxes.

Into you Arduino Ide open a new Scratch and write the code attached:

this code will displays a simple 2 lines string:

//using DFRobot.com libraries
//Compatible with the Arduino IDE 1.0
//Library version:1.1

#include <Wire.h>
#include <VirtualWire.h>

LiquidCrystal_I2C lcd(0x27,16,2);

void setup(){
  lcd.init();                      // initialize the lcd 
  lcd.backlight();
  
  lcd.home();
  
  lcd.setCursor(0, 0);
  lcd.print("Hello world...");
  lcd.setCursor(0, 1);
  lcd.print("this is me!");
  while(1);
}
int backlightState = LOW;
long previousMillis = 0;
long interval = 1000;
  
void loop(){
}



//the easiest way to create your own custom character is to create them visually using this web site: 

<a href="http://mikeyancey.com/hamcalc/lcd_characters.php" rel="nofollow">http://mikeyancey.com/hamcalc/lcd_characters.php</a> 

and then paste the byte array into your Scratch.

Step 4: Writing Simple Pacman Animation Code

Into you Arduino Ide open a new Scratch and write the code attached.

You will see a simple pacman on your display eating all the pills.

Comments

GHOSTGAMER44 (author)2017-03-13

now i understand how this works. THANKS! you helped me a LOT!

TomášS18 (author)2015-10-29

Thanks a lot :)

RicardoS20 (author)2015-08-07

Thanks!

RBA2000 (author)2015-07-16

What about:

#include <LiquidCrystal_I2C.h>

rkasemi (author)2015-02-01

error say 'lcd' was not declared in this scope
what is the problem can you give me soultion?

kantona80 (author)rkasemi2015-02-01

It could a problem related to libraries. Did you download the LiquidCrystal_I2Cv1-1.rar
From mine instructables and imported in your arduino IDE?

This is awesome!

About This Instructable

42,388views

33favorites

License:

More by kantona80:PacMan and custom characters on Arduino with a 16x2 LCD I2C YwRobot LCM1602 IIC V1
Add instructable to: