Hello,
I'am not so good in programming and want to connect a Bulls Matrix with 8x12. What characters are allowed for the var char? Only 8bit ASCII? Then I have a problem with the number of possible characters...
Thank you for answer.
Mike
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello,
now I'am on sourceforge ;). After I spend a bit of time I will response myself to help some others.
To define the keymap I used the decimal value, this is much easier when you haven't the right keys on keyboard.
const byte numRows = 9;
const byte numCols = 12;
const int debounceTime = 100;
char keymap[numRows][numCols] = {
{33,34,35,36,37,38,39,40,41,42,43,44},
{45,46,47,48,49,50,51,52,53,54,55,56},
{57,58,59,60,61,62,63,64,65,66,67,68},
{69,70,71,72,73,74,75,76,77,78,79,80},
{81,82,83,84,85,86,87,88,89,90,91,92},
{93,94,95,96,97,98,99,100,101,102,103,104},
{105,106,107,108,109,110,111,112,113,114,115,116},
{117,118,119,120,121,122,123,124,125,126,128,129},
{130,131,132,133,134,135,136,137,138,139,140,141}
};
byte rowPins[numRows] = {A0, A1, A2, A3, A4, A5, A6, A7, A8}; //connect to the row pinouts of the keypad
byte colPins[numCols] = {22, 24, 26, 28, 30, 32, 34, 36, 23, 25, 27, 29};
void setup()
{
Serial.begin(9600);
for (int row = 0; row < numRows; row++)
{
pinMode(rowPins[row],INPUT); // Set row pins as input
digitalWrite(rowPins[row],HIGH); // turn on Pull-ups
}
for (int column = 0; column < numCols; column++)
{
pinMode(colPins[column],OUTPUT); // Set column pins as outputs
// for writing
digitalWrite(colPins[column],HIGH); // Make all columns inactive
}
}
void loop()
{
char key = getKey();
if( key != 0) { // if the character is not 0 then
// it's a valid key press
/*Serial.print("Got key ");*/
Serial.print(key);
}
}
char getKey()
{
char key = 0;
for(int column = 0; column < numCols; column++)
{
digitalWrite(colPins[column],LOW); // Activate the current column.
for(int row = 0; row < numRows; row++) // Scan all rows for
// a key press.
{
if(digitalRead(rowPins[row]) == LOW) // Is a key pressed?
{
delay(debounceTime); // debounce
while(digitalRead(rowPins[row]) == LOW)
; // wait for key to be released
key = keymap[row][column]; // Remember which key
// was pressed.
}
}
digitalWrite(colPins[column],HIGH); // De-activate the current column.
}
return key; // returns the key pressed or 0 if none
}
The ninth Row is for future use of Buttons.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Make use of decimal values rocks and had never been done before !
Cheers :)
On 13/03/2019 16:25, Mike Nagel wrote:
Hello,
now I'am on sourceforge ;). After I spend a bit of time I will response myself to help some others.
To define the keymap I used the decimal value, this is much easier when you haven't the right keys on keyboard.
~~~
const byte numRows = 9;
const byte numCols = 12;
const int debounceTime = 100;
byte rowPins[numRows] = {A0, A1, A2, A3, A4, A5, A6, A7, A8}; //connect to the row pinouts of the keypad
byte colPins[numCols] = {22, 24, 26, 28, 30, 32, 34, 36, 23, 25, 27, 29};
void setup()
{
Serial.begin(9600);
for (int row = 0; row < numRows; row++)
{
pinMode(rowPins[row],INPUT); // Set row pins as input
digitalWrite(rowPins[row],HIGH); // turn on Pull-ups
}
for (int column = 0; column < numCols; column++)
{
pinMode(colPins[column],OUTPUT); // Set column pins as outputs
// for writing
digitalWrite(colPins[column],HIGH); // Make all columns inactive
}
}
void loop()
{
char key = getKey();
if( key != 0) { // if the character is not 0 then
// it's a valid key press
/Serial.print("Got key ");/
Serial.print(key);
}
}
char getKey()
{
char key = 0;
for(int column = 0; column < numCols; column++)
{
digitalWrite(colPins[column],LOW); // Activate the current column.
for(int row = 0; row < numRows; row++) // Scan all rows for
// a key press.
{
if(digitalRead(rowPins[row]) == LOW) // Is a key pressed?
{
delay(debounceTime); // debounce
while(digitalRead(rowPins[row]) == LOW)
; // wait for key to be released
key = keymap[row][column]; // Remember which key
// was pressed.
}
}
digitalWrite(colPins[column],HIGH); // De-activate the current column.
}
return key; // returns the key pressed or 0 if none
}
Hello,
I'am not so good in programming and want to connect a Bulls Matrix with 8x12. What characters are allowed for the var char? Only 8bit ASCII? Then I have a problem with the number of possible characters...
Thank you for answer.
Mike
Hello,
now I'am on sourceforge ;). After I spend a bit of time I will response myself to help some others.
To define the keymap I used the decimal value, this is much easier when you haven't the right keys on keyboard.
The ninth Row is for future use of Buttons.
Great Job Mike :)
Make use of decimal values rocks and had never been done before !
Cheers :)
On 13/03/2019 16:25, Mike Nagel wrote:
hi,
what is your arduino board?
hi,
Mega 2560 R3
https://www.banggood.com/Mega-2560-R3-ATmega2560-16AU-Control-Board-Without-USB-Cable-For-Arduino-p-1044805.html?utm_design=41&utm_source=emarsys&utm_medium=Shipoutinform171129&utm_campaign=trigger-emarsys&utm_content=Winna&sc_src=email_2671705&sc_eh=2dad5650a047ff501&sc_llid=10696476&sc_lid=104858042&sc_uid=IadAavHT7X