Weird(?) behaviour on SPI with digipot MCP4131

My first project. First time using an Arduino.

I'm trying to use an arduino to convert the signals from my car's entertainment bus (for the steering wheel control buttons) to something my aftermarket radio can understand.

In order to do that I'm using a digipot (MCP4131) which communicates with the arduino through SPI

I've connected the pins according to this tutorial

On the digipot, I haven't connected anything to pin 5,6,7 and am measuring the resistance across 7 and 6.

I'm using this code:

#include <SPI.h>

int CS= 10; //chip select

void setup()
{
pinMode (CS, OUTPUT);
SPI.begin();
}

void loop()
{
digitalWrite(CS, LOW);
SPI.transfer(0);
SPI.transfer(2);
digitalWrite(CS, HIGH);
}

However this isn't doing anything. Pin 10 (CS) isn't being shorted to ground. However, I noticed that shorting the Pin 1 of the digipot to ground worked and I could get my desired resistance. So I wrote this code:

#include <SPI.h>

int EP= 9; //enabling pin
int CS= 10; //chip select

void setup()
{
pinMode (CS, OUTPUT);
pinMode (EP, OUTPUT); 
SPI.begin();
}

void loop()
{
digitalWrite(EP, LOW);
digitalWrite(CS, LOW);
SPI.transfer(0);
SPI.transfer(2);
digitalWrite(CS, HIGH);
digitalWrite(EP, HIGH);
}

and connected pin 1 of the digipot to pin 9 (EP) instead of pin 10 (CS) of the arduino. This works. I gathered then that pin 10 (CS) on my arduino must not be working properly but the thing is, if I remove pin 10 (CS) from the code, it still doesn't work!

I'm very confused as to why I need the extra pin 10 (CS) lines in order for the digipot to work. In fact, there is nothing connected to pin 10 (CS). But if I remove it from the code the digipot stops working.

Any ideas as to why this is happening?

Why would you wire pin 5 and 7 the normal way (5V and GND) and use an analogRead on pin 6 to see the voltage and thus deduct the resistance ?

J-M-L:
Why would you wire pin 5 and 7 the normal way (5V and GND) and use an analogRead on pin 6 to see the voltage and thus deduct the resistance ?

Being a beginner I didn't want to put more code into the arduino. I just measure the resistance with an external multimeter. In the end, I only need the resistance so no point in running pin 5 and 7 the normal way anyway.

But that still doesn't explain why the first code isn't working.

There is no need for more code, just two wires to define The high and low points of your resistor so that you have the right readout.