matrix of pins to increase inputs

Status
Not open for further replies.

deelaleo

Well-known member
Hi,

I am working on my controller with Teensy 3.1, and I am using a matrix to add more inputs than the available digital IO available.

Code:
        2 - 3 - 4 - 5 - 6
    ------------------------    
    7   X
    ------------------------
    8   X
    ------------------------
    9
    ------------------------
    10              
    ------------------------
    11              
    ------------------------
    14
    ------------------------
    15
    ------------------------
    16
    ------------------------

My first switch is connected to pin 2 and 7 on one pin of the switch and the second pin is connected to ground. The second switch is connected to pin 2 and 8 to one pin of the switch; while the other pin goes to ground.
The peculiar thing is that when I turn on either of the switches; they both go on. I did add a couple of LED; and in my code I did set the first LED to go on when the first switch is enabled, and the second LED to go on when the second switch is enabled. They both turn on at the same time.

Why do I get this behavior? I am trying to connect 40 buttons and switches to the Teensy and use it for flight sim. Any help would be really appreciated. Thanks!
 
Show us your wiring diagram and a photo of your actual wiring. Without complete information about what you tried, we'll waste time guessing and asking questions.
 
This is how we work here:
Capture d’écran 2017-12-21 à 10.10.55.png
 
Sorry, I am aware of how it works here; I just didn't post the wiring since I thought that the matrix above was clear enough.

I did try with the keypad library, and it does work like a charm! Thanks @KurtE for the suggestion!
 
i'm probably misunderstanding what you note along with the diagram but the fact that both switches activate is not surprising to me at all because you have given all switches a common power lead as well as ground. like i said, i'm probably not understanding the setup but the culprit is 2 being on 1 pin of all the switches and ground the other.
 
Status
Not open for further replies.
Back
Top