The AD5259 library allows Arduino users to interface with the Analog Devices AD5259 digital potentiometer via I²C. This library provides functions to read and write values to the RDAC register, store settings in EEPROM, and reset stored values.
- Read and write RDAC values (0-255)
- Store and retrieve values from EEPROM
- Check device connection over I²C
- Reset EEPROM to a default value
- Built-in timeout handling for I²C communication
- Download or clone this repository.
- Copy the
AD5259folder into your Arduinolibrariesdirectory. - Restart the Arduino IDE.
#include <Wire.h>
#include "AD5259.h"AD5259 potentiometer(0x18); // Default I2C address
void setup() {
Serial.begin(115200);
Wire.begin();
if (potentiometer.begin()) {
Serial.println("AD5259 detected!");
} else {
Serial.println("AD5259 not found!");
}
}potentiometer.write(128); // Set RDAC to midpoint
uint8_t value = potentiometer.read();
Serial.print("RDAC Value: ");
Serial.println(value);potentiometer.writeEEPROM(200); // Save value to EEPROM
uint8_t storedValue = potentiometer.readEEPROM();
Serial.print("Stored EEPROM Value: ");
Serial.println(storedValue);potentiometer.resetEEPROM(128); // Reset to 128This library is released under the MIT License.
Pull requests and improvements are welcome! Feel free to contribute via GitHub.
Developed by thebestia90.
This software is provided "as is" without any warranties. Always verify values before use in critical applications.