====== Using LCD Display ====== An alphanumerical LCD is a straightforward and widely used output device in embedded systems and IoT applications. The LCD used here has a fixed organization of 2 lines and 16 characters per line (2x16). This scenario guides you through displaying text on the LCD using Arduino. ===== Prerequisites ===== * Familiarize yourself with Arduino hardware reference. * Install the LiquidCrystal library (built-in Arduino library). ===== Hardware Connections ===== | LCD Pin | Arduino Pin | |---------------|-------------| | RS | 8 | | EN | 9 | | D4 | 4 | | D5 | 5 | | D6 | 6 | | D7 | 7 | | Buttons Input | A0 | ===== Suggested Knowledge Resources ===== * Arduino basic programming fundamentals. * [[taltech:arduino:hardware|Arduino Uno Hardware Reference]] ===== Task ===== Display the text "Hello World" on the first line and "Hello IoT" on the second line of the LCD. ===== Steps ===== === Step 1: Include Library === Add the LCD library to your Arduino sketch: #include === Step 2: Declare GPIO Pins === Define GPIO pins connected to LCD control lines: const int rs = 8, en = 9, d4 = 4, d5 = 5, d6 = 6, d7 = 7; === Step 3: Initialize LCD === Create an instance of the LCD: LiquidCrystal lcd(rs, en, d4, d5, d6, d7); Set up the display dimensions (2 rows, 16 columns): lcd.begin(16, 2); === Step 4: Display Text === Write text to the LCD screen: lcd.setCursor(0, 0); // top left corner lcd.print("Hello World"); lcd.setCursor(0, 1); // second line lcd.print("Hello IoT"); ===== Validation ===== The LCD should clearly display "Hello World" on line 1 and "Hello IoT" on line 2. ===== Useful Methods ===== * ''lcd.clear()'' – clears all text from the LCD. * ''lcd.setCursor(col, row)'' – positions the cursor. * ''lcd.print(data)'' – prints data to the display. ===== Troubleshooting ===== If the LCD shows incorrect characters or nothing: - Double-check wiring and pin assignments. - Verify correct initialization (`lcd.begin(16,2)`). - Adjust the contrast potentiometer on the LCD, if available.