Following on from an earlier question where the implementation was flawed, can anyone advise if the below is a viable implementation of a circuit to handle a matrix keypad?

The idea is that one keypad column and one GPIO pin (1, 2 or 3) will be 'active' at any one time. This will sequentially flick between the 3 column/pin combinations. The optocoupler will turn on when a keypad button is pressed which will 'activate' (i.e. trigger a change) in GPIO 4.

There would be an optocoupler for each row - I have only included 1 on the diagram to keep it condensed. "in" is the LED anode/cathode and "out" is the photo transistor collector and emitter.

It's a learning exercise on the 555 and 4017, more than anything so any other pointers would be much appreciated.

enter image description here

  • \$\begingroup\$ I'm confused by these "0" and "1", you only say they are GPIO but are they inputs or outputs and what is the meaning of three "0". If there are four GPIO involved then why not call them gpio1, gpio2, gpio3, gpio4 and just tell us how they are configured. Also what is an "active" GPIO? \$\endgroup\$ – alexan_e Jan 9 '14 at 20:04
  • \$\begingroup\$ I see where you're coming from - it is a little confusing. The "0" and "1" pins are all individual GPIO pins configured as input. \$\endgroup\$ – phil-lavin Jan 9 '14 at 20:08
  • \$\begingroup\$ And why are there three "0" and one "1" and not two of each? \$\endgroup\$ – alexan_e Jan 9 '14 at 20:17
  • 1
    \$\begingroup\$ I've amended the diagram to hopefully clear it up \$\endgroup\$ – phil-lavin Jan 9 '14 at 20:24
  • \$\begingroup\$ what software did you use for drawing the schematic? \$\endgroup\$ – Roger Jan 9 '14 at 21:45

Q3 is wrong - it should go to reset if i read the circuit correctly

And, why bother with the transistors - It's likely that with a series resistor alone you won't (or needn't) exceed Imax into or out of the 3V3 powered sysyem. Use one resistor to feed the column (which acts as current limit for the opto) and another resistor (such as 10k) to feed the 3V3 IO lines.

There's also a work around to get rid of the opto couplers too.

  • \$\begingroup\$ Thanks Andy. Are you saying that Q3 should be directly connected to Reset? If so, is a resistor needed? \$\endgroup\$ – phil-lavin Jan 9 '14 at 20:10
  • \$\begingroup\$ What's the workaround for the opto? \$\endgroup\$ – phil-lavin Jan 9 '14 at 20:10
  • \$\begingroup\$ @phil-lavin Q3 was connected to ground and I presume you required it to connect to reset so that the 4017 would halt at Q3 and then immediately restart on Q0 - I haven't checked this logically. If the opto was removed and R1 connected to GPIO4 via a 10k resistor this would be fine. You'll need a pull down from R1 to 0V, possibly another 10k ohm. \$\endgroup\$ – Andy aka Jan 9 '14 at 21:31
  • \$\begingroup\$ @phil-lavin I'm also presuming you know that GPIO1-3 could be outputs directly feeding the keypad making the 4017 and the 555 redundant. \$\endgroup\$ – Andy aka Jan 9 '14 at 21:33
  • \$\begingroup\$ I do, yes. The project started out of wanting to try a purely interrupt based system. \$\endgroup\$ – phil-lavin Jan 9 '14 at 22:09

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