Sie sind auf Seite 1von 5

Membrane Switch Keypad

From ElectroDragon
Share on facebookShare on twitter
More Sharing Services Share
Share on linkedinShare on tumblrShare on stumbleuponShare on redditShare on
email

Contents
 1 Updated Demo Code 2013-05-24
 1.1 Demo code
 2 Introduction
 3 User guides
 4 Connecting Diagram
 5 Advanced application
 6 Buy

Updated Demo Code 2013-05-24


We have tested with library on 4X4 keypad, but there is some thing need to
change.Please follow the steps.

 Download this library, and it's refer to this arduino page.


 Use the example called "custom keypad" in the menu
 switched the pins, pin 1 connect to the keypad will make one row or one
column not work out. so let's change all the wirings from 1-4 and 5-7 to 5-
7 and 8-11.
 Always try to avoid pin 1, in other keypad version.

Demo code

/* @file CustomKeypad.pde
|| @version 1.0
|| @author Alexander Brevig
|| @contact alexanderbrevig@gmail.com
||
|| @description
|| | Demonstrates changing the keypad size and key values.
|| #
*/
#include <Keypad.h>
const byte ROWS = 4; //four rows
const byte COLS = 4; //four columns
//define the cymbols on the buttons of the keypads
char hexaKeys[ROWS][COLS] = {
{'0','1','2','3'},
{'4','5','6','7'},
{'8','9','A','B'},
{'C','D','E','F'}
};
byte rowPins[ROWS] = {7, 6, 5, 4}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {11, 10, 9, 8}; //connect to the column pinouts of the keypad

//initialize an instance of class NewKeypad


Keypad customKeypad = Keypad( makeKeymap(hexaKeys), rowPins, colPins, ROWS, COLS);

void setup(){
Serial.begin(9600);
}

void loop(){
char customKey = customKeypad.getKey();

if (customKey){
Serial.println(customKey);
}
}

Introduction
The 4x4 Keypad is a general purpose 16 button (4x4) matrix keypad. It comes
ready to work, simply peel-off the adhesive backing, stick it to your surface and
plug it in.

User guides
This is a simple application of port manipulation using Arduino to paly with the
4*4 button pad. Before read the code, you'd better see the connection diagram
first. We use four digital ports as HIGH voltage scanning the row of button pad
and four analog ports to read the column of button pad connected with four pull-
down resistors. If button is pressed,the voltage will be HIGH when it is scanned
by HIGH voltage concurrently. Otherwise, the voltage is pulled down and will be
LOW. Using eight ports totally, we can read 16 buttons.

Connecting Diagram
The resistor seems not very necessary, please concern this on your case.

Advanced application
Though the previous sample code can drive the button pad. However, this
method wastes eight I/O ports. We strongly recommend an other product GPIO,
which transforms between parallel and serial data transmission mode. Thus, with
a GPIO, we can expand at most 16 I/O ports only using an IIC interface.
We have written a more useful code to drive this button pad with a GPIO. Only
two I/O ports of Arduino board are used using IIC interface.(Analog 4 for
SDA(data) and analog 5 for SCL(clock))

Buy
Go Shopping 4×4 Matrix 16-Key Membrane Switch Keypad Keyboard (For
Arduino/AVR/PIC/ARM)

Retrieved from
"http://www.electrodragon.com/w/index.php?title=Membrane_Switch_Keypad&
oldid=3934"
Category:
 Keypad

Das könnte Ihnen auch gefallen