Pages: [1]   Go Down
Author Topic: LED matrix and button matrix on same pins?  (Read 534 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Full Member
***
Karma: 0
Posts: 142
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Offline Offline
Edison Member
*
Karma: 34
Posts: 1318
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
« Last Edit: June 11, 2012, 06:56:54 pm by DVDdoug » Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 22
Arduino neewbie
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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. 
But I'm with DVDdoug on this one, its gonna get complicated...fast!  smiley
Logged


0
Offline Offline
Full Member
***
Karma: 0
Posts: 142
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

yeah cheers guys. silly idea...
Logged

Pages: [1]   Go Up
Jump to: