// need 0.1uf cap between vcc and ground for proper operation // need 10k pull up resistor on scl and sda for i2c to work correctly // Pin Mappings (Per TinyCore) // ATTiny Pin -- Arduino Pin // 01 17/PA2/RESET // 02 0/PD0/RXD // 03 1/PD1/TXD // 04 2/PA1/XTAL2 // 05 3/PA0/XTAL1 // 06 4/PD2/INT0 // 07 5/PD3/INT1 // 08 6/PD4 // 09 7/PD5 // 10 GND // 11 8/PD6 // 12 9/PB0/PCINT0 // 13 10/PB1/PCINT1 // 14 11/PB2/PCINT2/OC0A // 15 12/PB3/PCINT3/OC1A // 16 13/PB4/PCINT4/OC1B // 17 14/PB5/PCINT5/MOSI/DI/SDA // 18 15/PB6/PCINT6/MISO/DO // 19 16/PB7/PCINT7/SCK/SCL // 20 VCC // i2c ATTiny Pins // sda: 17 // scl: 19 // DIP Switch 1 ATTiny Pins // 2 - 9 // DIP Switch 2 ATTiny Pins // 1 // 11-16 // 18 #define I2C_ADDRESS 0x65 #include void setup() { pinMode(0, INPUT); pinMode(1, INPUT); pinMode(2, INPUT); pinMode(3, INPUT); pinMode(4, INPUT); pinMode(5, INPUT); pinMode(6, INPUT); pinMode(7, INPUT); pinMode(17, INPUT); pinMode(8, INPUT); pinMode(9, INPUT); pinMode(10, INPUT); pinMode(11, INPUT); pinMode(12, INPUT); pinMode(13, INPUT); pinMode(15, INPUT); Wire.begin(I2C_ADDRESS); Wire.onRequest(requestEvent); } void loop() { delay(100); } // function that executes whenever data is requested by master // this function is registered as an event, see setup() byte dip_switches[] = {0b00000000, 0b00000000}; void requestEvent() { bitWrite(dip_switches[0], 7, digitalRead(0)); bitWrite(dip_switches[0], 6, digitalRead(1)); bitWrite(dip_switches[0], 5, digitalRead(2)); bitWrite(dip_switches[0], 4, digitalRead(3)); bitWrite(dip_switches[0], 3, digitalRead(4)); bitWrite(dip_switches[0], 2, digitalRead(5)); bitWrite(dip_switches[0], 1, digitalRead(6)); bitWrite(dip_switches[0], 0, digitalRead(7)); bitWrite(dip_switches[1], 0, digitalRead(15)); bitWrite(dip_switches[1], 1, digitalRead(13)); bitWrite(dip_switches[1], 2, digitalRead(12)); bitWrite(dip_switches[1], 3, digitalRead(11)); bitWrite(dip_switches[1], 4, digitalRead(10)); bitWrite(dip_switches[1], 5, digitalRead(9)); bitWrite(dip_switches[1], 6, digitalRead(8)); bitWrite(dip_switches[1], 7, digitalRead(17)); Wire.write(dip_switches, sizeof(dip_switches)); }