A way of storing and Shifting out 12 bit matrix?

Hi, i have just learned about Shift Registers, and have got them working fairly well, the only problem is i want to control 12 LEDs, to a specific bit pattern, is there any way i can store them and shift them out in one operation?

Ie

Matrix {
{B101010111101,B1011101010101,B101010101010,B110101101010},.......ETC) // I dont think this can be done like this, is there any way?

ShiftOut(.....,.....,....,....,Matrix[0][0])

What is the proper way to do this?

The proper way is to use hex numbers for your constants and use a loop to read the bytes from the array for shifting out.

Yes thats how i do it with Bytes, but the problem is i want to store 12 bit numbers in the matrix and them shift out the 12 bits to the shift registers. How can i do this?

Write your own shift out function that toggles the clock line 12 times. How are you shifting out at the moment?

digitalWrite(latchPin, LOW);
 
   
shiftOut(dataPin, clockPin, LSBFIRST, 0x1C); 


digitalWrite(latchPin, HIGH);

This is what im currently using, it shifts one Byte at a time.

Replace the shift out function with your own loop that goes round 12 times. Each time the clock is set high ( or low ) depending on what polarity you want. The. The data line is set to the value of the least significant bit, then the clock is restored. Finally the data is shifted one place to the right with the shift operator >>

Thanks for the guidance it makes sense, but there is one problem, i know that timing comes into play here, and im not really sure about the correct clock-data timing for the 74HC595. Is there any chance you can point me an existing Shiftout Function that i could modify?

adilmalik:
Thanks for the guidance it makes sense, but there is one problem, i know that timing comes into play here, and im not really sure about the correct clock-data timing for the 74HC595. Is there any chance you can point me an existing Shiftout Function that i could modify?

The 74HC595 can clock in data up to 20MHz so should be no need to worry about timings on an arduino with 16MHz clock speed. Just clock the data out as fast as you can.
EDIT: Looking at the shiftOut function for the SAM chip (Arduino Due) and it does not limit the speed. Not sure if this would break shiftOut to a 74HC595 as I assume it would be to fast?

i know that timing comes into play here,

Then you know wrong.

:zipper_mouth_face: Must have misunderstood the Arduino Shift Out example them. Anyhow ill be giving this a go and posting my code here. Thanks Grumpy Mike

To notate binary constants use the 0b11010101010 notation.
Ditto 0xFE5 for hexadecimal.

The B01110111 notation is actually a set of 510 #defines in the
Arduino sytem (binary.h), and not a C language feature, and its clearly pointless
as 0b01110111 notation exists and is more general (not limited to 8 bit
values).