Having trouble seeing the detail in this mess of jumper wires? Click on the photo for a larger view!
With the Qwiic GPIO circuit assembled and connected to your microcontroller it's time to get some code uploaded
and start controlling the extra I/O pins via I C!
Qwiic GPIO Arduino Library
Note:
This library assumes you are using the latest version of the Arduino IDE on your desktop. If this is your
first time using Arduino, please review our tutorial on installing the Arduino IDE. If you have not previously
installed an Arduino library, please check out our installation guide.
The SparkFun Qwiic GPIO Arduino Library helps to make interfacing between the TCA9534 and your Arduino
microcontroller simple. In this section we'll list all of the functions available in the library as well as brief
descriptions about what they do.
Library Functions
We've outlined all the functions in the Arduino library below along with some quick descriptions of what they do.
The examples cover nearly all of the functions so you may want to refer to those for help with writing your own
code using them.
Device Setup & Settings
bool begin(TwoWire &wirePort, uint8_t address);
- Initialize the TCA9534 on the I C bus. If you have
set the TCA9534 to an alternate I C address using the ADR jumpers, enter that here.
bool pinMode(uint8_t gpioNumber, bool mode);
- Sets the mode of the selected GPIO pin on the
TCA9534. For example,
pinMode(0, GPIO_OUT);
sets pin 0 as an output. All I/O's default to
Inputs
on
power up.
bool pinMode(bool *gpioPinMode);
- An alternative to the above function to set the entire port as an input
bool invertPin(uint8_t gpioNumber, bool inversionMode);
- Invert the polarity of the selected GPIO pin
on the TCA9534.
bool invertPin(bool *inversionMode);
- Invert the polarity of the entire port of the TCA9534. Refer to
Example 3B - Inversion_Port for a demonstration of how to set up and use this function.
GPIO Reading and Writing
bool digitalWrite(uint8_t gpioNumber, bool value);
- Your basic Digital Write function. Write to the
selected GPIO pin either
HIGH
or
LOW
.
2
2
2