There was another question along these lines... stop i2c - Interfacing - Arduino Forum but no solution was offered.
The problem I have is similar to that one, but the folks that answered could not seem to understand.
They just seem to say, use more pins!
I have an old Codan 8525A HF radio and it bit bangs control signals to drive I2C, CBUS and shift resisters all on the same 2 pins.
As I do not want to mod the boards, just remove the 80C31 and EPROM, then plug an Arduino into a custom board that fits in place, I need to use I2C, CBUS (I've written the bit bang driver and it works), and shift register for the PLL chips, all on the Arduino A4 and A5 pins.
Yes, I know I could use different pins and cut the Codan board tracks, but I want to keep it original and have the mods reversible. Also, when I get it all going, it will be a simple add on change for others to use this great old transceiver on the HF ham bands.
So, back to the question!
If the I2C has been started, the A4 and A5 pins no longer respond to digitalWrite and digitalRead commands.
I need to be able to run the I2C stuff, then turn the I2C off, and use the pins as "normal". Then turn I2C back on when needed....
Probably, you need external Mux Switch as depicted below to align the external I2C device and DIO device with the UNO's I2C Logic and DIO Logic respectively. The Wire.begin()/Wire.end() commands will control the K1/K2 switches of UNO; the PB0/PB1 lines will control the K3/K4 switches of Mux Switch.
I have the MUX added, but it is the other way around.
The Arduino has the SCL and SDA into one MUX port pair, a couple of pins for SClock and SData into another MUX port pair, the other 2 pairs are connected to +5V and gnd.
A pair of Arduino lines run the MUX selectors.
#define Sdata 8 // extra "SDA" #define Sclock 7 // extra "SCL" #define MUX0 9 // serial data and serial clock MUX0 control #define MUX1 10 // serial data and serial clock MUX1 control
1. You follow these steps to make your jpg picture visible online: (1) Right Click on the saved file object and click on 'copy link address'. (2) Open your post in Modify/Edit mode. (3) Place the cursor where you want to insert your picture. (4) click on the Insert an image icon of the tool bar of the post page. (5) A small dialog window will appear and follow the menu. (6) Press Cntrl+V to paste the link of your image. (7) Click on OK button, save the post. Observe that your picture (Fig-1) is on the post.
When A5 is HIGH and A4 drops to LOW, that is a I2C START condition.
With enough pulses, some day some chip might reply to its address and pull SDA low. When the Arduino has SDA HIGH at that moment, then you have a shortcut.
It is safer to keep the "open-collector" function for A4 and A5. Make the pin LOW or keep the pin floating (by making it INPUT).
I would set the A4 and A5 to INPUT before calling Wire.begin(), just for safety.
When you keep SDA as INPUT and floating (a pullup resistors should pull it high), then you can use the SCL pin for other things. No device on the I2C bus will do something, because there is never a START condition. Using SCL for other things that way is 100% safe.