The Adafruit AW9523 is a versatile I2C GPIO expander that significantly increases the number of GPIO pins available for use with microcontrollers such as the Arduino UNO. This module is particularly useful in projects where a large number of sensors, LEDs, or other peripherals need to be controlled, and the microcontroller itself does not have enough pins. The AW9523 is capable of handling 16 additional GPIOs, each of which can be individually set as an input or output.
Pin Number | Pin Name | Description |
---|---|---|
1 | VCC | Power supply (2.3V to 5.5V) |
2 | SCL | I2C clock signal |
3 | SDA | I2C data signal |
4 | INT | Interrupt output (active low) |
5 | ADDR | I2C address selection (connect to GND or VCC) |
6-21 | IO0-IO15 | GPIO pins (configurable as input or output) |
22 | GND | Ground |
Powering the Module:
Connecting to a Microcontroller:
Setting the I2C Address:
Using the GPIO Pins:
I2C Communication Failure:
Insufficient Output Current:
Unresponsive GPIO Pins:
Q: Can I use the AW9523 with a 3.3V microcontroller? A: Yes, the AW9523 supports I2C interface voltages from 1.8V to 5.5V, making it compatible with both 3.3V and 5V systems.
Q: How do I change the I2C address of the module? A: The I2C address can be changed by connecting the ADDR pin to either GND or VCC. The specific address mapping can be found in the AW9523 datasheet.
Q: Can I use the interrupt pin to wake up my microcontroller from sleep mode? A: Yes, the INT pin can be used as an external interrupt to wake up microcontrollers that support this feature.
#include <Wire.h>
#include <Adafruit_AW9523.h>
// Create AW9523 instance
Adafruit_AW9523 aw9523;
void setup() {
Serial.begin(9600);
// Initialize the AW9523
if (!aw9523.begin()) {
Serial.println("AW9523 not found");
while (1);
}
Serial.println("AW9523 found!");
// Set all pins to outputs
for (int i = 0; i < 16; i++) {
aw9523.pinMode(i, OUTPUT);
}
// Set all pins to low
for (int i = 0; i < 16; i++) {
aw9523.digitalWrite(i, LOW);
}
}
void loop() {
// Example: Toggle all pins
for (int i = 0; i < 16; i++) {
aw9523.digitalWrite(i, HIGH);
delay(100);
aw9523.digitalWrite(i, LOW);
}
}
This example initializes the AW9523 and sets all pins as outputs. It then toggles each pin on and off in sequence. Ensure that the Adafruit AW9523 library is installed in your Arduino IDE before compiling and uploading this code to your Arduino UNO.