I have a led-matrix that is common anode in row-wise and common cathode in column-wise. I need to glow the matrix in the shape of a square(first row && last row && first column && last column) , but I was not able to do it. I was able to glow the first and last row separately and first and second column separately)
void first_last_row();
void first_last_column();
int Led_Row_Pins[] = { 2 , 3 , 4 , 5 , 6 } ; // Anode pins are shorted in row_wise_manner
int Led_Column_Pins[] = {8 , 9 , 10 , 11 , 12} ; // Column Pins are shorted in column_wise_manner
int Loop_Count = 5 ;
int Wait_Time_On = 1000 ;
int Wait_Time_Off = 500 ;
int i = 0 ;
int j = 0 ;
int state = 1 ;
void setup() {
for( i = 0 ; i < Loop_Count ; i++ ){ // Anode Pins are connected in row_wise manner and are made LOW so that they dont conduct
pinMode(Led_Row_Pins[i],OUTPUT);
digitalWrite(Led_Row_Pins[i],LOW);
pinMode(Led_Column_Pins[i],OUTPUT); // Cathode Pins are connected in column_wise manner and are made HIGH so that they dont conduct
digitalWrite(Led_Column_Pins[i],HIGH);
}
}
void loop() {
first_last_row();
delay(1000);
first_last_column();
}
void first_last_row()
{
for( i = 0 ; i < Loop_Count ; i++ )// Led First And Last Row
{
for( j = 0 ; j < Loop_Count ; j++)
{
if( i == 0 || i == 4 )
{
digitalWrite(Led_Row_Pins[i],state); //Led_On_State
digitalWrite(Led_Column_Pins[j],!state);
}
}
}
}
void first_last_column()
{
for( j = 0 ; j < Loop_Count ; j++ )// Led First And Last Column
{
for( i = 0 ; i < Loop_Count ; i++)
{
if( j == 0 || j == 4 )
{
digitalWrite(Led_Row_Pins[i],state);// Led_On_State
digitalWrite(Led_Column_Pins[j],!state);
}
}
}
}
I need the first row and the last row and first column and last column led glow together so that it forms the shape of a square but I was able to glow them separately only first row and last row together and first column and last column.