You are on page 1of 3

PROJECT 11: LCD

Printing “Hello, world!” is usually the first thing that programming tutorials will have you do in
a new language. This guide starts by blinking an LED, but now we’re going to print out real text
using a Liquid Crystal Display (LCD).

Grab the following quantities of each part listed to build this circuit: Page | 1

NEW COMPONENTS

CHARACTER LIQUID CRYSTAL DISPLAY (LCD): Designed to show a grid of letters,


numbers and other special characters, LCDs are great for printing data and showing values.
When current is applied to this special kind of crystal, it turns opaque. This is used in a lot of
calculators, watches and simple displays. Adding an LCD to your project will make it super
portable and allow you to integrate up to 32 characters (16x2) of information.

NEW CONCEPTS

CONTRAST: Pin 3 on the LCD controls the contrast and brightness of the LCD. Using a simple
voltage divider with a potentiometer, the contrast can be adjusted. As you rotate the knob on the
potentiometer, you should notice that the screen will get brighter or darker and that the characters
become more visible or less visible. The contrast of LCDs is highly dependent on factors such as
temperature and the voltage used to power them. Thus, external contrast knobs are needed for
displays that cannot automatically account for temperature and voltage changes.

PIXELS: If you look closely at the characters on the LCD, you will notice that they are actually
made up of lots of little squares. These little squares are called pixels. The size of displays is
often represented in pixels. Pixels make up character space, which is the number of pixels in
which a character can exist.
PROJECT 11: LCD

Here is a capital letter B as created in pixels. The character space in this example is 6
pixels x 8 pixels.

HOOKUP GUIDE Page | 2


READY TO START HOOKING EVERYTHING UP? Check out the circuit diagram and
hookup table below to see how everything is connected.
PROJECT 11: LCD

Page | 3

SOURCE CODE:

#include <LiquidCrystal.h> //the liquid crystal library contains commands for printing to the display

LiquidCrystal lcd(13, 12, 11, 10, 9, 8); // tell the RedBoard what pins are connected to the display

void setup() {

lcd.begin(16, 2); //tell the lcd library that we are using a display that is 16 characters wide and 2
characters high
lcd.clear(); //clear the display
}

void loop() {

lcd.setCursor(0, 0); //set the cursor to the 0,0 position (top left corner)
lcd.print("Hello, world!"); //print hello, world! starting at that position

lcd.setCursor(0, 1); //move the cursor to the first space of the bottom row
lcd.print(millis() / 1000); //print the number of seconds that have passed since the last reset
}

You might also like