Is this a silly question? It seems like it might be possible?So I am making a simple game where the arudino lights up certain leds, then you have to press the buttons that the corresponding leds lit up on - like a memory game that gets harder and harder. It can also get you to press two at once...The button matrix is working great (thanks to help here), and I am assuming I can make an led matrix in exactly the same way, but when it reads a pins state, that would set that led high.Anyway what my question is:I am using diodes on each button of the matrix to stop ghosting. So if I also put the led matrix onto the same pins, but in the opposite direction would it be possible to se the same pins for the led matrix in some sort of way? It kinds of seems a bit surreal - but so surreal it might be possible that the two wouldnt conflict because of the diodes on the buttons and the fact that led's are diodes.

So if I have four buttons, and four leds, lets say led 1 and 2 came on, the user needs to press button's one and two. But I wouldnt necessarily want a) the led's turning off when the user did that or b) the led's coming on when the user pressed the buttons...Long answer? Short answer?Cheers guys

I' gonna say NO. It might be possible, but probably not practical... Maybe it could be done with some kind of additional hardware that switches between the buttons & the LEDs, so that at any moment either the buttons or the LEDs are connected/working.

An I/O pin has to be configured as an output OR an input. Your sketch can change the function at any time while it's running, but it cannot be an input and an output at the same time.

As a general rule, you don't want to connect outputs together... And a switch is an "output" (it goes to an input). For example, very-bad things can happen if your switch tries to force a signal high, while an Arduino output is trying to force the same signal/pin low at the same time. And, it needs to have the right kind of physical/functional connection. (i.e. A switch goes to an input, and an LED connects to an output... Or, you receive on an input and transmit from an output, etc.)

You can "OR" outputs together with a pull-up (or pull-down) resistor, so you could "or" an output pin together with a switch. But, somehow I don't think this will work with a matrix connection. And, it would probably turn-out that logically or-ing the signals together does the wrong thing logically/functionally.

I imagine (in my head it seems doable anyway) you probably could solve this by using some kind of "bus structure" combined with 3-state latches/buffers and some other logic preventing you from enabeling different latches at the same time.

I' gonna say NO. It might be possible, but probably not practical... Maybe it could be done with some kind of additional hardware that switches between the buttons & the LEDs, so that at any moment either the buttons or the LEDs are connected/working.