Hi, ALL; I´ve done some work with Direct Port Manipulation but never with PORTD and less D0 and D1. The best I have is an328p and as I want to try an 8 x 8 unicolour LED Matrix, I´ll need 16 I/O pins. ( I know I can use shift registers, but I´ll start without them).
Now, I´ll have to combine port pins like so:
int row[8] = {5, 6, 7, 8, 9, 10, 11, 12, };
int column[8] = {3, 4, A0, A1, A2, A3, A4, A5};
DDRB = B111111; // set all PORTB pins as OUTPUTs
DDRC = B111111; // set all PORTC pins as OUTPUTs
Not sure about PORTD? Can´t afford to brick my 328p!, surely need to reupload code.
DDRD = B11111110; // set all PORTD pins, except D0, as OUTPUTs.
// supposing D0 is an INPUT and D1 is an OUTPUT
I´ll be using PNP transistors for columns and rows, then:
void AllON()
{
PORTB = B100000;
PORTC = B000000;
PORTD = B00000110;
}
void AllOFF()
{
PORTB = B111111;
PORTC = B111111;//I know that by just switchng all columns ( or rows ), all LEDS go OFF, but…
PORTD = B11111110;
}
I haven´t written any code except for a 5 x 5 Matrix; just need to know if this works.
If so, I can do the rest, THANKS.