CONNECTING A LCD DISPLAY

advertisement
CONNECTING A LCD
DISPLAY
AMILCAR RINCON CHARRIS. PHD.
INTER AMERICAN UNIVERSITY OF PUERTO RICO - BAYAMON
CONNECTING A 1602 LCD DISPLAY
16 PINS
LCD SERIAL (SDA-SCL)
TYPES
CONNECTING THE DISPLAY AND
BREADBOARD
• Connect: Arduino 5v (pin 3) > plus column on
breadboard
Connect: Arduino GND (pin 4 or 5) > min column on
breadboard
CONNECT THE LCD POWER AND THE
BACKLIGHT POWER
•
•
•
•
Connect: GND row (min) on breadboard > pin 1 on LCD (VSS).
Connect: +5v row (plus) on breadboard > pin 2 on LCD (VDD).
Connect: +5v row (plus) on breadboard > pin 15 on LCD (A).
Connect: GND row (min) on breadboard > pin 16 on LCD (K)
POWER UP THE ARDUINO
POTMETER
• Connect: first pin of the potmeter > GND of the breadboard.
• Connect: middle pin of the potmeter > pin 3 of the LCD
display (VO).
• Connect : third pin of the potmeter> 5V of the breadboard.
COMMUNICATE WITH THE LCD
SCREEN
• Connect: pin 4 of the LCD display (RS) > pin 7 of the
Arduino.
• Connect: pin 5 of the LCD display (RW) > GND row of the
breadboard.
• Connect: pin 6 of the LCD display (E) > pin 8 of the
Arduino.
• Connect: pin 11 of the LCD display (D4) > pin 9 of the
Arduino.
• Connect: pin 12 of the LCD display (D5) > pin 10 of the
Arduino.
• Connect: pin 13 of the LCD display (D6) > pin 11 of the
Arduino.
• Connect: pin 14 of the LCD display (D7) > pin 12 of the
Arduino.
CONNECTIONS
THE CODE
• #include <LiquidCrystal.h>
LiquidCrystal lcd(7, 8, 9, 10, 11 , 12);
}
void setup() {
lcd.begin(16, 2);
lcd.setCursor(0,0);
lcd.write(“HOLA");
void loop() { }
LIQUIDCRYSTAL()
Description
• Creates a variable of type LiquidCrystal. The display
can be controlled using 4 or 8 data lines. If the
former, omit the pin numbers for d0 to d3 and leave
those lines unconnected. The RW pin can be tied to
ground instead of connected to a pin on the
Arduino; if so, omit it from this function's parameters.
Syntax
• LiquidCrystal(rs, enable, d4, d5, d6, d7)
BEGIN()
Description
Initializes the interface to the LCD screen, and
specifies the dimensions (width and height) of the
display. begin()needs to be called before any other
LCD library commands.
Syntax
• lcd.begin(cols, rows)
Parameters
• lcd: a variable of type LiquidCrystal
• cols: the number of columns that the display has
• rows: the number of rows that the display has
PRINT()
Description
• Prints text to the LCD.
Syntax
• lcd.print(data)
Parameters
• lcd: a variable of type LiquidCrystal
• data: the data to print (char, byte, int, long, or
string)
EXAMPLE
• #include <LiquidCrystal.h>
LiquidCrystal lcd(7, 8, 9, 10, 11 , 12);
void setup()
{
lcd.print("hello, world!");
}
void loop() {}
DISPLAY()
Description
• Turns on the LCD display, after it's been turned off
with noDisplay(). This will restore the text (and
cursor) that was on the display.
Syntax
• lcd.display()
Parameters
• lcd: a variable of type LiquidCrystal
EXAMPLE
• // include the library code:
#include <LiquidCrystal.h>
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(7, 8, 9, 10, 11 , 12);
void setup() {
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
// Print a message to the LCD.
lcd.print("hello, world!");
}
void loop() {
// Turn off the display:
lcd.noDisplay();
delay(500);
// Turn on the display:
lcd.display();
delay(500);
}
NOCURSOR()
Description
• Hides the LCD cursor.
Syntax
• lcd.noCursor()
Parameters
• lcd: a variable of type LiquidCrystal
EXAMPLE
• // include the library code:
#include <LiquidCrystal.h>
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(7, 8, 9, 10, 11 , 12);
void setup() {
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
// Print a message to the LCD.
lcd.print("hello, world!");
}
void loop() {
// Turn off the cursor:
lcd.noCursor();
delay(500);
// Turn on the cursor:
lcd.cursor();
delay(500);
}
SETCURSOR()
• lcd.setCursor(0, 0); // top left lcd.setCursor(15, 0); //
top right lcd.setCursor(0, 1); // bottom left
lcd.setCursor(15, 1); // bottom right
LIQUIDCRYSTAL LIBRARY
LCD 1602-04
LCD 1602
REFERENCES
• http://www.dreamdealer.nl/tutorials/connecting_a
_1602a_lcd_display_and_a_light_sensor_to_arduino_
uno.html
• https://www.arduino.cc/en/Reference/LiquidCrysta
l
Download