HOW TO USE: MATRIX MEMBRANE KEYBOARD

HOW TO USE: MATRIX MEMBRANE KEYBOARD-Uncategorized

Are you a starter with Dasduino? Or a newbie when it comes to electronics? You fancy a specific module, but you don’t know how to use it? Don’t worry, we have our How To Use series!

How to Use is a series of blog tutorials by soldered where you will find everything you need to begin working with your favorite modules. Tutorials include technical characteristics, operating principles, instructions on how to connect the module with Dasduino and basic coding. Everything else is up to you and your imagination.

BASIC FEATURES

Matrix membrane keyboard is one of the most basic modules. It contains 16 buttons, arranged in 4 rows and 4 columns and we use it as number input to our microcontroller.

Characteristics:

  • Maximum voltage: 35V
  • Maximum current: 100mA
  • Working temperature: -20 to +50°C 
  • Dimensions: 6,9 x 7,6 x 0,1 cm

 

WORKING PRINCIPLE

Matrix membrane keyboard uses a combination of 4 rows and 4 columns which determines each button of the keyboard to the microcontroller, Dasduino. Physically, below each button, there is a pushbutton which is connected to red with one end and to the column with the other. You can see these connections in the picture below:

HOW TO CONNECT MODULE WITH DASDUINO

This module comes with female headers which are connected to Dasduino as shown in the picture below. Since Dasduino comes with female headers as well, most simple way to make a connection is to add male headers in between. We can establish the connection with male-to-male cables too.

CODE

A code for Matrix membrane keyboard can be downloaded from the link below. To make it more simple, we used the Keypad library, and code shows an activated button inside a Serial monitor. If you are having any issues regarding library installation, follow our tutorial.

///////////////////////////////////////////////////////////////////////////////
/*                                                                           */
/* e.radionica@me.com                                                        */
/*                                                                           */
/* Matrix membrane keyboard 4x4                                              */
/*    https://soldered.com/product/membrane-keyboard-4x4/ */
///////////////////////////////////////////////////////////////////////////////
#include "Keypad.h"  // the code uses the Keypad.h library
                     // which you can download at http://bit.ly/1npE1Qs
const byte red = 4;    // the keyboard has 4 rows 
const byte stupac = 4; // and 4 columns
  char tipke[red][stupac]  = {  // define the position of keys on the keyboard
   {'1','2','3','A'},
   {'4','5','6','B'},
   {'7','8','9','C'},
   {'*','0','#','D'}
};
  byte red_pinovi[red] = {7,6,5,4};   // we connect the row pins in turn to PIN9, PIN8, PIN7, PIN6   
  byte stupac_pinovi[stupac] = {3,2,1,0};  // we connect the column pins in turn to PIN5, PIN4, PIN3, PIN2
  
  Keypad tipkovnica = Keypad(makeKeymap(tipke), red_pinovi, stupac_pinovi, red, stupac);
  
  void setup() {
    Serial.begin(9600);  // starting serial communication
  }
  
  void loop(){  
    char utipkano = tipkovnica.getKey();  // registers the pressed key
    
   if (utipkano) {               // in order to avoid sums, the result
    Serial.println(utipkano);    // is shown only if something is typed
   }
  }