# how to rotate matrix scroll by 90 degrees in code

Hey guys...I have a 16 x 8 matrix scrolling and adding on 2 more 8 x 8 matrices to make a 32 x 8 matrix scroll.....however, the I have to physically rotate the matrices...how can you do it in code because its difficult for this to work with how the pinouts get placed.....my code is attached

Scroll_Across.ino (13.2 KB)

Just write down the columns as rows.

could you look at my code and explain where I would do that though please

I am on my iPad and it won't copy your code but I will try.

``````B00110011;
B11001111;
B00111000;
B01010101;
B11011100;
B11110000;
B00000000;
B00011100;
``````

Would be
B11010000;
B11000000;
And so on, each coloumn becomes a row. This rotates the pattern you se.

If you look at your code, it is using printLED(). In particular, it uses this line:

``````   int c = font8x8[(number * 7) + a];      // Index into character table to get row data
``````

All you need to do is to rewrite that line.

I'm sorry I don't follow.....how would you rewrite it

Sure.

``````   int c = (font8x8[(number * 7) + 0] & (1<<a))?0x80:0;      // Index into character table to get row data
c |= (font8x8[(number * 7) + 1] & (1<<a))?0x40:0;
c |= (font8x8[(number * 7) + 2] & (1<<a))?0x20:0;
c |= (font8x8[(number * 7) + 3] & (1<<a))?0x10:0;
c |= (font8x8[(number * 7) + 4] & (1<<a))?0x08:0;
c |= (font8x8[(number * 7) + 5] & (1<<a))?0x04:0;
c |= (font8x8[(number * 7) + 6] & (1<<a))?0x02:0;
c |= (font8x8[(number * 7) + 7] & (1<<a))?0x01:0;
``````

This rotates the display 90/270 degrees. Depending on your physical orientation, it may be right-side-left. In that case, switch 0x80 with 0x01; 0x40 with 0x02; ...

Sometimes its easier to just look at youyr hardware a different way and rewire it to match.
For example, here are two parts advertised as common cathode and common anode (from futurlec.com).
You can see that if you orient them so the common anodes are connected in rows going across and the common cathodes are connected in columns going up, they are the same functionally, with just different IO pins.
So you can use them interchangeably as long as you determine where the top left corner LED is for instance and connect your anode and cathode accordingly and follow suit for the rest of the pins.
For these parts for example:
common cathode, anode-pin9 and cathode-pin16 turns on the top left; common anode, anode-pin8 and cathode-pin9 turns on the top left.

Hey crossroads.....how ya been.....so I'm working on a new 32x8, my first one worked ok, all the matrices showed the same letter as it scrolled each one individually ...that was with my mega2560......but now I've got a 16x8 scrolling perfect.....I did just rotate the matrices physically....however I add on two more to make it 32x8 and the 3and 4 matrix are blank while 1and 2 scroll across.....I have them cascaded, all caps and resistors in place.....I'm using a nano this time.......ill paste my code in the morning....