Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Homeade keyboard, few questions.

Status
Not open for further replies.

dirtyb15

Member
Hi all, i need to arrange about 20 buttons on a custom panel for a project at work. They will be used as inputs to a piece of software that we have that currently uses keyboard inputs. I was thinking i would use a PIC to detect button presses, then emulate a standard pc keyboard. I have done most of nigels tutorials in the past, and think that i could just use the switch and rs232 routines, but since i need 20 buttons, i prolly need a different pic. Im sure this has been done already, and i will search when i get home, but thought i would ask for any input. I guess i dont really need 20 inputs if i use some sort of logic table?
Thoughts?
Thanks in advance!
 
You're right, no need for 20 inputs. If you look at the way keypads work it'll help you a great deal, basically you'll be looking at having a 5x4 matrix.
So if you have 5 vertical lines and 4 horizontal lines, what you would do is.
Set your first vertical line high, the rest low and then scan through the four horizontal lines to see if one is high, if not move on to the next vertical line and scan the horizontal lines again etc.
Once you detect a high horizontal line, you'll know which of the 20 keys is pressed.

Err, a key press would connect its horizontal line to its vertical line.
 
dirtyb15 said:
Hi all, i need to arrange about 20 buttons on a custom panel for a project at work. They will be used as inputs to a piece of software that we have that currently uses keyboard inputs. I was thinking i would use a PIC to detect button presses, then emulate a standard pc keyboard. I have done most of nigels tutorials in the past, and think that i could just use the switch and rs232 routines, but since i need 20 buttons, i prolly need a different pic. Im sure this has been done already, and i will search when i get home, but thought i would ask for any input. I guess i dont really need 20 inputs if i use some sort of logic table?
Thoughts?
Thanks in advance!

You need to check my keypad tutorial as well, that gives you 16 buttons using 8 pins (4x4), it could be easily increased to 20 buttons using 9 pins (5x4) as Norlin says. Currently it uses all 8 pins on one port (supporting the plugin nature of the tutorials), I would suggest having 5 on one port, and 4 on a separate port for ease of programming.
 
dirtyb15 said:
I was thinking i would use a PIC to detect button presses, then emulate a standard pc keyboard.

There are many examples on the NET so in general you would not be in great troubles.

However, most designs only cover the communication between PC and keyboard when the PC is fully powered up.

If your "emulated keyboard" is already connected to the PC PS/2 port before the PC powers up, as is most likely the case, the PC BIOS would check for the PS/2 keyboard upon first powered on. Make sure that you taken care of that part of code so that the PC is satisfied as if a "real" keyboard is connected.

More information is available here, at the bottom of the webpage: **broken link removed**
 
Splitting in 4 and 5

Nigel Goodwin said:
I would suggest having 5 on one port, and 4 on a separate port for ease of programming.

In one of my own projects, after several tries I found that splitting in 4 and 5 bits made everything MUCH easier.
 
If number of pins is not important I would use 8 by 3 so that I could read up to 24 switches directly into 3 bytes.

Lots of ways to do it.

Good luck. Mike
 
Sorry, but...

Nigel Goodwin said:
Doing it 8 (4 + 4) and 1 would be a real pain! :p

Can't grasp the joke this time. :eek: ??
 
atferrari said:
Can't grasp the joke this time. :eek: ??

Sorry, no joke - just that doing it 4x4 on one port, and adding an extra pin on a separate port for the 5th pin, would be a real pain - compared with 5 on one port, and 4 on another.
 
Status
Not open for further replies.

New Articles From Microcontroller Tips

Back
Top