Ardu? No!MTobjectsButton setsMTkeypad ≫ Test 2

MTkeypad: Test 2
Event management for Uno, Nano, Mega

Test and character

Complete program example

// MTkeypad basic test with characters display

//   4    5    6    7
//   │    │    │    │
//   ├─1  ├─2  ├─3  ├─A
//   │ └──│─┴──│─┴──│─┴───A0
//   ├─4  ├─5  ├─6  ├─B
//   │ └──│─┴──│─┴──│─┴───A1
//   ├─7  ├─8  ├─9  ├─C
//   │ └──│─┴──│─┴──│─┴───A2
//   └─*  └─0  └─#  └─D
//     └────┴────┴────┴───A3


#include <MTobjects.h> // V1.1.0 See http://arduino.dansetrad.fr/en/MTobjects

const uint8_t PIN_LINES[] = {4 lines_on, A0, A1, A2, A3}; // Keypad lines pins
const uint8_t PIN_COLUMNS[] = {4 columns_on, 4, 5, 6, 7}; // Keypad columns pins

const char keys[] = { // Correspondence for display
    '1','2','3','A',
    '4','5','6','B',
    '7','8','9','C',
    '*','0','#','D'};

void display(int8_t key) // Called when you press a key
{
  Serial.print(keys[key]); // Associated character display
}

void release(void) // Called when you drop all the keys
{
  Serial.println();
}

MTkeypad Keypad(PIN_LINES, PIN_COLUMNS, display, release); // Implementation of keypad

void setup()
{
  Serial.begin(115200); // Also put the console on 115200 Bauds
}
  
void loop(){}