Here's the sketch I used to check my ladder:
char pins[]={34,35,36,37,38,39,40,41};
void writeval(int v){
for(int i=0;i<sizeof(pins);i++){
digitalWrite(pins[i],v&1);
v>>=1;
}
}
void setup() {
Serial.begin(115200);
analogReadResolution(12);
for(int i=0;i<sizeof(pins);i++)
pinMode(pins[i],OUTPUT);
}
void loop() {
int l=0;
for(int i=0;i<(1<<(sizeof(pins)));i++){
writeval(i);
delay(10);
int m=analogRead(0);
printf("%d : %d d=%d\n",i,m,m-l);
if(m<l)printf("!!!!!!ERROR!!!!!!!!!! non-monotonic\n");
l=m;
}
delay(2000);
}
If you get errors then just swap the resistors around until they go away.