// inslude the SPI library: #include // set pin 10 as the slave select for the digital pot: const int slaveSelectPin = 10; void setup() { delay(5000); // set the slaveSelectPin as an output: pinMode(slaveSelectPin, OUTPUT); // initialize SPI: SPI.begin(); digitalPotWrite(10); delay(5000); digitalPotWrite(20); delay(5000); digitalPotWrite(30); delay(5000); } void loop() { digitalPotWrite(40); delay(1000); } void digitalPotWrite(int rabbits) { // take the SS pin low to select the chip: digitalWrite(slaveSelectPin, LOW); // send in the address and value via SPI: // SPI.transfer(address); SPI.transfer(rabbits); // take the SS pin high to de-select the chip: digitalWrite(slaveSelectPin, HIGH); }