Go Down

Topic: Keypad.h (Read 3 times) previous topic - next topic

trendski


Hi,
I'm using a keypad these with the Keypad.h library and, yes it works fine. But I don't understand how the arduino is handling the input from it. I get that when a key is pressed a connection is made between a row and a column pin, which when read by arduino gives us a particular key as a result.

When I attached my ohm meter to various pins on the keypad I was basically measuring a drop in resistance (probably Megohms down to a few ohms) when a connection was made and the matrix from these tests gave me the data for the library to use. I understand that to calculate ohms (R) you can use V and I.
Does anyone know how the arduiono is handling these inputs?

I already tried looking at the keypad.h file and didn't get any further either.

Cheers
Craig Turner, blog: http://gampageek.blogspot.co.uk/ It helps with my learning if I write things down, esp. for others to follow (constructive comments welcomed to improve)

robtillaart

Can you post a link to your keypad.h library?

There should also be one or more .cpp files.

The working is as follows:

the rows are outputs
the columns are input
The Arduino sets row 1 high.
then it checks all the columns if a line is becoming high if so key found
if none it does the same for row 2,3,4
If no line is found high return KeyNone or something like that.

(rows & columns can be swapped)


Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

trendski

Here's the link:

arduino.cc/playground/uploads/Code/keypad.zip

robtillaart many thanks for the explanation, I think I understand it now.

Although the C files make heavy reading, I can see that they appear to be pulsing and checking row and column pins.

Cheers
Craig Turner, blog: http://gampageek.blogspot.co.uk/ It helps with my learning if I write things down, esp. for others to follow (constructive comments welcomed to improve)

robtillaart

you should read the scankeys() function, that's the workhorse in this lib.

the implementation is more robust and has some additional functionality, e.g. it also suppresses bouncing switches so you get only one key instead of a zillion ;)
Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

trendski

Many thanks again. I'll check it out.

I believe it's a good idea for me understand the stuff I'm using in more depth, now.

I've been using arduino for just over 12 months now.  It's a bit off post, but I just bought this book http://www.amazon.co.uk/Introduction-Embedded-Systems-Development-Environment/dp/1608454983/ref=sr_1_9?s=books&ie=UTF8&qid=1352488796&sr=1-9 to help speed the path to better understanding  :)

Cheers
Craig Turner, blog: http://gampageek.blogspot.co.uk/ It helps with my learning if I write things down, esp. for others to follow (constructive comments welcomed to improve)

robtillaart

at first sight a very interesting book!
I put it on my wishlist
Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Go Up