Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 6 of 6

Thread: matrix of pins to increase inputs

  1. #1

    matrix of pins to increase inputs

    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!

  2. #2
    Senior Member pictographer's Avatar
    Join Date
    May 2013
    Location
    San Jose, CA
    Posts
    637
    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.

  3. #3
    Senior Member+ Theremingenieur's Avatar
    Join Date
    Feb 2014
    Location
    Colmar, France
    Posts
    2,069
    This is how we work here:
    Click image for larger version. 

Name:	Capture d’écran 2017-12-21 à 10.10.55.png 
Views:	16 
Size:	18.6 KB 
ID:	12345

  4. #4
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    Posts
    3,704
    As the others mentioned, at this point we would only be guessing as we don't see the wiring or the code.

    But have you looked at using the Keypad library? It is installed with Teensyduino and has several examples and some information up at: https://www.pjrc.com/teensy/td_libs_Keypad.html

  5. #5
    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!

  6. #6
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •