pinMode(INTERRUPT_PIN, INPUT_PULLUP);
digitalWrite(INTERRUPT_PIN, HIGH);
attachInterrupt(digitalPinToInterrupt(INTERRUPT_PIN), ISR, FALLING);
Now that our interrupt pin is configured the code monitors the GPIO pins' statuses and any time the status
changes, the interrupt pin on the Qwiic GPIO will be driven LOW. You can view the entire loop and ISR function
below:
void loop() {
if (dataReady) {
myGPIO.digitalReadPort(gpioStatus);
for (uint8_t arrayPosition = 0; arrayPosition < NUM_GPIO; arrayP+) {
Serial.print(arrayPosition);
Serial.print(": ");
switch (gpioStatus[arrayPosition])
{
case true:
Serial.print("HI ");
break;
case false:
Serial.print("LO ");
break;
}
}
Serial.println();
dataReady = false;
}
}
void ISR() {
dataReady = true;
}
That wraps up the Arduino examples but if you would prefer to use Python instead with a different development
board or single-board computer like the Raspberry Pi, read on to the next two sections where we'll detail how to
use the Qwiic GPIO Python Package.
Qwiic GPIO Python Package
Note:
This package assumes you are using the latest version of Python 3. If this is your first time using
Along with the Arduino Library, we've written a Python package to control the Qwiic GPIO. You can install the
sparkfun-qwiic-gpio
Python package hosted by PyPi or if you prefer to manually download and build the
libraries from the GitHub repository, you can grab them by clicking the button below (
*Please be aware of any
package dependencies. You can also check out the repository documentation page, hosted on Read the Docs.
):