MCP23017 addressing certain pin

Hello, the code triggers all ports on and off. However, I need to address a specific pin (e.g. A0) and don’t know how to implent it.

Appreciate any help as Adafruit library didn’t work for me with the 2560.

#include <Wire.h>
const byte  mcp_address=0x20;      // I2C Address of MCP23017 Chip
const byte  GPIOA=0x12;            // Register Address of Port A
const byte  GPIOB=0x13;            // Register Address of Port B

 
void setup()

{

  Wire.begin();              // join i2c bus (address optional for master)
  Wire.beginTransmission(mcp_address);
  Wire.write((byte)0x00); // IODIRA register
  Wire.write((byte)0x00); // set all of bank A to outputs
  Wire.write((byte)0x00); // set all of bank B to outputs 
  Wire.endTransmission();
}

 void loop()

{
  Wire.beginTransmission(mcp_address);
  Wire.write(GPIOA);      // address bank B
  Wire.write((byte)0xFF);  // value to send - all HIGH ([u]I need only one pin and not all[/u])
  Wire.endTransmission();
  delay(500);
  Wire.beginTransmission(mcp_address);
  Wire.write(GPIOA);    // address bank B
  Wire.write((byte)0x00);  // value to send - all LOW
  Wire.endTransmission();
  delay(500);
  Wire.beginTransmission(mcp_address);
  Wire.write(GPIOB);      // address bank B
  Wire.write((byte)0xFF);  // value to send - all HIGH
  Wire.endTransmission();
  delay(500);
  Wire.beginTransmission(mcp_address);
  Wire.write(GPIOB);    // address bank B
  Wire.write((byte)0x00);  // value to send - all LOW
  Wire.endTransmission();
  delay(500);
}

vaxman:
Appreciate any help as Adafruit library didn't work for me with the 2560.

Why not?

That would be the first thing to determine.

If I remember you simply have to a read mask write operation but I am not positive on that. Try this link, it has lots of examples: https://www.best-microcontroller-projects.com/mcp23017.html

My bad: I forgot to declare pins as output and therefore, I blamed the library.

Thank you all.