int main(void) { const byte rows = 4; //four rows const byte cols = 3; //three columns char keys[rows][cols] = { {'1','2','3'}, {'4','5','6'}, {'7','8','9'}, {'*','0','#'} }; byte rowPins[rows] = {J1_9, J1_8, J1_7, J1_6}; //connect to the row pinouts of the keypad byte colPins[cols] = {J1_5, J1_4, J1_3}; //connect to the column pinouts of the keypad Serial pc(PA_1, PA_0); Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, rows, cols ); pc.baud(19200); pc.println("InputNumber"); wait_ms(500); while (1) { char c = keypad.getKey(); if (c) pc.write(c); } }
#include "Keypad.h" const byte ROWS = 4; //four rows const byte COLS = 3; //three columns char keys[ROWS][COLS] = { {'1','2','3'}, {'4','5','6'}, {'7','8','9'}, {'*','0','#'} }; byte rowPins[ROWS] = {8, 7, 6, 5}; //connect to the row pinouts of the keypad byte colPins[COLS] = {4, 3, 2}; //connect to the column pinouts of the keypad Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS ); void setup() { Serial.begin(9600); } void loop() { char key = keypad.getKey(); if (key != NO_KEY) { Serial.println(key); } }
{6,6,6},{1,0,7},{1,8,1}, // 6,7,8 {1,0,9} }; uint8_t bbdur[2] = {60,100}; // 75 ms for MF tones, 120 for KP/ST int ss4Tone[2] = {2040,2400}; // tones for 0,1 respectively char keys[4][4] = { {'1','2','3','a'}, {'4','5','6','b'}, {'7','8','9','c'}, {'#','0','*','d'} }; byte rowPins[4] = {5,4,3,2}; //connect to the row pinouts of the keypad byte colPins[4] = {9,8,7,6}; //connect to the column pinouts of the keypad // global objects Tone freq[2]; // array of Tone objects, now we can play as freq[0].play(); etc Keypad keypad = Keypad(makeKeymap(keys),rowPins,colPins,4,4); boolean rec = 0; // recording on/off boolean stored = 0; // stored digits? boolean autoDial = 0; // are we playing stored ANY didgits? int mode = 0; // 0 for MF, 1 for intern, 2 for SS4, 3 for DP, 4 for DTMF int mf2 = 0; // MF2 mode // the storage of integers MUST be integers (int): int store[24] = {-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1}; // call set up function to set up pins: void setup(void) { // Start up instructions: freq[0].begin(11); // Initialize our first tone generator freq[1].begin(12); // Initialize our second tone generator keypad.setHoldTime(1500); // hold for two seconds to change state to HOLD pinMode(10, INPUT); // 2600 button pinMode(13, OUTPUT); // LED for recording keypad.addEventListener(procButton);