327
Simulation
Explanation
Just like software-based SPI, software-based I2C employs bit-banging ordinary digital I/Os. The whole
functioning of I2C protocol is implemented in software. Again, the software I2C codes are self-
explanatory. This software I2C implementation can be used for any I2C-based device. If you have gone
through the pages recommended earlier, you will understand how it is working.
For this demo, a PCF8591 8-bit ADC-DAC module is used. This ready-made board hosts four 8-bit ADC
input channels and an 8-bit DAC output channel. Off the shelf, it contains a thermistor for sensing
ambient temperature, a light-dependent resistor (LDR) for detecting light level, a potentiometer
connected across the power rail and a free ADC input. The ADC inputs can also be used in various
ways. Check the device’s datasheet for details. I did a very raw level coding for the demo, and so I just
read and showed the ADC values. The DAC is operated using the value of ADC channel 0.