using Keypad library for a full QWERTY keyboard

option8:
i'll be glad to help debug, if i'm able.

Works for me. I can talk you through any debugging that we'll need to do. It's simple stuff as you'll see.

mstanley,

I have not read through your recent library code so I will just ask you: are you waiting for debounce time in the library call getKey()? Two calls to getKey() should take little time if you just sense the input without waiting debounce time.

Hi liudr,

I've been looking at some of your phi code. Nice work.

With version 2.0 of the keypad library there is no debouncing during the keyscan. The debounceTime is only used inside the state-machine and runs only after the keyscan is done.

Here's the heart of the keyscan code:

for( int c=0; c<size.columns; c++) {
	digitalWrite(columnPins[c], LOW);
	for( int r=0; r<size.rows; r++) {
		curKey = digitalRead(rowPins[r]);
		allKeys += curKey;
		if(curKey==0)
			currentKey = keymap[c+(r*size.columns)];
	}
	digitalWrite(columnPins[c], HIGH);
}

The variable allKeys provides a status to the state-machine.

Oops, almost forgot to answer your implied question. I'm not sure what's happening but I suspect that one of the static variables may be getting shared between the two instances of keypad. I will have to hook up a second keypad and see if I can pin down the problem.

I see. I've ordered 2 4*4 keypads and will try them on one arduino with two keypad objects with my keypad library.

Here is my most recent activity regarding library:

http://arduino.cc/forum/index.php/topic,85557.0/topicseen.html

liudr:
I see. I've ordered 2 4*4 keypads and will try them on one arduino with two keypad objects with my keypad library.

Cool. I would appreciate any feedback. I have a feeling that it may take a little while to pin down the problem.

Right now I'm working on a solution so option8 can use multiple keypresses without having to load two instances of keypad.

option8,

I tried to PM you but the system is down. Hopefully you'll see this post then.

I've made some progress on reading multiple keypresses. There are a couple of things you will need to pay attention to but right now it will read up to 10 simultaneous key presses. Let me if you reply I will post the changes here.

Hi there,

I just raced trough the post, but perhaps my problem is related:
http://arduino.cc/forum/index.php/topic,91932.0.html
Let me know if following your examples would be the right path and where to continue this (in my new thread or here)

Thanks

mclien

if you've mapped all the matrix connections, and have enough pins on the teensy to handle all the necessary inputs, then you could probably take what we're talking about in this topic and run with it for your project.

send me your email in a PM and i'll send you a copy of my latest sketch. you'll need to get mstanley to send you the latest keypad library as well.

good luck! (and post pics/links when you have a chance)

I can't send anything right now until I get some homework done. I've heavily modified the library since I last sent it to you option8. Probably won't be until this weekend before I could do anything.

option8, would you mind sending him a copy of the library that I gave you?

option8:
if you've mapped all the matrix connections, and have enough pins on the teensy to handle all the necessary inputs, then you could probably take what we're talking about in this topic and run with it for your project.

I have mapped all the matrix connections. The teensy has enought pins, but I still don't know if I can mix the analog and digital pins for that or if all matrix connections have to be the same sort of input (analog or didgital). If they have to be "same kind" I have to look if the teensy ++ is a way to go. IIRC I need 24 pins altogether (6x14, maybe 6x18), have to look that up at home.

The matrix keypad library will let you assign any pin numbers you like but will not be able to use the analog pins in their analog state. I'm not sure about the teensy but there are quite a few posts that describe how to configure the analog-in pins for digital use.

Is that what you are talking about?

Yes exactly. I'm a newbe to that, so I didn't know if the analog pins are useless and I only can could the digital ones.

and I'm not a native english speaker so that add some difficulties in understanding the stuff (and ma lead to some questions that might sound silly and unnessessary)

mclien:
Yes exactly. I'm a newbe to that, so I didn't know if the analog pins are useless and I only can could the digital ones.

and I'm not a native english speaker so that add some difficulties in understanding the stuff (and ma lead to some questions that might sound silly and unnessessary)

To expand this topic on analog pin ideas, I think you can connect a few resistors to the row pins like that of the analogbuttons and use column pins to drive low and sense with analog inputs. What do you thing, mstanley? 4 digital pins and 1 analog pins for a 4*4 keypad? I'll whip out the code with my phi_interface library, which already contains analog keypads but of a different type.

To expand this topic on analog pin ideas

I think I would like to but maybe we should start another thread for that. It could be pretty scary for newbies. :slight_smile:

What do you thing, mstanley? 4 digital pins and 1 analog pins for a 4*4 keypad?

LoL... I thought of that, too. It sounds like a pretty fun challenge. But for shipping code it would probably just be best to have the library identify that the user is connected to the analog pins and have the library reconfigure them for digital when needed.

mstanley:

To expand this topic on analog pin ideas

I think I would like to but maybe we should start another thread for that. It could be pretty scary for newbies. :slight_smile:

What do you thing, mstanley? 4 digital pins and 1 analog pins for a 4*4 keypad?

LoL... I thought of that, too. It sounds like a pretty fun challenge. But for shipping code it would probably just be best to have the library identify that the user is connected to the analog pins and have the library reconfigure them for digital when needed.

Yep! Will do once I get it to work. All I have now is a "matrix keypad" with multiple analog inputs, each with a number of keys hooked to it. This hybrid keypad will be more useful since you can just buy a matrix keypad and not having to construct a special keypad to use analogButton lib. I have been aching over the ATMEGA328P lacking of I/O pins for a while. I was trying to make a phi-panel out of GLCDs. They take 13 pins so 5 left if I do serial panel. I guess I've just found my way to handle that with analog/digital hybrid keypad. Awesome! Finding solutions or learning stuff every day is great!

FYI, the matrix of the Palm portable Keyboard (US-Layout), which I plan to re-use with the teensy:

        "c1"    "c2"    "c3"    "c4"    "c5"    "c6"    "c7"    "c8"    "c9"    "c10"   "c11"   "c12"
"r1"    "4"                     "c"     "r"     "f"     "8"     "u"     "j"     "m"
"r2"    "5"                     "v"     "t"     "g"     "9"     "i"     "k"     ","
"r3"    "6"                     "b"     "y"     "h"     "0"     "o"     "l"     "."
"r4"    "7"                     "n"     "` ~"   "space" "space2"        "p"     ";"     "done"
"r5"    "1"     "Caps"  "Del"           "cmd"   "x"     "-"     "["     "„“"    "/ "            "Shft L"
"r6"    "2"     "tab"   "left"          "q"     "a"     "+"     "]"     "enter" "up"            "shf R"
"r7"    "3"     "ctrl"  "down"          "w"     "s"     "BckSpce"       "\"     "ToDo"  "Memo"  "Fn"
"r8"    "z"             "right"         "e"     "d"     "Date"  "Phone"                 "alt"

So what do you think liudr? 12 digital and 1 analog pin for that, or are 8 steps to narrow for an analog pin?
But I could also live with the use of a "full" matrix of 20 I/O pins (so I can still leave out the RX/TX pins and have 2 pins left to drive a LED, if I want to)
And don't be confused by some strange Labels: There are some extra keys on that keyboard that where designed for the use with a Palm device, but could be perfectly reused as extra/media/F keys.
Once the hardware is working its just a metter of assinging the keys and perhaps do some work with xmodmap (at least when using GNU/Linux).

EDIT:
I was just surfing hackaday:

(haven't read all links, but it was mentioned he used a teensy++2.0 and "existing libraries". maybe it's worth alook?)

mclien,

8 analog steps should work. Then you have 12 digital I/O + 1 analog input to sense the entire keypad. I will find some time to tackle this. Under my phi_interfaces framework it should be easy to add a device like this but I have the phi_prompt library to release first :wink:

The hackaday is worth checking. I browsed the site and didn't find a design file. There's around 90 keys and the keypad layout is known so the maker could have made a custom dimension. Your keypad has a fixed dimension of 8*12 and that is what you have to deal with. The hackaday code should be worth looking at. The hackaday keyboard must allow multiple key held together so it's much more complicated than what my library does, which is single key only.

Oh, the last point you mention is a issue to me.
Since I want to use the device as a "normal" USB keyboard I have to get it working with up to 3 keys pressed (ALT+SHIFT+L or something like that) or is that what option8 does by using the keypad library 2 times?

option8 tried using the keypad library 2 times to handle multiple key presses but I don't believe it solved his problem. I modified the library for him so that, with some restrictions, he can press up to 10 keys at the same time.

I saw that he offered to send you a copy of his sketch so I asked him to send you a copy of the modified library. If he can't do it then I can send you what you'll need. But it will have to wait until this weekend.

Yes I got a "keypad 2.0 multi-keys" zip-file
and a "IIc Keyboard.ino"
So, some newbie questions (for verification):
-the ino file is option8s keyboard layout, which I have to modify (rows/cols amount, my layout)

  • there are a lot of examples included (mainly for the numkeypad, if I understood it correctly) and a keypad.h and a keypad.cpp file.

So "all" I need is to modify the layout part of option8s ino file and include the keypad.h library?