SPI MCP23S08 to Arduino: strange stop/start behaviour I have built an Arduino minimal breadboard circuit to test some parts I recently bought and I successfully managed to get the I2C MCP23008 working perfectly with LEDs and an LCD display.
However I have just recently tried to use the SPI version of the same chip with some really odd results. I have tried searching for code examples and libraries, but struggled to get anything working.

So I studied the datasheet to create the following code to flash an LED, however the flashing seems to work only briefly and then stops. Sometimes it stops and then stays lit randomly.

// inslude the SPI library:
#include &lt;SPI.h&gt;
const int chipSelect = 10;

void setup() {
  // initialize SPI:
  SPI.begin();

  pinMode(chipSelect, OUTPUT);
  
  // set the chipSelect as an output:
  digitalWrite(chipSelect, HIGH);

  sendCommand(0x00, 0x00);
}


void sendCommand(int address,int data) {
  digitalWrite(chipSelect, LOW);
  //  send in the address and value via SPI:
  delay(1);
  
  // SPI addressing 0x40 with A0 and A1 set to ground and R/W bit set to output
  SPI.transfer(0x40); 
  SPI.transfer(address);
  SPI.transfer(data);
  delay(1);
  
  // take the chipSelect pin high to de-select the chip:
  digitalWrite(chipSelect, HIGH);
}

void loop() {
  sendCommand(0x09,0xff);
  delay(1000);
  sendCommand(0x09,0x00);
  delay(1000);
}

I have a couple of these devices and they both came from a supplier on eBay. I would like to validate my code before I suspect that the devices are dodgy and are not a genuine part.
Can anyone help me validate my code, or has anyone had a similar experience with the SPI bus and other devices not behaving properly?
Edit
Could it be due to the length of my wires to the Arduino?
I have figured it out, lesson learned. I should have also drawn how my circuit connects to the Arduino, this would have probably then become obvious to me and everyone else. 

Basically I had MOSI -> MOSI and the same with MISO -> MISO, rather than crossing them MOSI -> MISO respectively.

Circuit working fine now duh!

Face-palm!