Arduino LCD Lab CTY SAR FCPS SHAWN LUPOLI

Arduino LCD Lab CTY SAR FCPS SHAWN LUPOLI, ELLIOT TAN

Let’s understand what we are working with…

How does the LCD work? Microcontroller has to manipulate several interface pins at once to control the display Register select (RS) pin – controls where in memory you are writing data to Read/Write (R/W) pin – selects reading or writing mode Enable pin – enables writing to registers 8 data pins – states of these pins are the values the LCD is reading Liquid Crystal library allows you to control LCD displays which are compatible with the Hitachi HD 44780 driver 16 pin interface Liquid Crystal simplifies two processes Puts data that form the image into the data registers Then puts instructions in the instruction registers

Visual of Connecting Arduino to LCD

Goal

Programming “Hello World” on LCD

“Hello World” Part 1 Include all necessary libraries #include <Liquid. Crystal. h> Initializing global variables The LCD itself needs to initialized as a Liquid. Crystal object “Liquid. Crystal lcd(12, 11, 5, 3, 2)” Setup() lcd. begin(cols, rows) – initializes interface to LCD screen, then specifies the dimensions of the display lcd. print(“Hello, World”) – prints text to the LCD

“Hello World” Part 2 Loop() Functions lcd. set. Cursor(col, row) – positions the LCD cursor, sets location where subsequent text written to LCD will be displayed Millis() – returns the numer of milliseconds sine the Arduino board began running current program Examples lcd. set. Cursor(0, 1) – sets cursor to column 0, line 1 lcd. print(millis() / 1000) – prints number of seconds since reset

CODE

Building the LCD circuit

Supplies 1 Arduino Leonardo/Uno board * Notes: 1 breadboard v Wires are 22 or 24 AWG, solid v Short wires = 5 cm v Medium wires = 12 cm v Long wires = 16 cm 6 short wires (2 red, 4 black) 4 medium wires (3 brown, 1 black) 5 long wires (1 red, 4 brown) 1 potentiometer 1 resistor (1 kΩ) 1 LCD

Diagram of LED Circuit

Connecting Code and Circuit

Putting it All Together UPLOAD! Remember to check for the flashing RX and TX lights, and a “Successful upload” message in your console Understanding the process LCD RS pin to digital pin 12 LCD Enable pin to digital pin 11 LCD D 4 pin to digital pin 5 LCD D 5 pin to digital pin 4 LCD D 6 pin to digital pin 3 LCD D 7 pin to digital pin 2 LCD R/W pin to ground

Troubleshooting Make sure to turn on the Potentiometer! Make sure all wires are connected to the correct pin! Questions?
- Slides: 15