FEZ Panda II with Matrix Keypad
After a few days of attempting to get this to work I thought I would save some time for anyone else attempting this particular activity.
I am using the JM09K keypad that I bought quite a while ago.
I am also using the FEZ Panda II
A link to the source code is at the bottom of this article
Where to start?
I was looking at a lot of different projects and it seemed that some people were using external pull-up resistors. But I was sure I wouldn’t need any of those! I saw that Arduino and Raspberry Pi projects had just stuck a header on the keypad and stuck it right in to the dev board. Turns out that it works a treat!
So I looked at the Arduino Keypad library and found that you needed to change the column pins from output to input. At first I thought that I would not be able to do that, but it turns out that the Port class implements IDisposable! So we can just wrap the Port declarations inside a using statement which will dispose of the pin reservation after we have finished using it.
The Keypad class
Influenced by the Arduino Keypad libraries use of a Keymap I decided that I would try and mimic some of its behaviour.
We use the HoldTime
to allow for a delay between key scans.
Now lets have a look at the method we use for getting the keys (I am sure I could refactor it to look a bit nicer though!).
Simple enough, right!
Now lets use it in our main program!
The source code for this article is available here
You need to have the .NET Micro Framework 4.1 installed so you can get access to the FEZPanda_II_GHIElectronics.NETMF.FEZ library.