Problem whith I2C digital potentiometer MCP40D18

Hello, I'm trying to handle a MCP40D18 50k digital potentiometer whit Arduino, I have detected the i2c port 0x3E correctly but I can't set the potentiometer value using the Wire.write() function. After many changes of the values passed to the function I always receive 0xF8 and measuring with a multimeter the potentiometer is set to the 50%.
Reading the datasheet I do not understand how to write the values correctly.
Some help please!

here is my code:

void setup()
{
Wire.begin();
Serial.begin(9600);
}

void potLoop()
{

Wire.beginTransmission(pot_address);    
Wire.write(byte(0x50));

errorPot=Wire.endTransmission();
Serial.print(" error - ");
Serial.println(errorPot,HEX);
delay(dt);

Wire.requestFrom(pot_address, 2);
*a = Wire.read();

Serial.print(" read a - ");
Serial.println(*a,BIN);

}
void loop()
{
potLoop();
}

Did you respect the voltage limitations of the pot (polarity of the DMM).
All pins of the chip (including the pot pins) must stay within the supply/GND limits of the chip.
Leo..

Hi, @jsebas2448
Welcome to the forum.
Please read the post at the start of any forum , entitled "How to use this Forum".

This will help with advice on how to present your code and problems.

How are you measuring the resistance?

Thanks.. Tom... :smiley: :+1: :coffee: :australia:

Thank's for your answers. Yes, all connections were right, the problem was before writing the potentiometer value a (0x00) write is needed.

  Wire.beginTransmission(pot_address);    
    Wire.write(byte(0x00)); // write instruction.
    Wire.write(Potval);   
    errorPot=Wire.endTransmission();

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.