Using Arduino and CS458001 10K SPI? Serial Bus Dig

Using Arduino and CS458001 10K SPI? Serial Bus Digital Potentiometer:

Im having problems with this particular chip. I have followed the tutorial and tried to adapt it for this particular chip with no luck. http://www.arduino.cc/en/Tutorial/SPIDigitalPot

these are two sheets on the chip

http://www.c-stamp.com/Documents/Documentation/CS45800Xm1.pdf http://www.c-stamp.com/Documents/Documentation/CS458001d1.pdf

if anyone could help me in anyway it would be super appreciated. Thanks :D

This is my current code:

#define DATAOUT 11//MOSI
#define DATAIN 12//MISO - not used, but part of builtin SPI
#define SPICLOCK 13//sck
#define SLAVESELECT 10//ss

byte resistance=0;
byte puppy = 136; //value to transmit, binary 10001000
byte mask = 1; //our bitmask
byte bitDelay = 100;

char spi_transfer(byte data)
{
for (mask = 00000001; mask>0; mask <<= 1) { //iterate through bit mask
if (puppy & mask){ // if bitwise AND resolves to true
digitalWrite(DATAOUT,HIGH); // send 1
Serial.println(“1”);
}
else{ //if bitwise and resolves to false
digitalWrite(DATAOUT,LOW); // send 0
digitalWrite(SPICLOCK,LOW);

Serial.println(“0”);
}
delayMicroseconds(bitDelay); //delay
}
for (mask = 00000001; mask>0; mask <<= 1) { //iterate through bit mask
if (data & mask){ // if bitwise AND resolves to true
digitalWrite(DATAOUT,HIGH); // send 1
digitalWrite(SPICLOCK,HIGH);
Serial.println(“1”);
}
else{ //if bitwise and resolves to false
digitalWrite(DATAOUT,LOW); // send 0
digitalWrite(SPICLOCK,HIGH);
Serial.println(“0”);
}
delayMicroseconds(bitDelay); //delay
}
Serial.println("--------");
}

void setup()
{
Serial.begin(9600);
byte i;
byte clr;
pinMode(DATAOUT, OUTPUT);
pinMode(DATAIN, INPUT);
pinMode(SPICLOCK,OUTPUT);
pinMode(SLAVESELECT,OUTPUT);
digitalWrite(SLAVESELECT,HIGH); //disable device
// SPCR = 01010000
//interrupt disabled,spi enabled,msb 1st,master,clk low when idle,
//sample on leading edge of clk,system clock/4 (fastest)
SPCR = (1<<SPE)|(1<<MSTR);
clr=SPSR;
clr=SPDR;
delay(10);

write_pot(255);

}

byte write_pot(int value)
{
digitalWrite(SLAVESELECT,LOW);
//2 byte opcode
spi_transfer(value);
digitalWrite(SLAVESELECT,HIGH); //release chip, signal end transfer
}

void loop()
{
delay(2000);
write_pot(0);

delay(2000);
write_pot(255);

}

any advice/help? Im getting no where with this :confused:

I got it working now, if anyone wants to know how reply here or msg me :D