onRequestI2C()
[Inter Integrated Circuit]
void onRequestI2C(void (*function)());Description
Sets the function that will be called when the I2C bus requests data.
Parameters
function: the function that will be called when the I2C
bus requests data.
Returns
Nothing.
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.
Sets the function requestEvent to be called when the I2C
bus requests data.
void requestEvent() {
// code to be executed when the I2C bus requests data
}
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
onRequestI2C(requestEvent); // sets the function requestEvent to be called when the I2C bus requests data
}
void loop() {
}Notes and Warnings
The parameter function must be a function that does not
receive any parameters.
