user6227: I am able to control one shift register with this shift function:
void shift (int pin) {
  shiftOut(ds,shcp,MSBFIRST,pin);  
  digitalWrite(stcp,HIGH);        
  delay(100);
  digitalWrite(stcp,LOW);         
}

but when I move to 2 shift registers it does not add up.. how do I need to adapt this method to make it work with 2 shift registers when I am going from 8 leds to 16 leds?
My second register now just copies the first register.. I want the second register to continue instead of repeat

user2881: split the data into 2 bytes, and then send those, one after the other
void shift (int pin) {
  byte data1 = 0;//shift register 1
  byte data2 = 0;//shift register 2
  if( pin<8 )
    data1 = (1<<pin);
  else
    data2 = (1<<(pin-8));
  shiftOut(ds,shcp,MSBFIRST,data2);//note that you send the data for shift register 2 first
  shiftOut(ds,shcp,MSBFIRST,data1);
  digitalWrite(stcp,HIGH);        
  delay(100);//why wait this long?
  digitalWrite(stcp,LOW);         
}


user5131: It sounds like the primary issue is how you've connected the two shift registers.  You just need the bit shifting out of the first one to shift into the second one so they act, together, as one longer shift register.

The example pictured is described in full here, under the heading "Example 2":
http://arduino.cc/en/tutorial/ShiftOut
As Klaus mentioned, you want to first ShiftOut the byte you intend to wind up in the second resister, then ShiftOut the byte for the first register.  This will push your first byte through to the second register.

6227: <p>I am able to control one shift register with this shift function:</p>

<pre><code>void shift (int pin) {
  shiftOut(ds,shcp,MSBFIRST,pin);  
  digitalWrite(stcp,HIGH);        
  delay(100);
  digitalWrite(stcp,LOW);         
}
</code></pre>

<p>but when I move to 2 shift registers it does not add up.. how do I need to adapt this method to make it work with 2 shift registers when I am going from 8 leds to 16 leds?</p>

<p>My second register now just copies the first register.. I want the second register to continue instead of repeat</p>
 2881: <p>split the data into 2 bytes, and then send those, one after the other</p>

<pre><code>void shift (int pin) {
  byte data1 = 0;//shift register 1
  byte data2 = 0;//shift register 2
  if( pin&lt;8 )
    data1 = (1&lt;&lt;pin);
  else
    data2 = (1&lt;&lt;(pin-8));
  shiftOut(ds,shcp,MSBFIRST,data2);//note that you send the data for shift register 2 first
  shiftOut(ds,shcp,MSBFIRST,data1);
  digitalWrite(stcp,HIGH);        
  delay(100);//why wait this long?
  digitalWrite(stcp,LOW);         
}
</code></pre>
 5131: <p>It sounds like the primary issue is how you've connected the two shift registers.  You just need the bit shifting out of the first one to shift into the second one so they act, together, as one longer shift register.</p>

<p><img src="https://i.stack.imgur.com/VEEl6.gif" alt="Two serial shift registers"></p>

<p>The example pictured is described in full here, under the heading "Example 2":
<a href="http://arduino.cc/en/tutorial/ShiftOut" rel="nofollow noreferrer">http://arduino.cc/en/tutorial/ShiftOut</a></p>

<p>As Klaus mentioned, you want to first <code>ShiftOut</code> the byte you intend to wind up in the second resister, then <code>ShiftOut</code> the byte for the first register.  This will push your first byte through to the second register.</p>
