stillOpenI2C()
[Inter Integrated Circuit]
bool stillOpenI2C();Description
Checks if the I2C bus is still open.
Parameters
None.
Returns
A boolean value that indicates if the I2C bus is still open.
Example Code
The code initializes the I2C communication with the SDA pin connected to pin 4, the SCL pin connected to pin 5, and the address of the chip set to 0x20.
Checks if the I2C bus is still open, and if it is, the code will perform a write I2C operation.
void setup() {
beginI2C(4, 5, 0x20); // initializes the I2C communication with the SDA pin connected to pin 4, the SCL pin connected to pin 5, and the address of the chip set to 0x20
}
void loop() {
if (stillOpenI2C()) { // checks if the I2C bus is still open
writeI2C("x is "); // sends the string "x is " to the follower chip
}
}Notes and Warnings
This function is useful to check if the I2C bus is still open before performing any I2C operation that cannot be completed with the callback functions, it is focused to be used with follower devices.
