8 way switch (MAX395) - trying to understand inputs and outputs

I'm using: http://datasheets.maxim-ic.com/en/ds/MAX395.pdf

I'm having a little trouble relating inputs to outputs. I would think that to turn on all of the switches I would pass it a 255 value through SPI.transfer() and to turn off all of the switches I would pass it a 0. However, actually testing it I get (switch states on right with switch 0 at the left, decimal value on left):

255: 10011100 0: 01001110 207: 11111011

I see little rhyme or reason to this.

Oh, and trying another identical switch..

255: 10111001

Does anyone have any insight into what could be going on and how I can fix it?

Does anyone have any insight into what could be going on and how I can fix it?

Yes it is right there in line 23 of your code, or is it line 24 I can't quite see.

Now if you want some real help then post the code and post a schematic of how you have it wired up.

Okay.

#include <SPI.h>

void setup() {
SPI.begin(); //initialize SPI
pinMode(10,OUTPUT); //CS
pinMode(11,OUTPUT); //DIN
pinMode(13,OUTPUT); //SCLK
digitalWrite(10,LOW); //drop CS low
SPI.transfer(255); //transfer data
digitalWrite(10,HIGH); //raise CS
}

void loop(){}

(Is Fritzing format generally appropriate for the schematic?)

MAX395.fzz (3.86 KB)

How are you measuring the state of the switches? Your diagram doesn't shows them being wired up at all.

Pete

I'm using a multimeter and measuring the resistance across the switch.

(Is Fritzing format generally appropriate for the schematic?)

Generally no. No everyone has it, and even if you do it is incredibly difficult to read. Unlike a real schematic.

I would try values of SPI.setDataMode() other than the default. http://arduino.cc/en/Reference/SPI

Well that did it, thanks.

How would you produce a proper schematic for sharing on this forum?

How would you produce a proper schematic for sharing on this forum?

Anything that produces real symbols.

So pencil and paper and photograph. General drawing package. Schematic layout application.

See this about reading one:- http://blog.makezine.com/archive/2011/01/reading-circuit-diagrams.html

Alright, that's doable. I have a little trouble converting between schematics (I can read and draw them) and wiring, though, so I wouldn't be surprised if that's frequently one of my problems, but I'm learning.

Thanks for your help.