Introduction: Interfacing Keypad and LCD With Intel Galileo

Introduction

In this tutorial am going to show you how to interface a liquid crystal

display and a keypad with Intel Galileo. In this tutorial we will use a 16x2 LCD,which displays 2 rows or character in 16 columns.

Step 1: Components;

Components;

1. Intel Galileo.

2. 4x4 matrix keypad.

3. 16x2 Liquid Crystal Display (LCD).

4. Potentiometer.

Step 2: Setup and Schematic;

-connect pin 1-VSS of the LCD to ground and also end of the

potentiometer to

ground.

-connect pin 2-VDD of the LCD to power, to provide power for the LCD.

-connect pin 3-VEE of the LCD to the variable terminal of the potentiometer.

This pin is used to adjust the contrast of the LCD.

-connect pin 4-RS of the LCD to pin 12 of Galileo.

-connect pin 5-RW of the LCD to ground.

-connect pin 6-E of the LCD to pin 11 of Galileo.

-connect pin 11-D4 of the LCD to pin 5 of Galileo.

-connect pin 12-D5 of the LCD to pin 4 of Galileo.

-connect pin 13-D6 of the LCD to pin 3 of Galileo.

-connect pin 14-D7 of the LCD to pin 2 of Galileo.

-connect pin 13 of Galileo to pin 1 of the keypad.

-connect pin 10 of Galileo to pin 2 of the keypad.

-connect pin 9 of Galileo to pin 3 of the keypad.

-connect pin 8 of Galileo to pin 4 of the keypad.

-connect pin 7 of Galileo to pin 5 of the keypad.

-connect pin 6 of Galileo to pin 6 of the keypad.

-connect pin 1 of Galileo to pin 7 of the keypad.

Step 3: Working;

When the project is switched on, power is fed to the LCD and

the back light

goes on.

When the keypad is pressed contact is made between two terminals to represent

a character.

Each character is represented by a combination of contact between two terminals.

The character pressed on the keypad is read by the pins of the Galileo.

The Galileo sets a position on the LCD as specified in the program where the

Character is to be printed.

It then sends the character to the LCD and it is printed on the set position.

This whole process prints the specific character pressed on the key pad on to

the LCD.

Step 4: Code;

#include <liquidCrystal.h>

#include<Keypad.h>

#include<Wire.h>

const byte rows=4;

const byte cols=3;

char keys[rows][cols]={

{'1','2','3'},

{'4','5','6'},

{'7','8','9'},

{'*','0','#'}

};

byte rowPins[rows]={13,10,9,8};

byte colPins[cols]={7,6,1};

Keypad keypad=Keypad(makeKeymap(keys),rowPins,colPins,rows,cols);

LiquidCrystal Lcd(12,11,5,4,3,2);

void setup() {

Lcd.begin(16,2);

Lcd.setCursor(1,0);

Lcd.print("Press a number");

// put your setup code here, to run once:

}

void loop() {

char key=keypad.getKey();

if(int(key)!=0)

{

Lcd.setCursor(5,1);

Lcd.print(key);

}

}