How to connect physical pushbuttons to a computer for use in a soundboard program?

I plan to do a project that will use 28 arcade style pushbuttons to activate 28 different sounds on a computer.
Any ideas on products out there I can use to connect all 28 buttons to a computer, preferably with a USB cable, so it can be used in a programming language such as C++?
One idea I had was to take apart a QWERTY keyboard, but I still want to be able to use my regular keyboard to use my computer.
Alternatively, is there a way for two keyboards to be connected to same computer, but one of them only activates a specific program? i.e. trying to type in notepad with it wouldn't work?

G4224T3 years ago

Any simple microcontroller type board out there would do the trick. An Arduino Uno should do and is low cost.

Arrange your switches in a matrix pattern of say 4 columns by 7 rows (requiring 11 I/O lines).

The arduino code is simple to write and is similar to C. The code would cycle through each column as an output and read each row as an input. This would give the exact button pressed.

The arduino can then write the button number out of its USB serial port. Your C++ program would then only have to read the serial port to retrieve the button pressed.

Swordmasterb (author)  G4224T3 years ago

Thank you for the advice, but I have since bought an Arduino Mega2560.

I have also tested some things, and made a post on the Arduino forums here.

I read your post in the Arduino forum. The guys there are right, although a bit unhelpful.

Try setting an array up to hold your 20 input pin numbers and a second empty array to hold their values. Then use a FOR loop to read the inputs of the pins from the first array and store the values in the second array.

Once you have looped through all the inputs, send the array of values in a single SERIAL.WRITE instruction to the serial port.

Your C# program can then just read the 20 bytes of data and will know the value of each push button with a single serial transmission.