Author
Topic: [Solved]12 button keypad to Axon MC (Read 2992 times)

I'm trying to implement this keypad in to the Axon MC. I'm having so much trouble with this. Wherever i research it always gives me the assembly language code or cpp code.I need a .c code to work with this I also don't know which port to hook it up.Help would be appreciable.

Now after you have it generate your code (Tools -> Generate...), write some IF statements to have it figure out which button was pushed. The generated code will give you examples of how to see if an input was activated.

FYI - I did something similar to this on another micro controller (Basic Atom Pro) in Basic for the DIY Remote control up on Lynxmotion.

Like the pic tutorial, we hooked up pull-up resistors to the 4 rows. With this setup there was some concern that if multiple buttons were pressed, that we could cause some connections between IO pins that were pulled high and others that re pulled low, which probably would not cause problems, but we decided to not take a chance as it was easy to change the code to avoid it.

What I did was convert the code that instead of setting a column high I would simply set the IO line to input and let it float, which if connected would be a 1 from the pull-up resistor. Hope that makes sense.

This is perfect. I've been wanting to attempt the 16-button version, but was a little unsure how to go about doing a couple of things. I think this thread contains exactly what I needed to know. Hooray and stuff. I'll let you know how it goes.

However, I have come across conflicting information that I would like clarification on. When plugging the keypad into the Axon II which row do I plug the pins into? The Project Designer blinks the ground and signal rows, while some other places indicate I should plug into the voltage row. I'm confused. Please help. Thanks!

Doesn't look right to me. Reading the docs then the column pins should be set as inputs (with pullup resistors). The row pins should all be output pins and default to high.Then:Make all column pins into input with pullups enabledMake all row pins into outputs and set them highFor each row Make this rows output pin low For each column Read the input pin for this column If its low then the button at this row and column has been pressed Next Column Make this rows output pin high againNext Row

There were a couple of more things to it in my case, but I would like to thank Webbot for his help. Everything seems to work like a charm now. I was just terribly confused by what pins started high, low, up, down, and so on.

IF you want to send me your code then I can try to build it into WebbotLib so others can benefit - you will of course get a credit in the source code comments.Note that I tend to have to re-engineer most submitted code a bit since WebbotLib would allow you to add 'many' such devices. Since I don't have the keypad then I may need to ask you to run/test my code.If you are interested then send me a personal message - if not then I understand.

As I mentioned earlier, did the same thing for DIY remote control now with XBEE on a different processor. When I first coded it up, I was concerned with the logic described that if the user pressed multiple buttons, it could direct two IO lines to each other where one is high and the other is low. Was concerned that the dead-short might be detrimental to the processor and changed the logic... With the Pull-up resistors installed instead of pulling the IO pins high, I instead let the pull-ups do this and turned those IO pins into inputs instead. So the logic became:

Reading the docs then the column pins should be set as inputs (with pull up resistors). The row pins should all be output pins and default to high.Then:Make all column pins into input with pull ups enabledMake all row pins into inputsFor each row Make this rows an output and set it low For each column Read the input pin for this column If its low then the button at this row and column has been pressed Next Column Make this rows pin input againNext Row

As I mentioned it may not be a major problem, but I was being caustious...

I really don't think it would be a major problem; but if you want to be cautious, that's okay. With that said, I went ahead and added code that breaks out of all loops if a button is pushed (i.e.: once a pressed button is discovered, don't scan any further).

I *FINALLY* got the keypads and some other stuff that I had ordered...six days after they were supposed to arrive. Regardless, I have soldered on some pins and have wired the thing up. Of course, I am at work right now and cannot tell you whether this part of the project was a success or failure. I guess I'll just have to keep you waiting...which reminds me:

Tony is too busy pushing buttons on his keypad and expressing excitement as a result to post right now due to the fact that he finally got his 16-button keypads in the mail AND it got them soldiered corrected on the first try (something he is not the greatest at) AND got it wired up correctly AND the fact the thing actually works.