beginI2CTransmission()
[Inter Integrated Circuit]
void beginI2CTransmission(unsigned short address);Description
Begins an I2C transmission from a Leader Device.
Parameters
address: the address of the follower chip.
Returns
Nothing.
Example Code
The code initializes the I2C communication with the SDA pin connected to pin 4, and the SCL pin connected to pin 5.
The code then begins an I2C transmission to the follower chip with the address 0x20.
void setup() {
beginI2C(4, 5); // initializes the I2C communication with the SDA pin connected to pin 4, the SCL pin connected to pin 5
}
void loop() {
beginI2CTransmission(0x20); // begins an I2C transmission to the follower chip with the address 0x20
writeI2C("x is "); // sends the string "x is " to the follower chip
writeI2C(42); // sends the value 42 to the follower chip
endI2CTransmission(); // ends the I2C transmission
}Notes and Warnings
- The
beginI2CTransmission()function must be called before sending data to the follower chip. - This function will take of all the pins specified, and configure them as needed, please, do not change the configuration of the pins after calling this function.
