int RowLed[7] = {2,3,4,5,6,7,8};        //Cathode connection points
int colLed[5] = {15,16,17,18,19};       //Anode connection Points

int Rpin = 6;                           //Total cathode pins
int cpin = 4;                           //Total anode pins

/* In arduino C first all the pins have to intialised whether input or output 
and this is done in the setup()

the intialisation of the pins is given below 

*/
void setup()                
{
  for (int i = 0; i <= Rpin; i++) 
  {
    pinMode(RowLed[i], OUTPUT);
  }
  
  for (int j = 0; j <= cpin; j++) 
  {
    pinMode(colLed[j], OUTPUT);
  }
}

/* First of all we need a function to turn all LEDS OFF
so alloff is a function to turn all LEDS OFF. 

THIS IS IMPORTANT SINCE for persistance of vision method we have to turn all leds off many times within a second.

The working of this is making the led reverse biased
or rowpins as LOW and column pins as high logic 
*/

void alloff() 
{
  //Loop to make the anode pin of all LED at 0V
  for (int i = 0; i <= Rpin; i++) 
  {
    digitalWrite(RowLed[i],LOW);
  }
  //Loop to make the cathode pin of all LED at +5V
  for (int j = 0; j <= cpin; j++) 
  {
   digitalWrite(colLed[j],HIGH);
  }

}  

/* ledon() is a function to turn a particular LED ON.
LED is specified as : ledon(row,column)

The working of this is making that led forward biased
or rowpins as High and column pins as Low logic 
*/


void ledon(int x, int y) 
{
  alloff();                             //first the turn off function is called to make sure that only that led is ON.
  digitalWrite(RowLed[x], HIGH);        //Makes the anode pin of the particular LED at +5 V
  digitalWrite(colLed[y], LOW);         //Makes the cathode pin of the particular LED at 0V 

}

/*   A function to display the letter E
    The corresponding leds are addressed here with a delay of 1 microsecond.   
*/

void L_E()
{
  
  ledon(0,0);delay(1);
  ledon(1,0);delay(1);
  ledon(2,0);delay(1);
  ledon(3,0);delay(1);
  ledon(4,0);delay(1);
  ledon(5,0);delay(1);
  ledon(6,0);delay(1);
  ledon(0,1);delay(1);
  ledon(0,2);delay(1);
  ledon(0,3);delay(1);
  ledon(0,4);delay(1);
  ledon(3,0);delay(1);
  ledon(3,1);delay(1);
  ledon(3,2);delay(1);
  ledon(3,3);delay(1);
  ledon(3,4);delay(1);
  ledon(6,0);delay(1);  
  ledon(6,1);delay(1);
  ledon(6,2);delay(1);
  ledon(6,3);delay(1);
  ledon(6,4);delay(1);

}
/*   A function to display the letter F
    The corresponding leds are addressed here with a delay of 1 microsecond.   
*/

void L_F()
{
  ledon(0,0);delay(1);
  ledon(1,0);delay(1);
  ledon(2,0);delay(1);
  ledon(3,0);delay(1);
  ledon(4,0);delay(1);
  ledon(5,0);delay(1);
  ledon(6,0);delay(1);
  ledon(0,1);delay(1);
  ledon(0,2);delay(1);
  ledon(0,3);delay(1);
  ledon(0,4);delay(1);
  ledon(3,0);delay(1);
  ledon(3,1);delay(1);
  ledon(3,2);delay(1);
  ledon(3,3);delay(1);
  ledon(3,4);delay(1);
  
}
/*   A function to display the letter Y
    The corresponding leds are addressed here with a delay of 1 microsecond.   
*/

void L_Y()
{
  ledon(0,0);delay(1);
  ledon(1,0);delay(1);
  ledon(0,4);delay(1);
  ledon(1,4);delay(1);
  ledon(2,1);delay(1);
  ledon(2,3);delay(1);
  ledon(3,2);delay(1);
  ledon(4,2);delay(1);
  ledon(5,2);delay(1);
  ledon(6,2);delay(1);
  
}
/* Here the function Combines the three Letters and repeats the action in a loop of 50 times */
void EFY()
{
  for(int i=0;i<=50;i++)
  {
    L_E();
  }
  alloff();
  delay(200);
  for(int i=0;i<=50;i++)
  {
    L_F();
  }
  alloff();
  delay(200);
  for(int i=0;i<=50;i++)
  {
   L_Y();
  }
  alloff();
  delay(200);
}

/*       loop() in arduino C is the fuction in which the action which is to be done countiously by the arduino is to be mentioned.It is similar to an infinite loop.
            Here I have called the EFY() so it repeatedly dispalys the name EFY.                                */
 
void loop() 
{
  EFY();
}