830 likes | 1.47k Views
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
E N D
Arduino LCD Lab CTY SAR FCPS Shawn Lupoli, Elliot Tan
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 HD44780 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
“Hello World” Part 1 • Include all necessary libraries • #include <LiquidCrystal.h> • Initializing global variables • The LCD itself needs to initialized as a LiquidCrystal object “LiquidCrystallcd(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.setCursor(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.setCursor(0, 1) – sets cursor to column 0, line 1 • lcd.print(millis() / 1000) – prints number of seconds since reset
Supplies * Notes: • Wires are 22 or 24 AWG, solid • Short wires = 5 cm • Medium wires = 12 cm • Long wires = 16 cm • 1 Arduino Leonardo/Uno board • 1 breadboard • 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
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 D4 pin to digital pin 5 • LCD D5 pin to digital pin 4 • LCD D6 pin to digital pin 3 • LCD D7 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?