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

46,725

33

7

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...

Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

Step 1: 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

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.

Tech Contest

Participated in the
Tech Contest

Teach It! Contest Sponsored by Dremel

Participated in the
Teach It! Contest Sponsored by Dremel

Be the First to Share

    Recommendations

    • Made with Math Contest

      Made with Math Contest
    • Multi-Discipline Contest

      Multi-Discipline Contest
    • Robotics Contest

      Robotics Contest

    7 Discussions

    0
    None
    GHOSTGAMER44

    2 years ago

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

    0
    None
    TomášS18

    3 years ago

    Thanks a lot :)

    0
    None
    rkasemi

    4 years ago on Introduction

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

    1 reply
    0
    None
    kantona80rkasemi

    Reply 4 years ago

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