Professional Documents
Culture Documents
Grab The Following Quantities of Each Part Listed To Build This Circuit
Grab The Following Quantities of Each Part Listed To Build This Circuit
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
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.
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
}