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