I am a total noob, i am currently working on a project to control 3 atmega8 as slaves. But i don't know to define hardware address for each slave,i.e. i am doing the schematic of the board on which all slaves will be residing. Help please.
You can assign any unused address that you like to the slaves in the Wire,begin() for each slave [like Wire.begin(6);]. I seem to remember to avoid using address 0 (zero) but not sure why. Also keep the addresses under 128.
The lowest 8(?) I2C addresses are reserved for special purposes (broadcast...).
Untested: When multiple Arduino slaves shall share the same code, the address can be stored in EEPROM, provided that the EEPROM is not affected when a new sketch is uploaded.
Is there a way to hardwire the address for each slave.
I would say only by using some resistors and ports so on power up it reads the ports then this will set the address of the salve. Lets say 3 resistors 2 pulled to GND one set high (5V)with jumpers this address - 0X27 then 2 resistors pulled high(5V) one to GND then address =0X3F and so on. Ths to me would be the only way to do it hardware way