With help from [efox29][1] I worked out to control the MAX5483, 10-bit digital potentiometer (data sheet [here][2]) with an arduino using SPI. Now how can I trigger more than one value?

I tried to do that with a simple for-loop, but it doesn't work. And even putting a delay seems to cause issues..


    #include <SPI.h> 
    const int csPin = 3;
    const int selPin = 2;  
    
    void setup() {
    
     SPI.begin();
     SPI.setBitOrder(MSBFIRST); //We know this from the Data Sheet
     SPI.setDataMode(SPI_MODE2);
    
     pinMode(csPin,OUTPUT); 
     digitalWrite(csPin, LOW);
    
     pinMode(selPin,OUTPUT);
     digitalWrite(selPin, HIGH); 
    
    }
        
    void loop()
    {     
        //"sweep" small range (from 1.7 to 2.1 KOhm)
        // 158 to 197
    //    
    //    for (int i=158; i < 211; i++){
    //    delay(1000);
    //    digitalPotWrite(i); //  
    //   } 
       
    digitalPotWrite(197); //  
    delay(100); // seems to cause issues.. without this line it works
       
    }
      
    void digitalPotWrite(int value) {
    digitalWrite(csPin, LOW);
    delay(1);
    byte command=0x0;
    byte byte0 = (value & 0x03) << 6;
    byte byte1 = (value & 0x3FC) >> 2;
    SPI.transfer(command);
    SPI.transfer(byte1);
    SPI.transfer(byte0);
    delay(1);
    digitalWrite(csPin, HIGH);
    }


  [1]: http://electronics.stackexchange.com/users/9409/efox29
  [2]: http://datasheets.maximintegrated.com/en/ds/MAX5481-MAX5484.pdf