// Display 0000 to 9999 in loop with dealy
// work done 02-03-24
void setup() {
  #define MAX 50

  // put your setup code here, to run once:
  volatile char *dirf,*dirk,*dira,*dirc;
  volatile char *outf,*outk,*outa,*outc;
  volatile long a[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x67};
  volatile long b[]={0xBF,0x86,0xDB,0xCF,0xE6,0xED,0xFD,0x87,0xFF,0xE7};
  volatile long i,j=0,k=0,l=0,m=1,lop1=0,lop2=0,lop3=0;
  dirf=0xFF,dirk=0xFF,dira=0xFF,dirc=0xFF;
  dirf = 0x30; outf = 0x31; 
  dirk = 0x107; outk = 0x108;
  dira = 0x21; outa = 0x22;
  dirc = 0x27; outc = 0x28;
  
  for(i=0;i<10;i++)//0001 to 0009
  {

  *outf=a[l];
  *outk=a[k];
  *outa=a[j];
  *outc=a[i];
  delay(MAX);
  }
  j=1;
  //--------------------
  while(lop1<9)
  {
  for(i=0;i<10;i++)//0010 to 0099
  {

  *outf=a[l];
  *outk=a[k];
  *outa=a[j];
  *outc=a[i];
  delay(MAX);
  }
  j=j+1;
  lop1++;
  }
  //---------
  
  k=1;
  
  for(lop2=0;lop2<9;lop2++)
  {
    lop1=0;
    j=0;
  while(lop1<10)
  {
  for(i=0;i<=9;i++)//0100 to 0999
  {

  *outf=a[l];
  *outk=a[k];
  *outa=a[j];
  *outc=a[i];
  delay(MAX);
  }
  j=j+1;
 
  lop1++;
  }
  k=k+1;
  }
//-------------------------------------1000 to 9999
l=1;
k=0;
j=0;
  for(lop3=0;lop3<9;lop3++)//1000 to 9999
  {
    j=0;k=0;

  for(lop2=0;lop2<=9;lop2++)
  {
    lop1=0;
    j=0;
  while(lop1<10)
  {
  for(i=0;i<=9;i++)//0100 to 0999
  {

  *outf=a[l];
  *outk=a[k];
  *outa=a[j];
  *outc=a[i];
  delay(MAX);
  }
  j=j+1;
 
  lop1++;
  }
  k=k+1;
  }
  l=l+1;
  }
  }
  
  

  

void loop() {
  // put your main code here, to run repeatedly:

}