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?