Ah that must be my issue, I am following the wrong tutorial
and yes I am using the MCP4131.
The following code exhibits the same issue:
#include <SPI.h>
byte address = 0x00;
int CS= 18;
void setup()
{
pinMode (CS, OUTPUT);
SPI.begin();
}
void loop()
{
for (int i = 0; i <= 128; i++)
{
digitalPotWrite(i);
delay(10);
}
delay(500);
for (int i = 128; i >= 0; i--)
{
digitalPotWrite(i);
delay(10);
}
}
int digitalPotWrite(int value)
{
digitalWrite(CS, LOW);
SPI.transfer(address);
SPI.transfer(value);
digitalWrite(CS, HIGH);
}
Here's a helpful post on the sparkfun pro micro atmega32u4:
The Pro Micro is an ATmega32U4-based board made by Sparkfun. It's a Leonardo clone, and uses the same bootloader. Compared to the Leonardo it's missing pins 11, 12, 13, A4 and A5.
...
Quirks to the Arduino 32u4 implementation in general: there's no Timer2 so any library or sketch that uses it won't work, the bootloader's auto-reset process can be overwhelmed by a bad sketch which can require you to manually reset to get a new sketch in (or in worst conditions you might need to use an ISP to reburn the bootloader but I think that's really rare). The various 'standard pins' are all moved around, eg. SPI is on different pins, I2C on different pins. The USB libraries take a huge whack of space so out of your 32kB you lose 4kb to the bootloader and another 3kb in 'overhead' (i.e. any sketch you write will be 3kb bigger because of the USB libraries). The TX/RX LEDs are (IMHO) handled a bit wierd and one of them is the hardware SPI SS pin, so any libraries that are hardwired to use the hardware SPI SS pin won't work.
...
Quirks specific to the Pro Micro: it's missing a few digital pins that appear on the Leonardo (I think it's 11, 12, 13 that are missing). I know they've released a newer version than mine, but if you have an older version, the bootloader is not compatible with Leonardo. There are errors on the schematic that may or may not be fixed now, relating to the assignment of analog pins on the digital side (eg. A8 may or may not be D8, etc).
Sparkfun has a programming for SPI tutorial using the Arduino SPI library, which points out steps my current code omits, including:
If you’re using the SPI Library, you must use the provided SCK, MOSI and MISO pins, as the hardware is hardwired to those pins. There is also a dedicated SS pin that you can use (which must, at least, be set to an output in order for the SPI hardware to function), but note that you can use any other available output pin(s) for SS to your slave device(s) as well.
I plan to implement these recommendations and continue to troubleshoot.
If anyone has experience or suggestions in using SPI with the Sparkfun Pro Micro atmega32u4 5V/16MHz or any comments please reply 