How to create Jumpers for I2C slave addresses?

I have a bunch of slaves and a master over I2C and was wondering if it's possible to set the address via jumpers like this Adafruit article shows instead of uploading the code all the time? If so, are there any tutorials how to do this?

Surely it relies on the device designer having built such ability into the device?

Not sure how that helps me... I was wondering if there's a tutorial out there on how to use jumpers to assign an address.

You mean you are using Arduino as i2c slaves and you want to control their addresses by jumper, so that the code running on the slaves is identical? Yes, absolutely you can, if the Arduino have spare pins. Just read the pins in setup() before you set the slave address.

shai:
Not sure how that helps me... I was wondering if there's a tutorial out there on how to use jumpers to assign an address.

Well you can't do it if the device in question, and you didn't say what yours are, doesn't have address pins in the first place.

Yes exactly. The code on the slaves is identical - sorry forgot to mention. I just want to change the address physically so I don't have to connect each slave to the IDE to upload code. Is there a tutorial on how to add jumpers to set an address?

Depends
Is this for your SMD feeder?
Then it depends on the number of spare pins on the ATtiny84.
Can also use DIP switches instead of solder bridges.
Or DIP switches and a resistor ladder on the analogue pin if you don't have enough I/O left.
Leo..

Does your device have address pins, like in the adafruit tut? Or not?

If it does, your device documentation will explain the truth table that defines each address, and you will then just ground them or high them according to what the docs say.

But it sounds to me that you want to be able to set a hardware address on a device that doesn't have such a facility, hence my question.

shai:
so I don't have to connect each slave to the IDE to upload code.

You always have to do that, unless you pay a huge amount of money for ATMEL to pre-program your code into thousands of chips at the factory. So why do you want to do it via jumpers?

shai:
Is there a tutorial on how to add jumpers to set an address?

Why do you need a tutorial? Just read the pins in setup(), decide on the address to use, and when you startup the Arduino as a slave, use the chosen address.

ok, the penny dropped... this is about Arduinos being the slaves, not devices like in the adafruit tut being connected to an Arduino....

No, you can't do exactly like that but if you program different IDs in the coding and add some logic like if Pin D3 goes HIGH then set this ID. IF Pin D4 goes HIGH then set second ID. Something like that.

jubukraa:
ok, the penny dropped... this is about Arduinos being the slaves

That's what I was assuming, because that seemed to be the least crazy interpretation of the OP's vague question.

jackthomson42:
No, you can’t do exactly like that

Exactly like what? If you mean how it is done on the AdaFruit ht16k33 backpacks, you could do it pretty much exactly like that.

PaulRB:
That's what I was assuming, because that seemed to be the least crazy interpretation of the OP's vague question.

My interpretation seemed less crazy to me :wink: given the link to a tutorial about a peripheral with address pads.

const byte address_base 0x10;

void setup()
{
 // address pins: 2, 3, 4

 byte address_offset = 0;
 for( i=4; i>=2; i--)
 {
   pinMode( i, INPUT_PULLUP);
   delay( 1);        // for extra safety in case there are no external pullup resistors

   address_offset <<= 1;
   if( digitalRead( i) == HIGH)
   {
     address_offset |= 0x01;  // set bit according to jumper
   }
 }
 Wire.begin( address_base + address_offset);
}

Using the EEPROM as address store costs no pins at all. As long as no address is programmed, the slave can scan the bus for the first free address and use it as its own. Then add one slave after another to the bus.