Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
en:iot-open:practical:hardware:taltech:arduino:scenarios:lcd [2025/09/02 14:34] – [Suggested Knowledge Resources] raivo.sellen:iot-open:practical:hardware:taltech:arduino:scenarios:lcd [2025/09/02 14:42] (current) raivo.sell
Line 1: Line 1:
 +<pagebreak>
 +====== Using LCD Display ======
 +{{:en:iot-open:practical:hardware:taltech:arduino:scenarios:lcd.jpg?300|}}
 +
 +An alphanumeric 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 the 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           |
 +
 +
 +===== 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:
 +<code c>
 +#include <LiquidCrystal.h>
 +</code>
 +
 +=== Step 2: Declare GPIO Pins ===
 +Define GPIO pins connected to LCD control lines:
 +<code c>
 +const int rs = 8, en = 9, d4 = 4, d5 = 5, d6 = 6, d7 = 7;
 +</code>
 +
 +=== Step 3: Initialize LCD ===
 +Create an instance of the LCD:
 +<code c>
 +LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
 +</code>
 +
 +Set up the display dimensions (2 rows, 16 columns):
 +<code c>
 +lcd.begin(16, 2);
 +</code>
 +
 +=== Step 4: Display Text ===
 +Write text to the LCD screen:
 +<code c>
 +lcd.setCursor(0, 0); // top left corner
 +lcd.print("Hello World");
 +
 +lcd.setCursor(0, 1); // second line
 +lcd.print("Hello IoT");
 +</code>
 +
 +===== 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.
 +
  
CC Attribution-Share Alike 4.0 International
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0