Saturday, August 13, 2016

LCD Interfacing



INTRODUCTION:

In this circuit, you’ll learn about how to use an LCD. An LCD, or liquid crystal display, is a simple screen that can display commands, bits of information, or readings from your sensor - all depending on how you program your board. In this circuit, you’ll learn the basics of incorporating an LCD into your project.

A Liquid Crystal Display (LCD) is a sophisticated module that can be used to display text or numeric data. The display included is two lines of 16 characters, and a backlight so it can be used at night. If you've been using the Serial Monitor to output data, you'll find that a LCD provides many of the same benefits without needing to drag a large computer around. This sketch will show you how to connect an LCD to your Arduino and display any data you wish.



MATERIALS NEEDED:


1 PC

1 Keyboard and 1 Mouse


1 Wireduino Board


1 USB cable


1 Breadboard


1 Potentiometer


16 Jumper Wires


1 LCD 2 X 16




PROCEDURE:



Hardware connections:

The LCD has a 16-pin male header attached to it along the top edge. Pin 1 is the pin closest to the corner of the LCD. Pin 16 is the pin closest to the center of the LCD. Plug the LCD into your breadboard. As usual, you will want to connect the + and - power rails on the side of the breadboard to 5V and GND on your Arduino. Plug your 10K potentiometer into three unused rows on your breadboard. Connect one side of the potentiometer to 5V,and the other side to GND (it doesn't matter which). When you run this sketch, you'll use the potentiometer to adjust the contrast of the LCD so you can see the display.


Now connect the LCD pins. Remember that pin 1 on the LCD is the one closest to the corner. Start there and work your way up.

1 to GND

2 to 5V

3 to the center pin on the potentiometer

4 to Arduino digital pin 12

5 to GND

6 to Arduino digital pin 11

7 (no connection)

8 (no connection)

9 (no connection)

10 (no connection)

11 to Arduino digital pin 5

12 to Arduino digital pin 4

13 to Arduino digital pin 3

14 to Arduino digital pin 2

15 to 5V

16 to GND



Once everything is connected, load this sketch into the Arduino, and adjust the potentiometer until the display is clear.

Library

The LCD has a chip built into it that controls all the individual dots that make up the display, and obeys commands sent to it by the the Arduino. The chip knows the dot patterns that make up all the text characters, saving you a lot of work. To communicate with this chip, we'll use the LiquidCrystal library, which is one of the standard libraries that comes with the Arduino. This library does most of the hard work of interfacing to the LCD; all you need to pick a location on the display and send your data!


Tips:


The LCD has a backlight that will light up when you turn on your Arduino. If the backlight doesn't turn on, check your connections. As we said above, the potentiometer adjusts the contrast of the display. If you can't see anything when you run the sketch, turn the potentiometer's knob until the text is clear.



1. Below is a sample program for a LCD:

#include <LiquidCrystal.h>
LiquidCrystal lcd(12,11,5,4,3,2);
void setup()
{
lcd.begin(16, 2);
lcd.clear();
lcd.print("hello, world!");
}
void loop()
{
lcd.setCursor(0,1);
lcd.print(millis()/1000);
}






No comments:

Post a Comment