MCP4241 digital potentiometer that i cant get to work right

i have recently bought this exact chip with breakout board [AK-MCP4241 – Dual Digital 10K Potentiometer Breakout | Artekit Labs]

this is the documentation for said chip [https://www.artekit.eu/resources/ak-mcp4241/doc/22059b.pdf]

i have planned to use this chip to output pot values to a ps5 gamepad so that i might code deadzone and response curves on the arduino with a stick i wired to 2 of the analog pins of the arduino pro micro.

the problem is i cannot with any degree of confidence figure out how to code for the chip.

this is the code i have currently

#include <SPI.h>

#define SlaveSelect 7  // Change this to your CS pin!
//#define READ_PIN A1  // The pin connected to the Wiper
int pot0 = 0;
//int pot1 = 16;
int pot1 = 18;
//int stickValue = 63;

void setup() {
  
  pinMode(SlaveSelect, OUTPUT);
  //digitalWrite(CS_PIN, HIGH);  // Deselect the MCP4241
   
  SPI.begin();
  Serial.begin(9600);  // Start serial communication for debugging
  // digitalWrite(SlaveSelect, LOW);
  // digitalPotWrite(0, 0);
  // digitalPotWrite(1, 0);
  // digitalWrite(SlaveSelect, HIGH);
  
}

void loop() {
 //unlockWiper();

  //digitalPotWrite(pot0, 0);
  digitalPotWrite(pot1, 63);

  //digitalPotWrite(pot1, 0);
  digitalPotWrite(pot0, 63);
}

int digitalPotWrite(int CommandByte, int value) {
// take the SS pin low to select the chip:
digitalWrite(SlaveSelect, LOW);
// send in the address and value via SPI:
SPI.transfer(CommandByte);
SPI.transfer(value);
// take the SS pin high to de-select the chip:
digitalWrite(SlaveSelect, HIGH);
}

this code will set the value for pot 0 and i am fairly confident that 0 is the address for pot 0 but pot 1is allways maxed out at 128 and never seems to change its value making me completely unsure what the address for pot 1s wiper is and how to set it.

Through various sources i have come up with multiple values for addresses for pot1 such as 1, 16, 18 and 01 witch came from the data sheet but i really dont understand the data sheet.

the MCP4241 allso has a wiper lock feature that can lock either of the wiper values witch i am worried i may of accidently turned on for pot 1 when i was trial and erroring addresses and cs pin values.

if anyone has any good experience interacting with chips like this if you could tell me the proper way to access both pots or at least tell me with some confidence what the address for pot 1 is i would greatly appreciate it

The write command byte for pot0 is 0x00
The write command byte for pot1 is 0x10

Put a 10us delay after you set the CS LOW and before you bring it HIGH

Arduino -- 4241
MOSI --> MOSI
MISO <-- MISO
SCK --> SCK
CS --> CS
GND --> GND

i put in the new addresses and put the delays where you said but pot 1 is still maxing out instead of changing to 63

Does pot0 work?

I don't know how i missed it but you need to do a SPI.beginTransaction after you do the SPI.begin and set the speed to 1000000

pot 0 did work, and do i need to put all variables in to the spi.beginTransaction or will 1000000 do on its own

Just to be sure everything is set correctly use:
SPI.beginTransaction(SPISettings(1000000, MSBFIRST, SPI_MODE0))

pot 0 is still working pot 1 is still maxed and i think the 0x00 for pot 0 is for its stored value in its memory because it only changes to the value i gave it when i turn it off then back on again

According to table 7-2 in the data sheet the commands are 0x00 ans 0x10
For debugging try this code

#include <SPI.h>

#define SlaveSelect 7

int pot0 = 0x00;
int pot1 = 0x10;

void setup() {
  pinMode(SlaveSelect, OUTPUT);
  digitalWrite(SlaveSelect, HIGH);  // Deselect the MCP4241

  SPI.begin();
  SPI.beginTransaction(SPISettings(1000000, MSBFIRST, SPI_MODE0));
  Serial.begin(9600);
  delay(10);
  digitalPotWrite(pot0, 63);
  delay(10);
  digitalPotWrite(pot1, 63);

}

void loop() {
}

int digitalPotWrite(int CommandByte, int value) {
  // take the SS pin low to select the chip:
  digitalWrite(SlaveSelect, LOW);
  delay(1);
  // send in the address and value via SPI:
  SPI.transfer(CommandByte);
  SPI.transfer(value);
  // take the SS pin high to de-select the chip:
  delay(1);
  digitalWrite(SlaveSelect, HIGH);
}

pot 0 working, pot1 still maxed out and im gunna set pot0 to run through its steps to see if its updating as the value changes quick

yea 0x00 is a saved value for when it powers up, 0 is the one that can be updated in real time but pot1 still doesnt move on start up. do you think this could be caused by a problem with the cs pin because if i comment out changing the cs pin high and low pot 0 still moves in real time

That would suggest the CS line may be stuck LOW
Comment out the write to pot0 and see if pot1 works

no its still stuck at max

This sketch will print the error code returned from the 4241. Any value other than FF is an error

#include <SPI.h>

#define SlaveSelect 7

int pot0 = 0x00;
int pot1 = 0x10;
int CMDerror;

void setup() {
  pinMode(SlaveSelect, OUTPUT);
  digitalWrite(SlaveSelect, HIGH);  // Deselect the MCP4241

  SPI.begin();
  SPI.beginTransaction(SPISettings(1000000, MSBFIRST, SPI_MODE0));
  Serial.begin(9600);
  delay(10);

  CMDerror = digitalPotWrite(pot0, 63);
  Serial.println(CMDerror, HEX);
  delay(10);
  CMDerror = digitalPotWrite(pot1, 63);
  Serial.println(CMDerror, HEX);

}

void loop() {
}

int digitalPotWrite(int CommandByte, int value) {
  // take the SS pin low to select the chip:
  digitalWrite(SlaveSelect, LOW);
  delay(1);
  // send in the address and value via SPI:
  byte cmderror = SPI.transfer(CommandByte);
  SPI.transfer(value);
  // take the SS pin high to de-select the chip:
  delay(1);
  digitalWrite(SlaveSelect, HIGH);
  return cmderror;
}

this code didnt return anything in the serial moniter at first but i moved

CMDerror = digitalPotWrite(pot0, 63);
  Serial.println(CMDerror, HEX);
  delay(10);
  CMDerror = digitalPotWrite(pot1, 63);
  Serial.println(CMDerror, HEX);

to the loop and it returned 0

Then something is drastically wrong.
Which Arduino are you using?
Which IDE version?

arduino pro micro, arduino ide 2.3.2

Isn't port 1 0x01
I don't believe 0x10 is valid

0x01 still does not move the pot 1 value on start up or in real time

Put this in the loop if you don't get FF then something is wrong

  delay(300);
  CMDerror = digitalPotWrite(pot0, 63);
  Serial.println(CMDerror, HEX);
  delay(300);
  CMDerror = digitalPotWrite(pot1, 63);
  Serial.println(CMDerror, HEX);