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

Thread: Teensy 3.2 + WIZ820io & Micro SD + 4 position DIP switch

  1. #1
    Junior Member
    Join Date
    Dec 2016
    Posts
    9

    Teensy 3.2 + WIZ820io & Micro SD + 4 position DIP switch

    I want to add a 4-position DIP switch to a Teensy w/ an SD Card. I have a Teensy 3.2 and the WIZ820io & Micro SD adaptor.
    I have not added the WIZ820io to the board.

    I was wondering how I could connect the DIP switch to this setup?

    My goal is to have 16-different choices corresponding to different files on the SD card.

  2. #2
    Senior Member Theremingenieur's Avatar
    Join Date
    Feb 2014
    Location
    Colmar, France
    Posts
    624
    Connect the Dip switches to 4 digital pins of the Teensy and ground. In your code, configure these 4 pins as input with pull-up and attach a single ISR to these which in case of a state change reads all 4 pins and writes the reconstituted number from 0 to 15 to a global volatile int variable. The latter might then checked for change in the loop() and a corresponding action be taken.

  3. #3
    Member
    Join Date
    Oct 2016
    Location
    Colchester, Essex, UK
    Posts
    44
    That's definitely the obvious and easiest solution.

    If you're short of pins, you could use a resistive ladder into one analog input. Requires a few external resistors though. With a restive ladder, you can comfortably go up to about 9 to 10 switches, still using only one pin on the micro.

  4. #4
    Junior Member
    Join Date
    Dec 2016
    Posts
    9
    Quote Originally Posted by Theremingenieur View Post
    Connect the Dip switches to 4 digital pins of the Teensy and ground.
    Looking at the reference page https://www.pjrc.com/store/wiz820_sd_adaptor.html, I shouldn't use any pin that the SD card uses, and to allow for the future addition of the Ethernet interface, I should also avoid the pins the WIZ820io uses. That means I shouldn't use 4,8,9,10,11,12 and 13, right?

    I could theoretically add a second 4-position DIP switch if I get crazy.

    Given that, I'm trying to determine the most convenient set of pins to use, how to fasten them to the Teensy. I have some perfboard I can use.

    So pins 13,14,15,16 and perhaps 17,18,19,20 are a good choice?
    So I could socket the Teensy board and use extra long header pins and fasten the switches on the underside.
    Or perhaps try to fasten them above the adapter board somehow?

  5. #5
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    13,227
    Quote Originally Posted by grymoire View Post
    That means I shouldn't use 4,8,9,10,11,12 and 13, right?
    Pin 8 is safe, unless you've modified the board to connect it to the WIZ820io powerdown pin.

    Yes, avoid using 4,9,10,11,12,13, because they're used by the SD card and/or WIZ820io.

  6. #6
    Junior Member
    Join Date
    Dec 2016
    Posts
    9
    Quote Originally Posted by PaulStoffregen View Post
    Pin 8 is safe, unless you've modified the board to connect it to the WIZ820io powerdown pin.

    Yes, avoid using 4,9,10,11,12,13, because they're used by the SD card and/or WIZ820io.
    I wrote up a blog post on how I addressed my problem.

Posting Permissions

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