jcmusix:
I have wired up two tpic6b595's to an Arduino UNO I think they are properly wired according to instructions.
But we don't know, because we don't have a picture or schematic of it.
jcmusix:
The problem is that if I turn on (led #3 for example) it turns on #3 led from both chips. I would like to be able to turn on leds 1-16 and have number 1-8 only turn on from the first shift register while 9-16 turn on led's from the second shift register.
OK, so you attached the code. That is very inconvenient. Let's look at it here (the way the instructions tell you to):
/*
Shift Register Example
for TPIC6B595 shift register by Jens C Brynildsen
This sketch turns reads serial input and uses it to set the pins
of a TPIC6B595 shift register.
Hardware:
* TPIC6B595 shift register attached to pins 7, 8, 11 and 12 of the Arduino,
as detailed below.
* LEDs attached to each of the outputs of the shift register
Based on the example created 23 Mar 2010 by Tom Igoe
*/
//Pin to clear the register
const int clearPin = 7;
//Pin connected to latch pin (RCK) of TPIC6B595
const int latchPin = 8;
//Pin connected to clock pin (SRCK) of TPIC6B595
const int clockPin = 12;
////Pin connected to Data in (SER IN) of TPIC6B595
const int dataPin = 11;
int counter = 0;
int numLedsInUse = 8;
void setup() {
//set pins to output because they are addressed in the main loop
pinMode(clearPin, OUTPUT);
pinMode(latchPin, OUTPUT);
pinMode(dataPin, OUTPUT);
pinMode(clockPin, OUTPUT);
Serial.begin(9600);
Serial.println("*");
// Always start by setting SRCLR high
digitalWrite( clearPin, HIGH);
// delay a little and then set
delay(10);
}
void loop() {
// Display LED's running
digitalWrite( clearPin, HIGH);
if( counter >= (numLedsInUse-1) ){
counter = 0;
} else {
counter++;
}
// write to the shift register with the correct bit set high:
registerWrite(counter, HIGH);
delay( 1000);
}
// This method sends bits to the shift register:
void registerWrite(int whichPin, int whichState) {
// Serial.println(whichPin);
// the bits you want to send
byte bitsToSend = 0;
// write number as bits
bitWrite(bitsToSend, whichPin, whichState);
// turn off the output so the pins don't light up
// while you're shifting bits:
digitalWrite(latchPin, LOW);
// Serial.println(bitsToSend);
// Serial.println("_");
// shift the bits out
shiftOut(dataPin, clockPin, MSBFIRST, bitsToSend);
// turn on the output so the LEDs can light up:
digitalWrite(latchPin, HIGH);
}
Hmmm. Well, it is very confused code, but you are sending 8 bits and latching them. When you do it a second time, the 8 bits from the first register - if you have chained them correctly - go to the second and it displays what was previously on the first.
If you want to display 16 bits, you have to send (the correct) two lots of 8 bits so they ripple through the two registers, before the latch puts them to the output. You do not (need to) turn off the outputs because the outputs correspond to what is in the latches, not the ripple registers.