The Adafruit DS3502 is a digital potentiometer, or "digipot," which provides a programmable resistance value across its two terminals. This component is ideal for applications requiring precise control of voltage, current, or signal amplitude. Common use cases include adjusting the brightness of LEDs, controlling the gain of an amplifier, or fine-tuning sensor inputs.
Pin Number | Name | Description |
---|---|---|
1 | SCL | Serial Clock Line for I²C communication |
2 | SDA | Serial Data Line for I²C communication |
3 | A0 | Address pin for I²C address selection |
4 | W | Wiper terminal, the variable end of the potentiometer |
5 | L | Low terminal, the low end of the potentiometer |
6 | H | High terminal, the high end of the potentiometer |
7 | VDD | Power supply voltage (2.7V to 5.5V) |
8 | GND | Ground |
#include <Wire.h>
// DS3502 I2C address (depends on A0 pin connection)
const int DS3502_Address = 0x28;
// Command to set wiper position
const byte WIPER_REG = 0xA9;
void setup() {
Wire.begin(); // Join I2C bus
Serial.begin(9600); // Start serial communication for debugging
setWiperPosition(128); // Set wiper to mid-scale position
}
void loop() {
// Example: Cycle through all resistance positions
for (int position = 0; position < 256; position++) {
setWiperPosition(position);
delay(10); // Short delay between changes
}
}
void setWiperPosition(byte position) {
Wire.beginTransmission(DS3502_Address); // Begin transmission to DS3502
Wire.write(WIPER_REG); // Point to wiper register
Wire.write(position); // Set new wiper position
Wire.endTransmission(); // End transmission
// Debug output to serial monitor
Serial.print("Wiper position set to: ");
Serial.println(position);
}
Q: Can the DS3502 be used with a microcontroller other than Arduino? A: Yes, the DS3502 can be interfaced with any microcontroller that supports I²C communication.
Q: How do I change the I²C address of the DS3502? A: The I²C address can be changed by connecting the A0 pin to either GND or VDD. This provides two possible addresses for the device.
Q: Is the DS3502 capable of handling power applications? A: The DS3502 is designed for low-power applications and should not be used in high-power circuits.
Q: How do I save the wiper position so it's retained after power cycling? A: The DS3502 automatically stores the last wiper position in its non-volatile memory when powered down.
For further assistance, consult the Adafruit DS3502 datasheet or contact technical support.