Hi guys,
Can you help with the following code?
I have a 8/8 button matrix connected to a button shield,
which is connected to an Arduino Mega.
I am trying to insert characters on a computer display.
It's my first code and I am a bit struggling.
Can you help?
Any suggestion would be useful.
Regards
// 8/8 keypad to print characters
// on computer display
#include <Keypad.h>
int R0=9;
int R1=8;
int R2=7;
int R3=6;
int R4=5;
int R5=4;
int R6=3;
int R7=2;
void setup();
{
pinMode(R0, INPUT);
pinMode(R1, INPUT);
pinMode(R2, INPUT);
pinMode(R3, INPUT);
pinMode(R4, INPUT);
pinMode(R5, INPUT);
pinMode(R6, INPUT);
pinMode(R7, INPUT);
}
const byte Rows = 8; // 8 rows
const byte Cols = 8; // 8 columns
char keys [Rows] [Cols] ={
{'a','b','c','d','e','f','g','h'},
{'i','j','k','l','m','n','o','p'},
{'q','r','s','t','u','v','w','x'},
{'y','z','A','B','C','D','E','F'},
{'G','H','I','J','K','L','M','N'},
{'O','P','Q','R','S','T','U','V'},
{'W','X','Y','Z','1','2','3','4'},
{'5','6','7','8','9','0','.',','},
};
byte rowPins [Rows] = {R0, R1, R2, R3, R4, R5, R6, R7};
// connect to row pinouts of the keypad
byte colPins [Cols] = {A0, A1, A2, A3, A4, A5, A6, A7};
// connect to column pinouts of keypad
Keypad keypad = Keypad( makeKeymap (keys), rowPins, colPins,
Rows, Cols };
void setup() {
Serial.begin (9600);
Keypad.begin();
}
void loop() {
char key = keypad.getKey();
if (key != No_Key){
Serial.println( key );
}
}