isWritingI2C()
[Inter Integrated Circuit]
bool isWritingI2C();Description
Checks if the I2C bus is currently writing data.
Parameters
None.
Returns
A boolean value that indicates if the I2C bus is currently writing data.
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 currently writing data, and if it is, the code will perform a read I2C operation, and save the data to the EEPROM.
void setup() {
beginEEPROM(32); // initializes the EEPROM with 32 bytes of memory
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
if (isReadingI2C()) { // checks if the I2C bus is currently reading data
writeI2C("x is "); // sends the string "x is " to the follower chip
}
if (isWritingI2C()) { // checks if the I2C bus is currently writing data
unsigned char val = readI2C(); // reads data from the follower chip
writeI2C(val); // writes the data to the EEPROM
}
}
}Notes and Warnings
This function is planned to be used with follower devices to check if
the I2C bus is currently reading data, together with the
stillOpenI2C() function.
