Take the 2-minute tour ×
Raspberry Pi Stack Exchange is a question and answer site for users and developers of hardware and software for Raspberry Pi. It's 100% free, no registration required.

I have a naive keyboard matrix (no diodes, so only 2 simultaneous key presses can detected, at most).

I would like to read this matrix by connecting the columns to GPIO pins configured as outputs and the rows to GPIO pins configured as inputs.

By driving the column pins, one at a time, it should be possible to test which keys are pressed by reading the GPIO input pins.

(I will run a polling daemon, written in C, to read the matrix, and squirt data into the kernel using the uinput kernel driver.)

Will I fry the RPi by connecting GPIO-outs to GPIO-ins?

(If GPIO inputs act as near infinite resistances, then there will be no problem - but I don't know this.)

share|improve this question
add comment

2 Answers

up vote 1 down vote accepted

No, you won't fry the GPIO pins. The RasPi doesn't really care where the signal's coming from or going to as long as it conforms to the 3.3v logic level on the inputs, and doesn't draw more than 8ma from the outputs. See this for a more complete discussion of pinouts and restrictions. Note that two of the GPIO pins are intended for I2C and have 1.8K pullup resistors attached.

Your key scanning scheme should work- it's often implemented on numeric keypads- as long as you have enough I/O ports for the job. You might want to investigate a keyboard encoder chip to make things simpler. Many of them include debouncing and 2 key rollover protection.

share|improve this answer
add comment

There is the risk of accidentally getting both pins configured as output at some point. Maybe you could add some series protection resistors to the input lines (and perhaps output)? That would give some extra safety and should be dimensionable so there will be no voltage lost from "low" impedance outputs to high impedance inputs. There should be no problem with edge speed on keypads :)

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.