Using Arduino 16x2 LCD Keypad Shield

LCD Shield Ardunio

Using Arduino 16x2 LCD Keypad Shield

 Today, in this article, I will tell you how you can use the LCD Keypad Shield module with Arduino and which pins are left open. Let's get right into the article without further ado.

Placing the Shield onto Arduino

The pins on the shield are inserted so that they fit perfectly onto the Arduino and pressed down. When the pins are completely seated, it means the shield is now ready to work together with Arduino.

Arduino LCD Shield Arduino LCD Shield Arduino LCD Shield


Let's Look at the Pins on the Shield

LCD Shield

There are 7 pins on the shield, and these pins correspond to the following pins on the Arduino, from left to right: 13, 12,11,3,2,1,0 

The pins located at the bottom are Reset, 3.3V, 5V, GND, GND, VIN, A1,A2,A3,A4,A5

Shield Button Values

When you read buttons as analog data, which button sends which analog value.

Shield Pins

Which pin performs which function when the shield is connected to the Arduino.

Commands You Can Use While Using the LCD Screen

Command

Feature

lcd.clear()

Clears the screen.

lcd.print(data)

Writes text to the screen

lcd.setCursor(x,y)

Allows you to begin writing at the X and Y rows.

lcd.scrollDisplayLeft()

Scrolls the display to the left

lcd.scrollDisplayRight()

Scrolls the display to the right

lcd.creatChar(num,data)

Used to create special characters.

 

How is the Screen on the Shield Used?

If you have used any LCD screen before, you can use the LCD screen on this shield very easily as well; in terms of usage, it is almost the same, just that the thing that is different is controlling the backlight not by code but by controlling pin number 10.

The library we use to write text on the screen, as in nearly all other LCD screens, is "#include <LiquidCrystal.h>"

Let's do a sample operation to display text on the screen.
#include <LiquidCrystal.h>

// Screen
LiquidCrystal Ekran(8, 9, 4, 5, 6, 7);


// Basic Functions
void setup() {
  Serial.begin(9600);
  BTSerial.begin(38400);
  Ekran.begin(16, 2);
  Ekran.setCursor(0,0);
  Ekran.print("UrhobA");
  Ekran.setCursor(0,1);
  Ekran.print("2. Line");

}

void loop() {

}

As for how to use the buttons on the screen, anyone who knows how to use analog pins can easily use the buttons on the shield. We take the data coming over the analog values and can use them by making the necessary assignment.

I already mentioned which analog value comes from which button in the "let's look at the pins" section above, you can take a look at that.

If you print the pressed button on the screen with the code below, it will return you a value like 0, 1, 2, 3, 4, 5, and you can see that we did this with the ButtonFind function below.
#include <LiquidCrystal.h>


// Screen
LiquidCrystal Ekran(8, 9, 4, 5, 6, 7);
int basilanTus = 0;
int okunanDeger = 0;

#define rightButton      0;
#define leftButton      1;
#define upButton   2;
#define downButton    3;
#define selectButton      4;
#define noneButton      5;

// Special Functions

byte ButtonFind() {
  okunanDeger = analogRead(A0);
  if (okunanDeger > 1000) {
    return noneButton;
  }
  if (okunanDeger < 50) {
    return rightButton;
  }
  if (okunanDeger < 195) {
    return upButton;
  }
  if (okunanDeger < 380) {
    return downButton;
  }
  if (okunanDeger < 555) {
    return leftButton;
  }
  if (okunanDeger < 790) {
    return selectButton;
  }
}
void ClearScreen(int x, int y) {
  Ekran.setCursor(x, y);
  Ekran.print("                ");
}
void PrintScreen(int x, int y, String text) {
  Ekran.setCursor(x, y);
  Ekran.print(text);
}


// Basic Functions
void setup() {
  Serial.begin(9600);
  BTSerial.begin(38400);
  Ekran.begin(16, 2);
  PrintScreen(0, 0, "    UrhobA     ");
  PrintScreen(0, 1, "System Starting..");
  delay(1000);
  ClearScreen(0, 1);
  PrintScreen(0, 1, "System Started");
  delay(1000);
  Ekran.setCursor(0, 1);
  ClearScreen(0, 1);

}

void loop() {
  basilanTus = ButtonFind();
  Ekran.setCursor(0, 1);


}