Hir sir, I have interfaced Digital Potentiometer Part Number: MCP41010. I have attached the Code for your reference:
#include <SPI.h>
// Pins for SPI comms
#define DATA 11 // SPI Data pin number
#define CLK 13 // SPI Clock pin number
#define CS_DIGIPOT 9 // MCP41010 chip select - digital potentiometer.
void write_digipot(int val) {
// // take the CS pin low to select the chip:
digitalWrite(CS_DIGIPOT,LOW);
// send in the address and value via SPI:
SPI.transfer(B00010001);
// write out the value
SPI.transfer(val);
// take the CS pin high to de-select the chip:
digitalWrite(CS_DIGIPOT,HIGH);
SPI.endTransaction();
}
void setup() {
pinMode(CS_DIGIPOT,OUTPUT);
SPI.begin(); // Set pins as outputs for SPI hardware.
write_digipot(128); // Set MCP41010 to mid point.
}
void loop(void) {
}
The code is working. The part which is used is the 10k Digital Potentiometer. Here is the Reading for the SPI Data Sent:
if Data --> 00 -- Resistance --> 0 ohms Data --> 64 -- Resistance --> 2.2K ohms Data --> 128 -- Resistance --> 4.3k ohms Data --> 192 -- Resistance --> 6.5K ohms Data --> 255 -- Resistance --> 8.6k Ohms
For testing I have used P-Dip Package of the Part : MCP41010 IC.
My question is, why the Resistance is not 10k ohms when i give the Data = 255? PA0 and PW0 pin is shorted. I am checking the Resistance in between PB0 and the PW0. What could be problem? Kindly let us know.
Datasheet for MCP41010:
MCP4201 datasheet.pdf (866.3 KB)
