• Worldwide Shipping

  • 24/7 Customer Support

  • FAQ
  • Worldwide Shipping

  • 24/7 Customer Support

  • FAQ

How to use: Matrix membrane keyboard

Are you a starter with Croduino? 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 e-radionica 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 Croduino 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.

DSC_8589

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, Croduino. 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:

Model

How to connect module with Croduino

This module comes with female headers which are connected to Croduino as shown in the picture below. Since Croduino 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.
Klik za veću sliku

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.

///////////////////////////////////////////////////////////////////////////////
/*                                                                           */
/* (c) e-radionica.com 2014 - http://www.e-radionica.com/licenca             */
/* [email protected]                                                        */
/*                                                                           */
/* Matrix membrane keyboard 4x4                                              */
/*    http://e-radionica.com/hr/matrix-membranska-tipkovnica.html            */
///////////////////////////////////////////////////////////////////////////////

#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 
   }
  }

 

Leave a Reply