### outputGPIO() usage example Source: https://github.com/adafruit/adafruit_aw9523/blob/master/_autodocs/api-reference/Adafruit_AW9523.md Calls aw.begin() then sets all 16 GPIO outputs at once using a 16-bit bitfield. Examples show all pins high, only pin 0 high, and all pins low. ```cpp aw.begin(); aw.outputGPIO(0xFFFF); // all 16 pins high aw.outputGPIO(0x0001); // only pin 0 high aw.outputGPIO(0x0000); // all pins low ``` -------------------------------- ### Basic Initialization Example Source: https://github.com/adafruit/adafruit_aw9523/blob/master/_autodocs/api-reference/Adafruit_AW9523.md Shows how to initialize the AW9523 with the default I2C address (0x58). If begin() fails, prints an error message and halts forever. ```cpp #include Adafruit_AW9523 aw; void setup() { if (!aw.begin(0x58)) { // default address is also 0x58 Serial.println("AW9523 not found? Check wiring!"); while (1) delay(10); // halt forever } Serial.println("AW9523 found!"); } ``` -------------------------------- ### Usage example with begin() and pinMode() Source: https://github.com/adafruit/adafruit_aw9523/blob/master/_autodocs/api-reference/Constants.md Shows how to initialize the AW9523 with the default address and set pin 0 to constant-current LED mode using the AW9523_LED_MODE sentinel. ```cpp #include Adafruit_AW9523 aw; void setup() { // 0x58 below is the same as AW9523_DEFAULT_ADDR if (!aw.begin(AW9523_DEFAULT_ADDR)) { while (1) delay(10); } aw.pinMode(0, AW9523_LED_MODE); // constant-current mode sentinel } ``` -------------------------------- ### digitalWrite() usage example: set pin high and low Source: https://github.com/adafruit/adafruit_aw9523/blob/master/_autodocs/api-reference/Adafruit_AW9523.md Shows how to set a pin as output and then write HIGH and LOW values using digitalWrite(). ```cpp aw.pinMode(0, OUTPUT); aw.digitalWrite(0, HIGH); // set pin 0 high aw.digitalWrite(0, LOW); // set pin 0 low ``` -------------------------------- ### digitalRead() usage example Source: https://github.com/adafruit/adafruit_aw9523/blob/master/_autodocs/api-reference/Adafruit_AW9523.md Shows how to read a digital input on pin 1 and print a message when it is high. ```cpp aw.pinMode(1, INPUT); bool pressed = aw.digitalRead(1); if (pressed) { Serial.println("Pin 1 is high"); } ``` -------------------------------- ### pinMode() usage example: GPIO output, input, and LED drive Source: https://github.com/adafruit/adafruit_aw9523/blob/master/_autodocs/api-reference/Adafruit_AW9523.md Shows how to configure pins as digital output, digital input, and constant-current LED driver using pinMode(). ```cpp aw.pinMode(0, OUTPUT); // pin 0 as digital output aw.pinMode(1, INPUT); // pin 1 as digital input aw.pinMode(2, AW9523_LED_MODE); // pin 2 as constant-current LED driver ``` -------------------------------- ### openDrainPort0() usage example Source: https://github.com/adafruit/adafruit_aw9523/blob/master/_autodocs/api-reference/Adafruit_AW9523.md Calls aw.begin() then toggles open-drain output for all Port 0 pins. Passing true enables open-drain, false switches back to push-pull. ```cpp aw.begin(); aw.openDrainPort0(true); // Port 0 pins now open-drain aw.openDrainPort0(false); // Port 0 pins back to push-pull ``` -------------------------------- ### analogWrite() 256-step LED fade example Source: https://github.com/adafruit/adafruit_aw9523/blob/master/_autodocs/api-reference/Adafruit_AW9523.md Demonstrates a 256-step LED fade using analogWrite(). The pin must be in constant-current mode (AW9523_LED_MODE). The value wraps from 255 to 0. ```cpp aw.pinMode(0, AW9523_LED_MODE); // must be in constant-current mode uint8_t x = 0; void loop() { aw.analogWrite(0, x++); // 0 .. 255 then wraps to 0 delay(10); } ``` -------------------------------- ### reset() usage example Source: https://github.com/adafruit/adafruit_aw9523/blob/master/_autodocs/api-reference/Adafruit_AW9523.md Calls aw.begin() then aw.reset() to perform a soft reset over I2C. If the reset is not acknowledged, prints an error message to the serial monitor. ```cpp aw.begin(); if (!aw.reset()) { Serial.println("Soft reset was not acknowledged on the I2C bus"); } ``` -------------------------------- ### configureLEDMode() example Source: https://github.com/adafruit/adafruit_aw9523/blob/master/_autodocs/api-reference/Adafruit_AW9523.md Sets pin 0 to constant-current (LED) mode. The function writes the complement of the bitfield to the active-low LED mode registers (0x12 and 0x13). Returns true if both I2C writes are acknowledged. ```cpp aw.begin(); aw.configureLEDMode(0x0001); // pin 0 in constant-current mode ``` -------------------------------- ### interruptEnableGPIO() example Source: https://github.com/adafruit/adafruit_aw9523/blob/master/_autodocs/api-reference/Adafruit_AW9523.md Enables interrupt detection on pin 1 only. The function writes the complement of the bitfield to the active-low interrupt enable registers (0x06 and 0x07). Returns true if both I2C writes are acknowledged. ```cpp aw.begin(); aw.interruptEnableGPIO(0x0002); // enable INT detection on pin 1 only ``` -------------------------------- ### begin() Source: https://github.com/adafruit/adafruit_aw9523/blob/master/_autodocs/api-reference/Adafruit_AW9523.md Initializes the AW9523 hardware and I2C communication. Sets up the I2C device, performs a software reset, verifies the chip ID, configures all pins as inputs, sets port 0 to push-pull, and disables interrupts. ```APIDOC ## begin() ### Description Initializes the AW9523 hardware and I2C communication. Sets up the I2C device, performs a software reset, verifies the chip ID, configures all pins as inputs, sets port 0 to push-pull, and disables interrupts. ### Method begin ### Signature ```cpp bool begin(uint8_t address = AW9523_DEFAULT_ADDR, TwoWire *wire = &Wire); ``` ### Parameters - **address** (uint8_t) - Optional - I2C address of the expander. Default is AW9523_DEFAULT_ADDR (0x58). - **wire** (TwoWire *) - Optional - The TwoWire bus object used for I2C connections. Default is &Wire. ### Returns - **bool** - true if initialization succeeded (I2C device opened, reset acknowledged, chip ID 0x23 verified), otherwise false. ### Example ```cpp #include Adafruit_AW9523 aw; void setup() { if (!aw.begin(0x58)) { // default address is also 0x58 Serial.println("AW9523 not found? Check wiring!"); while (1) delay(10); // halt forever } Serial.println("AW9523 found!"); } ``` ### Example (explicit bus selection) ```cpp Adafruit_AW9523 aw; TwoWire *myBus = &Wire1; // secondary I2C bus on some boards void setup() { bool ok = aw.begin(0x58, myBus); if (!ok) { // Chip not found, reset not acked, or chip ID != 0x23 Serial.println("AW9523 init failed"); } } ``` ``` -------------------------------- ### begin() Method Declaration Source: https://github.com/adafruit/adafruit_aw9523/blob/master/_autodocs/api-reference/Adafruit_AW9523.md Declaration of the begin() method. It initializes the I2C device, performs a software reset, verifies the chip ID (0x23), configures all pins as inputs, sets port 0 to push-pull, and disables interrupts. Returns true on success, false otherwise. ```cpp bool begin(uint8_t address = AW9523_DEFAULT_ADDR, TwoWire *wire = &Wire); ``` -------------------------------- ### Read all GPIO inputs with inputGPIO() Source: https://github.com/adafruit/adafruit_aw9523/blob/master/_autodocs/api-reference/Adafruit_AW9523.md Calls aw.begin() to initialize the AW9523, then reads all 16 GPIO input states into a uint16_t and prints the value in hexadecimal. The return value is a 16-bit binary input where 0 is low and 1 is high, with bit N representing pin N. ```cpp aw.begin(); uint16_t states = aw.inputGPIO(); Serial.print("Port state: 0x"); Serial.println(states, HEX); ``` -------------------------------- ### Construct an Uninitialized AW9523 Instance Source: https://github.com/adafruit/adafruit_aw9523/blob/master/_autodocs/api-reference/Adafruit_AW9523.md Creates an Adafruit_AW9523 object. The instance is uninitialized until begin() is called. ```cpp Adafruit_AW9523 aw; // construct an (uninitialized) expander instance ``` -------------------------------- ### Configure GPIO direction with configureDirection() Source: https://github.com/adafruit/adafruit_aw9523/blob/master/_autodocs/api-reference/Adafruit_AW9523.md Initializes the AW9523 and sets pin 0 as output and pins 1-15 as input using a 16-bit bitfield where 1 is output and 0 is input. The function writes the complement of the bitfield to the direction registers because they are active-low. ```cpp aw.begin(); aw.configureDirection(0x0001); // pin 0 = output, pins 1–15 = input ``` -------------------------------- ### Explicit Bus Selection and Failure Handling Source: https://github.com/adafruit/adafruit_aw9523/blob/master/_autodocs/api-reference/Adafruit_AW9523.md Initializes the AW9523 on a secondary I2C bus (Wire1) with explicit address 0x58. Checks the return value and prints a failure message if initialization fails. ```cpp Adafruit_AW9523 aw; TwoWire *myBus = &Wire1; // secondary I2C bus on some boards void setup() { bool ok = aw.begin(0x58, myBus); if (!ok) { // Chip not found, reset not acked, or chip ID != 0x23 Serial.println("AW9523 init failed"); } } ``` -------------------------------- ### Typical usage of Adafruit_AW9523 Source: https://github.com/adafruit/adafruit_aw9523/blob/master/_autodocs/README.md Shows basic initialization and digital/analog output control. Calls begin(0x58) with the default I2C address, halting if the chip is not found. Uses pinMode with OUTPUT and AW9523_LED_MODE, then digitalWrite and analogWrite in the loop. ```cpp #include Adafruit_AW9523 aw; void setup() { if (!aw.begin(0x58)) { // default I2C address while (1) delay(10); // halt if chip not found } aw.pinMode(0, OUTPUT); // digital output aw.pinMode(2, AW9523_LED_MODE); // constant-current LED drive } void loop() { aw.digitalWrite(0, HIGH); aw.analogWrite(2, 128); // ~50% constant current delay(100); aw.digitalWrite(0, LOW); delay(100); } ``` -------------------------------- ### configureDirection() Source: https://github.com/adafruit/adafruit_aw9523/blob/master/_autodocs/api-reference/Adafruit_AW9523.md Sets the direction for all 16 GPIO at once using a 16-bit bitfield where 1 = output and 0 = input. The complement is written to the configuration registers because the AW9523 direction register is active-low. ```APIDOC ## configureDirection() ### Description Sets the direction for all 16 GPIO at once. The pins parameter is a 16-bit bitfield: 1 == output, 0 == input. The complement of pins is written to AW9523_REG_CONFIG0 (0x04) and AW9523_REG_CONFIG0 + 1 (0x05) because the AW9523 direction register is active-low (a set bit means input). ### Method configureDirection() ### Signature ```cpp bool configureDirection(uint16_t pins); ``` ### Parameters - **pins** (uint16_t) - Required - 16 bits of direction settings, 1 == output, 0 == input. ### Returns - **bool** - true if both I2C writes were acknowledged, otherwise false. ### Throws None. ### Example ```cpp aw.begin(); aw.configureDirection(0x0001); // pin 0 = output, pins 1–15 = input ``` ``` -------------------------------- ### configureLEDMode() Source: https://github.com/adafruit/adafruit_aw9523/blob/master/_autodocs/api-reference/Adafruit_AW9523.md Sets constant-current (LED) mode for all 16 GPIO at once. The pins parameter is a 16-bit bitfield where 1 enables LED mode. Writes the complement to the LED-mode registers. ```APIDOC ## configureLEDMode() ### Description Sets constant-current (LED) mode for all 16 GPIO at once. The `pins` parameter is a 16-bit bitfield where `1` enables LED mode. The complement of `pins` is written to the LED-mode registers. ### Method configureLEDMode ### Signature ```cpp bool configureLEDMode(uint16_t pins); ``` ### Parameters - **pins** (uint16_t) - Required - 16 bits of LED-mode settings, `1` == constant-current mode enabled ### Returns - **bool** - `true` if both I2C writes were acknowledged, otherwise `false`. ### Throws None. ### Example ```cpp aw.begin(); aw.configureLEDMode(0x0001); // pin 0 in constant-current mode ``` ``` -------------------------------- ### Constructor / Destructor Source: https://github.com/adafruit/adafruit_aw9523/blob/master/_autodocs/api-reference/Adafruit_AW9523.md Constructs and destroys an Adafruit_AW9523 instance. The constructor performs no work; initialization is deferred until begin() is called. The destructor performs no cleanup. ```APIDOC ## Constructor / Destructor ### Description Constructs and destroys an Adafruit_AW9523 instance. The constructor performs no work; initialization is deferred until begin() is called. The destructor performs no cleanup. ### Method Constructor / Destructor ### Signature ```cpp Adafruit_AW9523(); ~Adafruit_AW9523(); ``` ### Parameters None. ### Returns None. ### Example ```cpp Adafruit_AW9523 aw; // construct an (uninitialized) expander instance ``` ``` -------------------------------- ### inputGPIO() Source: https://github.com/adafruit/adafruit_aw9523/blob/master/_autodocs/api-reference/Adafruit_AW9523.md Reads the input value for all 16 GPIO at once. Returns a 16-bit value where each bit represents the state of a pin (0 = low, 1 = high). ```APIDOC ## inputGPIO() ### Description Reads the input value for all 16 GPIO at once. Reads registers AW9523_REG_INPUT0 (0x00) and AW9523_REG_INPUT0 + 1 (0x01). ### Method inputGPIO() ### Signature ```cpp uint16_t inputGPIO(void); ``` ### Parameters None. ### Returns - **uint16_t** - 16 bits of binary input: 0 == low, 1 == high; bit N is the state of pin N. ### Throws None. ### Example ```cpp aw.begin(); uint16_t states = aw.inputGPIO(); Serial.print("Port state: 0x"); Serial.println(states, HEX); ``` ``` -------------------------------- ### Button + LED with interrupt on button pin Source: https://github.com/adafruit/adafruit_aw9523/blob/master/_autodocs/api-reference/Adafruit_AW9523.md Configures pin 0 as an output and pin 1 as an input, enables interrupt detection on pin 1, then mirrors the button state to the LED in loop(). The interrupt is enabled with `aw.enableInterrupt(1, true)`; the active-low interrupt-enable register stores the complement of `en`. ```cpp aw.pinMode(0, OUTPUT); aw.pinMode(1, INPUT); aw.enableInterrupt(1, true); // detect changes on pin 1 void loop() { aw.digitalWrite(0, aw.digitalRead(1)); // mirror button state to LED delay(10); } ``` -------------------------------- ### outputGPIO() Source: https://github.com/adafruit/adafruit_aw9523/blob/master/_autodocs/api-reference/Adafruit_AW9523.md Sets the output value for all 16 GPIO at once using a 16-bit bitfield. Returns true if both I2C writes are acknowledged. ```APIDOC ## outputGPIO() ### Description Sets the output value for **all 16 GPIO at once**. `pins` is a 16-bit bitfield: bit *N* is the value for pin *N* (`1` == high). Written to `AW9523_REG_OUTPUT0` (`0x02`) and `AW9523_REG_OUTPUT0 + 1` (`0x03`). ### Method outputGPIO ### Signature `bool outputGPIO(uint16_t pins);` ### Parameters - **pins** (uint16_t) - Required - 16 bits of binary output settings, `1` == high. ### Returns - **bool** - `true` if both I2C write commands were acknowledged, `false` if either write failed. ### Throws None. ### Example ```cpp aw.begin(); aw.outputGPIO(0xFFFF); // all 16 pins high aw.outputGPIO(0x0001); // only pin 0 high aw.outputGPIO(0x0000); // all pins low ``` ``` -------------------------------- ### reset() Source: https://github.com/adafruit/adafruit_aw9523/blob/master/_autodocs/api-reference/Adafruit_AW9523.md Performs a soft reset over I2C by writing 0 to the soft reset register. Returns true if the reset command was acknowledged. ```APIDOC ## reset() ### Description Performs a soft reset over I2C by writing `0` to register `AW9523_REG_SOFTRESET` (`0x7F`). ### Method reset ### Signature `bool reset(void);` ### Parameters None. ### Returns - **bool** - `true` if the I2C reset command was acknowledged. ### Throws None. ### Example ```cpp aw.begin(); if (!aw.reset()) { Serial.println("Soft reset was not acknowledged on the I2C bus"); } ``` ``` -------------------------------- ### pinMode() function signature Source: https://github.com/adafruit/adafruit_aw9523/blob/master/_autodocs/api-reference/Adafruit_AW9523.md Declares the pinMode() method for setting pin direction and LED mode. Parameters: pin (0-15) and mode (INPUT, OUTPUT, or AW9523_LED_MODE). ```cpp void pinMode(uint8_t pin, uint8_t mode); ``` -------------------------------- ### Constructor and Destructor Declarations Source: https://github.com/adafruit/adafruit_aw9523/blob/master/_autodocs/api-reference/Adafruit_AW9523.md Declarations for the Adafruit_AW9523 constructor and destructor. The constructor performs no work; state is initialized only when begin() is called. The destructor performs no cleanup. ```cpp Adafruit_AW9523(); ~Adafruit_AW9523(); ``` -------------------------------- ### digitalWrite() function signature Source: https://github.com/adafruit/adafruit_aw9523/blob/master/_autodocs/api-reference/Adafruit_AW9523.md Declares the digitalWrite() method for setting a pin's digital output level. Parameters: pin (0-15) and val (true for high, false for low). ```cpp void digitalWrite(uint8_t pin, bool val); ``` -------------------------------- ### analogWrite() Source: https://github.com/adafruit/adafruit_aw9523/blob/master/_autodocs/api-reference/Adafruit_AW9523.md Sets the constant-current setting for one pin using the AW9523's 256-step dimming control register. The pin-to-register mapping is not linear. ```APIDOC ## analogWrite() ### Description Sets the constant-current setting for one pin using the AW9523's 256-step dimming control register (chip datasheet Table 13). The pin-to-register mapping is not linear. ### Method `void analogWrite(uint8_t pin, uint8_t val)` ### Parameters - **pin** (uint8_t) - Required - GPIO to set, from 0 to 15 inclusive - **val** (uint8_t) - Required - Current ratio: `0` (off) to `255` (max current) ### Returns - **void** - For pins outside `0`–`15` the function returns early without any I2C write. ### Throws None. ### Pin-to-Register Mapping | Pin range | Register | Addresses | |-----------|----------|-----------| | 0–7 | `0x24 + pin` | `0x24`–`0x2B` | | 8–11 | `0x20 + (pin - 8)` | `0x20`–`0x23` | | 12–15 | `0x2C + (pin - 12)` | `0x2C`–`0x2F` | | > 15 | — | returns without writing | ### Example ```cpp aw.pinMode(0, AW9523_LED_MODE); // must be in constant-current mode uint8_t x = 0; void loop() { aw.analogWrite(0, x++); // 0 .. 255 then wraps to 0 delay(10); } ``` ``` -------------------------------- ### Define special pinMode() mode for constant current Source: https://github.com/adafruit/adafruit_aw9523/blob/master/_autodocs/api-reference/Constants.md Defines a sentinel value 0x99 that is not a real register value but is recognized by Adafruit_AW9523::pinMode() to select constant-current LED drive. ```cpp #define AW9523_LED_MODE 0x99 ///< Special pinMode() macro for constant current ``` -------------------------------- ### enableInterrupt() method signature Source: https://github.com/adafruit/adafruit_aw9523/blob/master/_autodocs/api-reference/Adafruit_AW9523.md Declares the enableInterrupt method that sets the interrupt-enable bit for one pin. The bit is pin % 8 of AW9523_REG_INTENABLE0 + (pin / 8), and the complement !en is written because the register is active-low. Returns void and throws nothing. ```cpp void enableInterrupt(uint8_t pin, bool en); ``` -------------------------------- ### analogWrite() function signature Source: https://github.com/adafruit/adafruit_aw9523/blob/master/_autodocs/api-reference/Adafruit_AW9523.md Declares the analogWrite() method that sets the constant-current level for a pin using the AW9523's 256-step dimming control. ```cpp void analogWrite(uint8_t pin, uint8_t val); ``` -------------------------------- ### digitalRead() Source: https://github.com/adafruit/adafruit_aw9523/blob/master/_autodocs/api-reference/Adafruit_AW9523.md Reads the digital input for one pin (bit pin % 8 of AW9523_REG_INPUT0 + (pin / 8)). Returns true for high, false for low. ```APIDOC ## digitalRead() ### Description Reads the digital input for one pin (bit `pin % 8` of `AW9523_REG_INPUT0 + (pin / 8)`). ### Method `bool digitalRead(uint8_t pin)` ### Parameters - **pin** (uint8_t) - Required - GPIO to read, from 0 to 15 inclusive ### Returns - **bool** - `true` for a high value read, `false` for a low value read. ### Throws None. ### Example ```cpp aw.pinMode(1, INPUT); bool pressed = aw.digitalRead(1); if (pressed) { Serial.println("Pin 1 is high"); } ``` ``` -------------------------------- ### openDrainPort0() Source: https://github.com/adafruit/adafruit_aw9523/blob/master/_autodocs/api-reference/Adafruit_AW9523.md Turns open-drain output on/off for all Port 0 pins (GPIO 0–7) by writing the complement of the parameter to the general configuration register. ```APIDOC ## openDrainPort0() ### Description Turns open-drain output on/off for **ALL Port 0 pins (GPIO 0–7)** by writing the complement of `od` to bit 4 of the general configuration register `AW9523_REG_GCR` (`0x11`, width 1). ### Method openDrainPort0 ### Signature `bool openDrainPort0(bool od);` ### Parameters - **od** (bool) - Required - `true` to enable open-drain output, `false` for push-pull. ### Returns - **bool** - `true` if the I2C write was acknowledged, otherwise `false`. ### Throws None. ### Example ```cpp aw.begin(); aw.openDrainPort0(true); // Port 0 pins now open-drain aw.openDrainPort0(false); // Port 0 pins back to push-pull ``` ``` -------------------------------- ### interruptEnableGPIO() Source: https://github.com/adafruit/adafruit_aw9523/blob/master/_autodocs/api-reference/Adafruit_AW9523.md Sets the interrupt watch for all 16 GPIO at once. The pins parameter is a 16-bit bitfield where 1 enables interrupt. Writes the complement to the interrupt-enable registers. ```APIDOC ## interruptEnableGPIO() ### Description Sets the interrupt watch for all 16 GPIO at once. The `pins` parameter is a 16-bit bitfield where `1` enables interrupt. The complement of `pins` is written to the interrupt-enable registers. ### Method interruptEnableGPIO ### Signature ```cpp bool interruptEnableGPIO(uint16_t pins); ``` ### Parameters - **pins** (uint16_t) - Required - 16 bits of pins to enable interrupts on, `1` == enabled ### Returns - **bool** - `true` if both I2C writes were acknowledged, otherwise `false`. ### Throws None. ### Example ```cpp aw.begin(); aw.interruptEnableGPIO(0x0002); // enable INT detection on pin 1 only ``` ``` -------------------------------- ### Define register addresses Source: https://github.com/adafruit/adafruit_aw9523/blob/master/_autodocs/api-reference/Constants.md Defines the register addresses used by the library for chip ID, soft reset, input/output, configuration, interrupt enable, general configuration, and LED mode. ```cpp #define AW9523_REG_CHIPID 0x10 ///< Register for hardcode chip ID #define AW9523_REG_SOFTRESET 0x7F ///< Register for soft resetting #define AW9523_REG_INPUT0 0x00 ///< Register for reading input values #define AW9523_REG_OUTPUT0 0x02 ///< Register for writing output values #define AW9523_REG_CONFIG0 0x04 ///< Register for configuring direction #define AW9523_REG_INTENABLE0 0x06 ///< Register for enabling interrupt #define AW9523_REG_GCR 0x11 ///< Register for general configuration #define AW9523_REG_LEDMODE 0x12 ///< Register for configuring const current ``` -------------------------------- ### Define default I2C address Source: https://github.com/adafruit/adafruit_aw9523/blob/master/_autodocs/api-reference/Constants.md Defines the default I2C address for the AW9523 breakout as 0x58. Used as the default parameter in Adafruit_AW9523::begin(). ```cpp #define AW9523_DEFAULT_ADDR 0x58 ///< The default I2C address for our breakout ``` -------------------------------- ### digitalRead() function signature Source: https://github.com/adafruit/adafruit_aw9523/blob/master/_autodocs/api-reference/Adafruit_AW9523.md Declares the digitalRead() method that reads a single GPIO pin. Returns true for high, false for low. ```cpp bool digitalRead(uint8_t pin); ``` -------------------------------- ### enableInterrupt(uint8_t pin, bool en) Source: https://github.com/adafruit/adafruit_aw9523/blob/master/_autodocs/api-reference/Adafruit_AW9523.md Sets the interrupt-enable bit for one pin on the AW9523. The interrupt-enable register is active-low, so the complement of the en flag is written. This method returns void and does not report I2C write failures. ```APIDOC ## enableInterrupt(uint8_t pin, bool en) ### Description Sets the interrupt-enable bit for one pin (bit `pin % 8` of `AW9523_REG_INTENABLE0 + (pin / 8)`). Because the interrupt-enable register is active-low, the complement `!en` is written. ### Method void ### Signature ```cpp void enableInterrupt(uint8_t pin, bool en); ``` ### Parameters - **pin** (uint8_t) - Required - GPIO to set, from 0 to 15 inclusive - **en** (bool) - Required - `true` to enable interrupt detection, `false` to ignore ### Returns - **void** - No return value. ### Throws - None. ### Example ```cpp aw.pinMode(0, OUTPUT); aw.pinMode(1, INPUT); aw.enableInterrupt(1, true); // detect changes on pin 1 void loop() { aw.digitalWrite(0, aw.digitalRead(1)); // mirror button state to LED delay(10); } ``` ### Behavioral Notes - The library uses no exceptions; all failures are surfaced as `bool` returns from the 16-pin and setup methods. The single-pin methods (`pinMode`, `digitalWrite`, `digitalRead`, `analogWrite`, `enableInterrupt`) return `void`/`bool` value reads and do not report I2C write failures. - Registers 0x02/0x04/0x06/0x12 use paired `+1` registers for Port 1; the direction, interrupt-enable and LED-mode registers are written with the **complement** of the bitfield because those registers are active-low on the AW9523. - `begin()` must succeed before any other method is used; other methods assume `i2c_dev` is already allocated. ``` -------------------------------- ### pinMode(uint8_t pin, uint8_t mode) Source: https://github.com/adafruit/adafruit_aw9523/blob/master/_autodocs/api-reference/Adafruit_AW9523.md Sets the pin mode or direction for a single GPIO pin on the AW9523. Writes the direction and LED-mode bits for the specified pin. ```APIDOC ## pinMode(uint8_t pin, uint8_t mode) ### Description Sets the pin mode / direction for one pin. Writes both the direction bit (`AW9523_REG_CONFIG0 + (pin / 8)`) and the LED-mode bit (`AW9523_REG_LEDMODE + (pin / 8)`). ### Method pinMode ### Signature ```cpp void pinMode(uint8_t pin, uint8_t mode); ``` ### Parameters - **pin** (uint8_t) - Required - GPIO to set, from 0 to 15 inclusive - **mode** (uint8_t) - Required - One of `INPUT`, `OUTPUT`, or `AW9523_LED_MODE` (`0x99`) ### Behavior | `mode` value | Direction bit | LED-mode bit | Effect | |--------------|---------------|--------------|--------| | `OUTPUT` | `0` | `1` | GPIO digital output | | `INPUT` | `1` | `1` | GPIO digital input | | `AW9523_LED_MODE` (`0x99`) | `0` | `0` | Constant-current LED drive | Any other `mode` value is ignored (no register write occurs). ### Returns `void` ### Throws none ### Example ```cpp aw.pinMode(0, OUTPUT); // pin 0 as digital output aw.pinMode(1, INPUT); // pin 1 as digital input aw.pinMode(2, AW9523_LED_MODE); // pin 2 as constant-current LED driver ``` ``` -------------------------------- ### digitalWrite(uint8_t pin, bool val) Source: https://github.com/adafruit/adafruit_aw9523/blob/master/_autodocs/api-reference/Adafruit_AW9523.md Sets the digital output level for a single GPIO pin on the AW9523. Writes a single bit of the output register for the specified pin. ```APIDOC ## digitalWrite(uint8_t pin, bool val) ### Description Sets the digital output for one pin. Writes a single bit (shift `pin % 8`) of `AW9523_REG_OUTPUT0 + (pin / 8)`. ### Method digitalWrite ### Signature ```cpp void digitalWrite(uint8_t pin, bool val); ``` ### Parameters - **pin** (uint8_t) - Required - GPIO to set, from 0 to 15 inclusive - **val** (bool) - Required - `true` for high value, `false` for low value ### Returns `void` ### Throws none ### Example ```cpp aw.pinMode(0, OUTPUT); aw.digitalWrite(0, HIGH); // set pin 0 high aw.digitalWrite(0, LOW); // set pin 0 low ``` ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.