tech-support

*/ ?>

You are still a beginner in case of using Croduino. Or with electronics in general? Certain module occupied your thoughts but you don't know how to use it? How to use modules series is there for you! How to use modules is a blog tutorial series in which you will find all that you need to start working with your favorite module. Tutorials include technical characteristics, working principles, manuals about how to connect modules with Croduino and basic code. Rest is left for your imagination.

Basic characteristics

  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 membranska tipkovnica 4x4                                          */
/*    http://e-radionica.com/hr/matrix-membranska-tipkovnica.html            */
///////////////////////////////////////////////////////////////////////////////

#include "Keypad.h"  // kod koristi library Keypad.h
                     // mozes ga preuzeti na http://bit.ly/1npE1Qs

const byte red = 4;    // Tipkovnica ima 4 reda
const byte stupac = 4; // i 4 stupca

  char tipke[red][stupac]  = {  // definiraj polozaj tipki na tipkovnici
   {'1','2','3','A'},
   {'4','5','6','B'},
   {'7','8','9','C'},
   {'*','0','#','D'}
};

  byte red_pinovi[red] = {7,6,5,4};   // pinove redova spajamo redom na PIN9, PIN8, PIN7, PIN6    
  byte stupac_pinovi[stupac] = {3,2,1,0};  // pinove stupaca spajamo redom na PIN5, PIN4, PIN3, PIN2
  
  Keypad tipkovnica = Keypad(makeKeymap(tipke), red_pinovi, stupac_pinovi, red, stupac);
  
  void setup() {
    Serial.begin(9600);  // zapocinjemo serijsku komunikaciju
  }
  
  void loop(){   
    char utipkano = tipkovnica.getKey();  // registrira pritisnutu tipku
    
   if (utipkano) {               // kako bi izbjegli sumove, rezultat 
    Serial.println(utipkano);    // prikazujemo samo ako je nesto utipkano
   }
  }