Snippet - Keypad 3x4 Gadgeteer driver

Keypad 3x4 Gadgeteer driver

A little driver for the 3x4 keypad sold by GHI that works on a Gadgeteer board.

It has KeyPressed/KeyReleased events and you can choose the socket on which it will connect. Events return the key value (from 1 to 12) and the associated char (from ‘0’ to ‘9’, ‘*’ and ‘#’).

Please note that the keypad is not a Gadgeteer module, so there’s no Drag&Drop in Visual Studio. Also, there’s only a small part of the driver that is related to Gadgeteer, so it’s easy to modify it for non-Gadgeteer boards : you only have to change the pin assignments.

Tested on Cerbuino Bee with 4.2 SDK.

1 Like

@ Bec a Fuel - nice one, was just about to get one for a project so will make life easier :slight_smile:

@ Bec a Fuel - Very nice. Looks to be a significant improvement over the code at:

So much so, I was tempted to point the tutorial to your driver snippet, particularly since the code in the tutorial uses a while(true) loop inside ProgramStarted, which is a big Gadgeteer no-no. :slight_smile:

Might just have to pick me up a keypad now…

Somebody has been asking about it very recently.

Edit. Found it and pointed to this thread.

What’s the part number for the gadgeteer interface? is it an extender module, if so what is pin asignment to the keypad?

All the details are in the Wiki page and the code.

@ Justin and @ Devhammer : thank you :wink:

Here are some more details :
[ul]the keypad has to be connected to a Y socket, because of the 7 lines
on the Hydra, since Port.ResistorMode.PullDown gives an exception, I’m using Port.ResistorMode.Disabled. But in this case, I have to put some resistors or else the keypressed/keyreleased events are continuously firing… See attached picture for an example.[/ul]

@ Dr9 : the extender module is useful here to “transform” Gadgeteer sockets into something that is “breadboard compatible”. Using the extender, you can then connect almost anything to a Gadgeteer board !

@ Bec a Fuel - I think you were not sure about gadgeteer and liked the arduino style better at some point. What do you think now after you have tried gadgeteer?
What can we do to improve?

I was waiting for this one :wink: I’m still “not sure”…

In fact, I wanted to show a driver for the Panda II, first. Mainly because this driver is only a part of a “bigger project” that should originally use the Panda II.
But since you were so kind to produce a Gadgeteer board in an Arduino form, which almost gives the better of the two worlds, I’ve thought I should do something for the Cerbuino :wink:
And at the end, the actual bigger project may well switch to Cerbuino, if I don’t need too much I/O’s (even though I can still use the IO60P16 module, in this case).

For me, not much : maybe 2 or 3 more Gadgeteer sockets on a Cerbuino equivalent board, that would be all I may ask.
The fact is that I’m still a bit reluctant with the Gadgeteer socket concept : I think that we’re wasting too much pins when we connect a module on a socket. So, you can’t really do more since you’re stuck by the design.

But don’t worry, the Cerbuino is powerful enough for all my actual needs. And because of its Arduino style, I think it may replace the Panda II in my heart sooner or later. :slight_smile:

Oh yes, I see an improvement : please change the pin assignments on the IO60P16 to be hardware I2C compatible :wink: (just teasing, don’t worry)

The only reason for software i2c was to save the i2c but for things that needs high speeds, like a gyro and accelerometer on a quadcopter :wink:

You have your reasons, that I accept, even though I may not agree :wink:

Coming back to this driver, version 2 is now working on all Hydra Y sockets (with real pulldown resistors) but doesn’t work on Cerbuino sockets 1 & 2 :frowning: Only socket 3 is valid !?
I still don’t understand why, though, so I will have to investigate…

Hi everyone,

Just to put this topic up, I just received a 3x4 keypad (seems the one sold by GHI but I bought it somewhere else), and try to use it with my cerberus.

I got some strange behaviour, depending on wich socket I put my extender (yes, i’m serious).

I use the code from the Wiki, mine, and the one provided by Bec a fuel, but always the same result.
I always got a key pressed down. Sometimes is the key 1, and sometimes the key 2. Depending on wich socket I place the extender…

It’s totally strange, and I don’t understand what I’m doing wrong.

Do I need to initialize the extender in some way ??

Thanks for your time.

Try adding delays in your button scan

@ Exasperant - Are you 100% sure your keyboard is identical to the one sold by GHH?

@ Gus Actually I’ve a Thread.Sleep(250) between each iteration.

@ Mike This is the big question. I don’t know, I pretend it is because it looks like a lot the one GHI sells
I bought it from the french web site “Generation Robots” (http://www.generationrobots.com). They sell it as a “Gagdeteer keypad”, so i assumed it’s the one from GHI…

Reading the last post of Bec A Fuel, are there any things to do when using it with a Cerberus ?

@ Bec a Fuel

Thank you for posting the code for the keypad.
I’m having an issue. I was issued a FEZ Hydra and of course the resister mode is disabled. Is there a code solution around this issue with the resistor ports disabled?

Thank you

EDIT: We are also using the Breakout module to connect the pad to the board.

if you are using a breakout module, put some resistors on it?