22 Aug 2013 shimniok   » (Journeyer)

3-State Jumper

Up to 27 A2D adapters can live on the same I2C bus. The address is configured with 3 jumpers, each with 3 states: soldered high, soldered low, and unsoldered. Pull-down and pull-up resistors are the key to detecting all three states.


I use a 220k pull-down resistor on each of the pins. That's because the MCU I'm using has a 50k pull-up resistor. If the jumper is left disconnected, it is pulled down with the 220k resistor and appears logic low until  the 50k pull-up resistor is enabled creating a voltage divider that applies logic high to the pin.

Internal 50k pull-up used to detect if jumper connected to VCC, GND, or nothing.

If the pin is high regardless of the pull-up resistor, it's because it's been soldered to VCC. Likewise if the pin is low regardless of the pull-up, it's soldered to GND.


Here's the code to get the address based on the jumper attached to the specified pin. ADDR_PORT and ADDR_DDR are defined in this case as PORTA and DDRA