How to do connections of 16x2 LCD display
LCD display connections
Components and supplies
1
Arduino UNO
1
Jumper wires (generic)
1
Solderless Breadboard Full Size
1
Resistor 330 ohm
1
Alphanumeric LCD, 16 x 2
1
Single Turn Potentiometer- 10k ohms
Apps and platforms
1
Arduino IDE
Project description
Code
Arduino code
arduino
1/* 2 LiquidCrystal Library - Custom Characters 3 4 Demonstrates how to add custom characters on an LCD display. 5 The LiquidCrystal library works with all LCD displays that are 6 compatible with the Hitachi HD44780 driver. There are many of 7 them out there, and you can usually tell them by the 16-pin interface. 8 9 This sketch prints "I <heart> Arduino!" and a little dancing man 10 to the LCD. 11 12 The circuit: 13 * LCD RS pin to digital pin 12 14 * LCD Enable pin to digital pin 11 15 * LCD D4 pin to digital pin 5 16 * LCD D5 pin to digital pin 4 17 * LCD D6 pin to digital pin 3 18 * LCD D7 pin to digital pin 2 19 * LCD R/W pin to ground 20 * 10K potentiometer: 21 * ends to +5V and ground 22 * wiper to LCD VO pin (pin 3) 23 * 10K poterntiometer on pin A0 24 25 created 21 Mar 2011 26 by Tom Igoe 27 modified 11 Nov 2013 28 by Scott Fitzgerald 29 modified 7 Nov 2016 30 by Arturo Guadalupi 31 32 Based on Adafruit's example at 33 https://github.com/adafruit/SPI_VFD/blob/master/examples/createChar/createChar.pde 34 35 This example code is in the public domain. 36 http://www.arduino.cc/en/Tutorial/LiquidCrystalCustomCharacter 37 38 Also useful: 39 http://icontexto.com/charactercreator/ 40 41*/ 42 43// include the library code: 44#include <LiquidCrystal.h> 45 46// initialize the library by associating any needed LCD interface pin 47// with the arduino pin number it is connected to 48const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2; 49LiquidCrystal lcd(rs, en, d4, d5, d6, d7); 50 51// make some custom characters: 52byte heart[8] = { 53 0b00000, 54 0b01010, 55 0b11111, 56 0b11111, 57 0b11111, 58 0b01110, 59 0b00100, 60 0b00000 61}; 62 63byte smiley[8] = { 64 0b00000, 65 0b00000, 66 0b01010, 67 0b00000, 68 0b00000, 69 0b10001, 70 0b01110, 71 0b00000 72}; 73 74byte frownie[8] = { 75 0b00000, 76 0b00000, 77 0b01010, 78 0b00000, 79 0b00000, 80 0b00000, 81 0b01110, 82 0b10001 83}; 84 85byte armsDown[8] = { 86 0b00100, 87 0b01010, 88 0b00100, 89 0b00100, 90 0b01110, 91 0b10101, 92 0b00100, 93 0b01010 94}; 95 96byte armsUp[8] = { 97 0b00100, 98 0b01010, 99 0b00100, 100 0b10101, 101 0b01110, 102 0b00100, 103 0b00100, 104 0b01010 105}; 106 107void setup() { 108 // initialize LCD and set up the number of columns and rows: 109 lcd.begin(16, 2); 110 111 // create a new character 112 lcd.createChar(0, heart); 113 // create a new character 114 lcd.createChar(1, smiley); 115 // create a new character 116 lcd.createChar(2, frownie); 117 // create a new character 118 lcd.createChar(3, armsDown); 119 // create a new character 120 lcd.createChar(4, armsUp); 121 122 // set the cursor to the top left 123 lcd.setCursor(0, 0); 124 125 // Print a message to the lcd. 126 lcd.print("I "); 127 lcd.write(byte(0)); // when calling lcd.write() '0' must be cast as a byte 128 lcd.print(" Arduino! "); 129 lcd.write((byte)1); 130 131} 132 133void loop() { 134 // read the potentiometer on A0: 135 int sensorReading = analogRead(A0); 136 // map the result to 200 - 1000: 137 int delayTime = map(sensorReading, 0, 1023, 200, 1000); 138 // set the cursor to the bottom row, 5th position: 139 lcd.setCursor(4, 1); 140 // draw the little man, arms down: 141 lcd.write(3); 142 delay(delayTime); 143 lcd.setCursor(4, 1); 144 // draw him arms up: 145 lcd.write(4); 146 delay(delayTime); 147}
Downloadable files
Circuit Diagram
Circuit Diagram

Circuit Diagram
Circuit Diagram

Comments
Only logged in users can leave comments