shiftout 64 bits of data

Dear experts,
i’m new for this forum and beg you to teach me about shiftout in this first post :).
the case is, i have 8 * 74HC595 ICs, i want 64 bits output as the result to control 64 leds at a time.

if i have int variable contain 8 * 8 bits data in array, how to shiftout these data?
is repeating shiftout of each data correct? as below:

/CODE/
int myData[8]={11,22,33,44,55,66,77,88};
digitalWrite(latchPin, 0);
for(int i=0;i<=7;i++)
{
shiftOut(dataPin, clockPin, myData*);*
}
digitalWrite(latchPin, 1);
/END/
Thanks,

looks fine to me

You may want to consider using the technique from the link below if you are running eight SR's.

This has some code that uses SPI to run those same SRs, may help if you run into limits / flicker, etc.

http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1260443886

Good luck

heh I kinda took over that thread

using the shift out function should be fine if each led has its own output (course the SR cant handle all 8 on at once you need transistors, or super dim led's that will be uneven)

where I ran into speed issues was in scanning 1024 leds like a screen, you could also do scanning which would drop your sr count down to 2, people scan through 8x8 matrices all the time (thats why I had to be a jerk and scan through 16 of them lol)

Thanks for the replies,
@marklar: i promise to learn SPI also :slight_smile:
@Osgeld: yes,each led has its own current supply from transistor.

i just confused, i saw some guys using shift operator (>>8) when shifting 16 bit of data for the HIBYTE.

if i modify my code as below, is it correct (similar result)?

/CODE/
for(int i=0;i<=7;i++)
{
shiftOut(dataPin, clockPin, myData_>>(i*8));_
}
/END/
thanks,

++i takes the current number runs through the loop THEN adds 1

i++ adds one then runs the loop

if your using i as a counter you have to keep this in mind , ++i would be the safer route, as i++ pretty much starts your counter at 1

thanks for the advice Osgeld.

my point is in blue hilite part below:

/CODE/
for(int i=0;i<=7;i++)
{
shiftOut(dataPin, clockPin, myData_>>(i8)[/color][/b]);_
__
}*__
/END/
thanks,

if i modify my code as below, is it correct (similar result)?

Short answer - No!

If you interface to a single 16 bit shift-register (or two 8-bit shift registers) you could fit all data in a 16 bit variable and do as follows:

  unsigned int data;
  
  digitalWrite(latchPin, LOW);
  shiftOut(dataPin, clockPin, LSBFIRST, (byte)data); // shift out low byte
  shiftOut(dataPin, clockPin, LSBFIRST, (byte)(data>>8)); // shift out high byte
  digitalWrite(latchPin, HIGH);

Using an array as you do is just fine - keep it as is.

In your code, myData is defined as an array of eight 16-bit values. Since you only need eight 8-bit values you should change the data type from int (16-bit) to byte (8-bit).

thank you BenF for your great answer, i got it :-bd.