arduino character lcd tutorial

Upload: karlitosman

Post on 01-Jun-2018

220 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/9/2019 Arduino Character LCD Tutorial

    1/3

    22/1/2015 Arduino Character LCD Tutorial

    http://www.hacktronics.com/Tutorials/arduino-character-lcd-tutorial.html 1/3

    Home Tutorials Projects Tools Contact Us

    ShoppingAccessories

    Android ADK

    Arduino

    BlinkM

    Cables

    Clearance

    Components

    LCDs

    Power

    Prototyping

    Robotics

    Sensors

    Video-Audio

    Wearable Computing

    Wireless

    Zigbee / Xbee

    List All Products

    Product Search

    Search

    Advanced Search

    Username

    Password

    Remember me

    LoginLos t Password?

    Forgot your username?

    No account yet? Register

    View Cart/Checkout

    Your Cartis currently empty.

    Newest Products!

    Current Sensor 30 Amp

    $8.95

    Add to Cart

    Arduino Pro

    $19.95

    Add to Cart

    Seeeduino Mega

    $43.00

    Add to Cart

    Arduino Character LCD Tutorial

    See the LCD Shield for Arduino for a pre-assem bled LCD+ Keypad shield.

    Your Arduino has things to tell you. One of the easiest ways to let it com municate is to attach a character LCD. These LCD modules

    are a lot of fun, however they can be tricky to get working right. Many a hacker has spent hours trying to get one working, only to suffer

    through frustration and hum iliation. Hacktronics is here to help.

    The LCD m odules covered here are based on the very popular HD44780 controller.

    Software used in this tutorial can be downloaded here:

    Arduino LCD Software Example

    Hardware used in this tutorial:

    LCD HackPack, 16x2 or 20x4 (includes LCD m odule, header pins, smal l solderles s breadboard, wire jumpers, and contrast resistor)

    Arduino Uno, Mega, or som ething com patible

    Instructions:

    -----

    If this is your first Arduino project, first go through our Arduino: Getting Started and Beginning Solderless Breadboards tutorials.

    -----

    Use your solderless breadboard and wire jumpers to make these connections:

    LCD Pin Connect to

    1 (VSS) GND Arduino pin*

    2 (VDD) + 5v Arduino pin

    3 (contrast) Resistor or potentiometer to GND Arduino pin*4 RS Arduino pin 12

    5 R/W Arduino pin 11

    6 Enable Arduino pin 10

    7 No connection

    8 No connection

    9 No connection

    10 No connection

    11 (Data 4) Arduino pin 5

    12 (Data 5) Arduino pin 4

    13 (Data 6) Arduino pin 3

    14 (Data 7) Arduino pin 2

    15 Backlight + Resistor to Arduino pin 13**

    16 Backlight GND GND Arduino pin*

    *Use a breadboard rail to make multiple connections to the Arduino GND pin

    *For potentiometer connection, use the potentiometer's center pin and ei ther of the other pins to make the connection from LCD pin 3

    to Arduino GND

    ** A current limiting res istor or potentiometer (40 Ohm minim um) s hould be used to avoid excessive current.

    OSD DisplaysStandard and Custom TFT-LCD, OLED, STN & TN LCD

    http://www.hacktronics.com/View-your-cart-content.htmlhttp://www.hacktronics.com/Lost-password.htmlhttp://www.hacktronics.com/View-all-products-in-shop.html?category=0http://www.hacktronics.com/Zigbee-/-Xbee/View-all-products.htmlhttp://www.hacktronics.com/Wireless/View-all-products.htmlhttp://www.hacktronics.com/Video-Audio/View-all-products.htmlhttp://www.hacktronics.com/Wearable-Computing/View-all-products.htmlhttp://www.hacktronics.com/Wearable-Computing/View-all-products.htmlhttp://www.hacktronics.com/Robotics/View-all-products.htmlhttp://www.hacktronics.com/Power/View-all-products.htmlhttp://www.hacktronics.com/Cables/View-all-products.htmlhttp://www.hacktronics.com/Arduino/View-all-products.htmlhttp://www.hacktronics.com/hackpacks/LCD/LCD_example.ziphttp://www.hacktronics.com/Arduino/LCD-Shield-for-Arduino/flypage.tpl.htmlhttp://www.hacktronics.com/Tutorials/arduino-character-lcd-tutorial.htmlhttp://www.hacktronics.com/http://www.hacktronics.com/Table/Tutorials/http://www.hacktronics.com/Projects/http://www.hacktronics.com/Lost-user-name.htmlhttp://www.hacktronics.com/Video-Audio/View-all-products.htmlhttp://www.hacktronics.com/Create-customer-account.htmlhttp://www.hacktronics.com/Android-ADK/View-all-products.htmlhttp://www.hacktronics.com/Perform-detailed-search.htmlhttp://www.hacktronics.com/Contact-Us/Name.htmlhttp://www.hacktronics.com/Tutorials/arduino-character-lcd-tutorial.htmlhttp://www.hacktronics.com/Arduino/Arduino-Boards/Arduino-Pro/flypage.tpl.htmlhttp://www.hacktronics.com/Arduino/View-all-products.htmlhttp://www.hacktronics.com/LCDs/View-all-products.htmlhttp://www.hacktronics.com/Zigbee-/-Xbee/View-all-products.htmlhttp://www.hacktronics.com/Lost-password.htmlhttp://www.hacktronics.com/Wearable-Computing/View-all-products.htmlhttp://www.hacktronics.com/Sensors/View-all-products.htmlhttp://www.hacktronics.com/BlinkM/View-all-products.htmlhttp://del.icio.us/http://www.hacktronics.com/Table/Tutorials/http://www.hacktronics.com/Clearance/View-all-products.htmlhttp://www.hacktronics.com/Projects/http://www.hacktronics.com/hackpacks/LCD/LCD_example.ziphttp://www.hacktronics.com/Wireless/View-all-products.htmlhttp://digg.com/http://www.hacktronics.com/View-all-products-in-shop.html?category=0http://www.hacktronics.com/Arduino/LCD-Shield-for-Arduino/flypage.tpl.htmlhttp://www.hacktronics.com/LCDs/LCD-HackPack/flypage.tpl.htmlhttp://www.hacktronics.com/Tutorials/beginning-solderless-breadboards.htmlhttp://www.hacktronics.com/Prototyping/View-all-products.htmlhttp://www.hacktronics.com/Power/View-all-products.htmlhttp://www.hacktronics.com/Accessories/View-all-products.htmlhttp://www.hacktronics.com/Table/Tools/http://www.hacktronics.com/Cables/View-all-products.htmlhttp://www.hacktronics.com/Sensors/Current-Sensor-30-Amp/flypage.tpl.htmlhttp://www.hacktronics.com/Tutorials/arduino-flashing-led.htmlhttp://www.hacktronics.com/Robotics/View-all-products.htmlhttp://www.hacktronics.com/Arduino/Arduino-Boards/View-all-products.htmlhttp://www.hacktronics.com/Arduino/Seeeduino-Mega/flypage.tpl.htmlhttp://www.hacktronics.com/Components/View-all-products.htmlhttp://www.hacktronics.com/View-your-cart-content.htmlhttp://www.hacktronics.com/
  • 8/9/2019 Arduino Character LCD Tutorial

    2/3

    22/1/2015 Arduino Character LCD Tutorial

    http://www.hacktronics.com/Tutorials/arduino-character-lcd-tutorial.html 2/3

    It should look something like this:

    Software

    Here is the driver code:

    /* ------------------------------------------------------------------------------- */

    // character LCD example code

    // www.hacktronics.com

    #include

    // Connections:// rs (LCD pin 4) to Arduino pin 12

    // rw (LCD pin 5) to Arduino pin 11

    // enable (LCD pin 6) to Arduino pin 10

    // LCD pin 15 to Arduino pin 13

    // LCD pins d4, d5, d6, d7 to Arduino pins 5, 4, 3, 2

    LiquidCrystal lcd(12, 11, 10, 5, 4, 3, 2);

    int backLight = 13; // pin 13 will control the backlight

    void setup()

    {

    pinMode(backLight, OUTPUT);

    digitalWrite(backLigh t, HIGH); // turn backligh t on. Replace 'HIGH' with 'LOW' to turn it off.

    lcd.begin(16,2); // columns, rows. use 16,2 for a 16x2 LCD, etc.

    lcd.clear(); // start with a blank screen

    lcd.setCursor(0,0); // set cursor to column 0, row 0 (the first row)

    lcd.print("Hel lo, World"); // change this text to whatever you like. keep it clean.

    lcd.setCursor(0,1); // set cursor to column 0, row 1 lcd.print("hacktronics.com");

    // if you have a 4 row LCD, uncomm ent these lines to write to the bottom rows

    // and change the lcd.begin() statement above.

    //lcd.setCursor(0,2); // set cursor to column 0, row 2

    //lcd.print("Row 3");

    //lcd.setCursor(0,3); // set cursor to column 0, row 3

    //lcd.print("Row 4");

    }

    void loop()

    {

    }

    /* ------------------------------------------------------------------------------- */

    You can also download it here example LCD s oftware, and unzip the file.

    You will now have a folder called LCD_example

    Start the Arduino s oftware and load the example program by clicking File->Sketchbook->Open

    Navigate to the LCD_example folder and s elect the LCD_example.pde file.

    Transfer the program to your Arduino by clicking the Upload to I/O board button. After uploading, on the LCD you should see:

    Hello, World

    hacktronics.com

    If you do not s ee this m ess age, your LCD m odule m ay be out of sync with your Arduino. Just press the reset button on your Arduino (it

    may take a couple of res ets), and they should s ynchronize.

    See the comments in the example code for instructions on positioning the cursor and printing your own mess ages to the LCD. It is

    that simple!

    Happy hacking.

    Send feedback on this tutorial here.

    http://www.hacktronics.com/Contact-Us/Name.htmlhttp://www.hacktronics.com/hackpacks/LCD/LCD_example.ziphttp://www.hacktronics.com/images/arduino_lcd_connections-lg.jpg
  • 8/9/2019 Arduino Character LCD Tutorial

    3/3

    22/1/2015 Arduino Character LCD Tutorial

    http://www.hacktronics.com/Tutorials/arduino-character-lcd-tutorial.html 3/3

    Sitio Oficial DIRECTVNo te Pierdas Nada en la TV. Graba, Pausa y Retrocede. Contrata Ahora!