Skip to main content

PCAL6416A - Digital Write

This page covers driving a digital output pin on the PCAL6416A GPIO expander.


Writing a pin

Connect an LED with a current-limiting resistor between A0 and GND.

#include "PCAL6416A-SOLDERED.h"

PCAL6416A expander;

void setup()
{
Serial.begin(115200);
expander.begin();

expander.pinModePCAL(PCAL6416A_A0, OUTPUT);
}

void loop()
{
expander.digitalWritePCAL(PCAL6416A_A0, HIGH);
delay(1000);
expander.digitalWritePCAL(PCAL6416A_A0, LOW);
delay(1000);
}

expander.pinModePCAL()

Configures a GPIO pin on the PCAL6416A expander as an input or output.

Returns value: None.

Function parameters:

TypeNameDescription
uint8_tpinThe GPIO pin to configure. Use a constant such as PCAL6416A_A0-PCAL6416A_A7 or PCAL6416A_B0-PCAL6416A_B7.
uint8_tmodePin mode: INPUT, OUTPUT, INPUT_PULLUP, or INPUT_PULLDOWN.

expander.digitalWritePCAL()

Sets the output state of a selected GPIO pin on the PCAL6416A expander.

Returns value: None.

Function parameters:

TypeNameDescription
uint8_tpinThe GPIO pin to write. Use a constant such as PCAL6416A_A0-PCAL6416A_A7 or PCAL6416A_B0-PCAL6416A_B7.
uint8_tvalueOutput level: HIGH or LOW.

The LED should blink on and off once per second.

digitalWrite.ino

Full digital write example for the PCAL6416A GPIO expander