Here's a simple and cheap 8 way DIP switch on I2C
Peter Jakacki
Posts: 10,193
in Propeller 1
I try to avoid DIP switches as much as I can but in this project I think I must use them since I have so many identical modules all bussed together. But I was a bit pressed for I/O and of course I could use the equivalent of a PCF8574 but decided I had one I/O to spare anyway so I used a cheap 74HC165 parallel-in/serial-out shift register. By connecting the Prop's I2C SCL to the clock and the SDA to the load it will of course chatter wildly during any I2C operation but who cares as the Prop isn't listening.
When I do want to read it I just simulate the load pulse, read it and clock it until I'm done with the SDA line held high so it looks like start/stop conditions although it is probably too fast too be seen by an I2C chip.
I may still end up with an I2C I/O expander but in any case this is it. The colored pullups are simply parts of resistor networks. The TSSOP16 74HC165 costs less than 10 cents in reel quantities, the resnets about a cent each so the interface circuit costs around 12 cents.
When I do want to read it I just simulate the load pulse, read it and clock it until I'm done with the SDA line held high so it looks like start/stop conditions although it is probably too fast too be seen by an I2C chip.
I may still end up with an I2C I/O expander but in any case this is it. The colored pullups are simply parts of resistor networks. The TSSOP16 74HC165 costs less than 10 cents in reel quantities, the resnets about a cent each so the interface circuit costs around 12 cents.
Comments
I've used SPI with 165's before but never I2C