here is a simple code that will read the current position of the wiper of channel 0 and then set it to position 100. The code is able to read the current position, but not change it to 100. it is basically stuck at 127.
#include <Wire.h>
#define AD5254_ADDRESS 0x2C // I2C address of AD5254
#define RDAC0 0x00 // RDAC0 register address
byte wiperValue = 0; // variable to store wiper value
void setup() {
Wire.begin();
Serial.begin(9600);
}
void loop() {
Wire.beginTransmission(AD5254_ADDRESS);
Wire.write(RDAC0);
Wire.endTransmission();
Wire.requestFrom(AD5254_ADDRESS, 1);
while (Wire.available()) {
wiperValue = Wire.read();
Serial.print("Current Wiper Value: ");
Serial.println(wiperValue);
}
Wire.beginTransmission(AD5254_ADDRESS);
Wire.write(RDAC0);
Wire.write(100);// set wiper value to 100
Wire.endTransmission();
}
any help on how to change the value of the wiper is much appreciated
hey @jim-p. I will definitely do that. however, I think I have tried that, also, I think by default, they are zero. I will try it again and see. what do you think about the code?
So, I have tried your code. It seems to be able to read the current position using your code and mine. but I want to change to the position of the wiper which I am not able to do
P.S. its a 1 k ohm DigiPot. using a ohm meter across W1 and B1 , it reads 500 ohms
Hi, @jremington. As I mentioned in above, I am able to read the current position of the wiper but not able to change it. I have used the example included in the library you mentioned.
The AD5254 does NOT have pull-ups on SCL or SDA, so you need external pull-ups.
A0 and A1 cannot be left floating, they need to be connected to ground or 5V, depending on what I2C address you want.
WP is the write protect control for BOTH the internal EEPROM and the RDAC registers. It has an internal pull-down, so must be connected to 5V if you want to change the registers or EEPROM.