Hi All
For my understanding with the keypad library i have build up e simple 2 x 2 Button Matrix.
2 Rows, 2 Cols
"1" "2"
"3" "4"
Of course i read a lot about the coding of this.
Board is Arduino Leanardo
But for now when i press the first Button i get the first:"1"
when i hit the second i also see "1" in the Serial Mon.
I Press 3 ond get 4
i press 4 ond i get also 4.
now the code which i modyfied from a Example Code
Thanks a lot for help
////
#include <Keypad.h> //Bibliothek zum auslesen der Matrix Tastatur
//Definieren der Zeilen und Spalten.
//Wenn eine größere Tastatur verwendet wird,
//muss das hierdefiniert werden.
const byte COLS = 2;
const byte ROWS = 2;
//Definieren der Pins, über welche die Matrix Tastatur
//mit dem Microcontroller verbunden wurde.
const byte COL_PINS[COLS] = { 10, 11};
const byte ROW_PINS[ROWS] = { 8, 9};
//Da der Datentyp char nur ein Zeichen aufnehmen kann,
//verwende ich ab der Zahl 10 die Buchstaben A bis G.
const char KEYS[ROWS][COLS]={
{'1','2'},
{'3','4'},
};
//Initialisieren des KeyPad Objektes
Keypad myKeypad = Keypad(makeKeymap(KEYS), ROW_PINS, COL_PINS, ROWS, COLS);
void setup() {
//Begin der seriellen Kommunikation mit 9600 baud.
Serial.begin(9600);
}
void loop() {
//lesen ob eine Taste gedrückt wurde
char key = myKeypad.getKey();
//Wenn eine Taste gedrückt wurde,
//dann den Wert auf der seriellen Konsole
//Ausgeben.
if (key) {
Serial.print("Die Taste ");
Serial.print(key);
Serial.println(" wurde gedrueckt");
}
}