I am very new to Arduino, so please excuse any incorrectly used terminology - I'm still getting my head around it all!
I am trying to use an Arduino M0 PRO to communicate with an AD8403 1k digital potentiometer. After following many examples online, implementing them, getting a colleague to check my work, and getting no output from the DigiPot, I decided to read around SPI and try to infer what I needed in my script to communicate properly with the chip.
Below is the code I wrote:
* AD8403 Test On PCB I/O Blade
*
* CS - to digital pin 10 (SS pin)
* SDI - to digital pin 11(MOSI pin)
* CLK - to digital pin 13 (SCK pin)
*
* VDD - to 5V
* DGND - to ground
* SHDN - to 5V
* RST - pulled high
*
* A(1,2,3,4) - to 5V
* W (1,2,3,4) - to oscilloscope
* B(1,2,3,4) - to ground
* AGND(1,2,3,4) - to ground
*/
#include <SPI.h>
const int chipSelect = 10;
int address;
int value;
void digitalPotWrite(int address, int value){
SPI.transfer(address);
SPI.transfer(value);
}
void setup() {
pinMode (chipSelect, OUTPUT);
SPI.begin();
}
void loop() {
for (;;){
for (value = 0; value < 255 ; value++){
digitalPotWrite(2, value);
}
}
}
//END
This is supposed to select chip 3 in the DigiPot (I chose that number so that the binary address sent would be 2 characters in length, as is on the spec sheet), and then scale from 0-255 on the sweep arm of the Pot. This should hopefully then give out a voltage which ranges from 0V up to 5V.
I used a logic analyser after checking with a multimeter, and with both tools I found that I had nothing coming out of the digital pins on the arduino.
The 5V and ground were working.
This is first time using SPI, and my first time really writing a script myself, so any help or suggestions would be appreciated.
Thanks in advance!