Wire Library
Wire Library
Wire Library
This library allows you to communicate with I2C / TWI devices.
Functions
On the Arduino boards with the R3 layout (1.0 pinout), the SDA - begin()
(data line) and SCL (clock line) are on the pin headers close to - requestFrom()
the AREF pin. The Arduino Due has two I2C / TWI interfaces - beginTransmission()
- endTransmission()
SDA1 and SCL1 are near to the AREF pin and the additional one
- write()
is on pins 20 and 21. - available()
As a reference the table below shows where TWI pins are - read()
- SetClock()
located on various Arduino boards.
- onReceive()
Board I2C / TWI pins
- onRequest()
Uno, Ethernet A4 (SDA), A5 (SCL)
Mega2560 20 (SDA), 21 (SCL)
Leonardo 2 (SDA), 3 (SCL)
Due 20 (SDA), 21 (SCL), SDA1, SCL1
Note
The Wire library implementation uses a 32 byte buffer, therefore any communication
should be within this limit. Exceeding bytes in a single transmission will just be
dropped.
Examples
- Digital Potentiometer: Control an Analog Devices AD5171
Digital Potentiometer.
- Master Reader/Slave Writer: Program two Arduino boards to
communicate with one another in a Master Reader/Slave
Sender configuration via the I2C.
- Master Writer/Slave receiver:Program two Arduino boards
to communicate with one another in a Master Writer/Slave
Receiver configuration via the I2C.
- SFR Ranger Reader: Read an ultra-sonic range finder
interfaced via the I2C.
- Add SerCom : Adding mores Serial interfaces to SAMD
microcontrollers.
See also
- Master Writer
- Master Reader
- SFR Ranger Reader
- Digital Potentiometer
Reference Home
The text of the Arduino reference is licensed under a Creative Commons Attribution-
ShareAlike 3.0 License. Code samples in the reference are released into the public
domain.
Contact Us
About Us
Distributors
Careers
Security
© 2019 Arduino