I could get the desired output. However, this wont work for different output. for example if i wanna have 1024 decimal or "0000010000000000" i couldn't get the output even by one time "shiftOut(dataPin, clockPin, MSBFIRST,1024);" or repeating it twice .
I would be really appreciate it if someone could help me.
Thanks in advance.
Shiftout only sends 1bytes worth of data to the IC.
8bits worth, the next time you use shiftout, 8 more bits get shifted into the first register any bits previously store get shifted out to the 2nd register.
So the trick is to get the high/low values and send it in 2 lots (16bits)
int dataOut; // declare in pre-setup part of sketch
// then update in loop as needed:
dataOut = 0b1000000000111111;
// or
dataOut = 32831;
// then send it out:
digitalWrite(latchPin, LOW);
shiftOut(dataPin, clockPin, MSBFIRST, highByte (dataOut);
shiftOut(dataPin, clockPin, MSBFIRST, lowByte (dataOut);
digitalWrite(latchPin, HIGH);
Thanks a lot for your response CrossRoads.
I have a question .. if i use more than two 595, how should i change your code? for example for three 595 should it be like this?:
That will send the same byte twice, is that what you want?
If the three bytes are to be unique, you could put the data into a 32-bit unsigned long, and break out the 8-bit chunks from there. Or just use three unique bytes:
well i meant 32bit output generally(or even more). this solution is the one which cjdelphi also suggested. However, what interested me about your code which makes me to ask a question was this part of it :
highByte (dataOut); lowByte (dataOut);
that how this form could be used for more than 16 bit. so in this case for any length of bit i don't need to separate them in individual 8bit .