// By Nissanka MD COTM

  #define pinDp 2
  #define pinC  3
  #define pinD  4
  #define pinE  5
  #define pinG  6
  #define pinF  7
  #define pinA  8
  #define pinB  9
  #define pinComDig1  12
  #define pinComDig2  13

  bool A;
  bool B;
  bool C;
  bool D;
  bool E;
  bool F;
  bool G;
  bool Dp;

  int delayDigitDisplay = 500;

  void writeDisplay(){
    digitalWrite(pinA,A);
    digitalWrite(pinB,B);
    digitalWrite(pinC,C);
    digitalWrite(pinD,D);
    digitalWrite(pinE,E);
    digitalWrite(pinF,F);
    digitalWrite(pinG,G);
    digitalWrite(pinDp,Dp);

  }


  void allOff(){
    A=LOW;
    B=LOW;
    C=LOW;
    D=LOW;
    E=LOW;
    F=LOW;
    G=LOW;
    Dp=LOW;
    //writeDisplay();
  }

  void allOn(){
    A=HIGH;
    B=HIGH;
    C=HIGH;
    D=HIGH;
    E=HIGH;
    F=HIGH;
    G=HIGH;
    //Dp=HIGH;
    //writeDisplay();
  }

  void allOnWrite(){
    allOn();
    writeDisplay();
  }

  void allOffWrite(){
    allOff();
    writeDisplay();
  }

  void n1(){
    allOff();
    B=HIGH;
    C=HIGH;
    writeDisplay();
  }

  void n2(){
    allOn();
    C=LOW;
    F=LOW;
    writeDisplay();
  }

  void n3(){
    allOn();
    E=LOW;
    F=LOW;
    writeDisplay();
  }

  void n4(){
    allOn();
    A=LOW;
    D=LOW;
    E=LOW;
    writeDisplay();
  }

  void n5(){
    allOn();
    B=LOW;
    E=LOW;
    writeDisplay();
  }

  void n6(){
    allOn();
    B=LOW;
    writeDisplay();
  }

  void n7(){
    allOff();
    A=HIGH;
    B=HIGH;
    C=HIGH;
    writeDisplay();
  }

  void n8(){
    allOn();
    writeDisplay();
  }

  void n9(){
    allOn();
    E=LOW;
    writeDisplay();
  }

  void n0(){
    allOn();
    G=LOW;
    writeDisplay();
  }

  void Err(){
    allOn();
    B=LOW;
    C=LOW;
    writeDisplay();
  }



  void displayDigit(int digit){

    allOffWrite();

    switch(digit){
      
      case 0:
        n0();
      break;

      case 1:
        n1();
      break;

      case 2:
        n2();
      break;

      case 3:
        n3();
      break;

      case 4:
        n4();
      break;

      case 5:
        n5();
      break;

      case 6:
        n6();
      break;

      case 7:
        n7();
      break;

      case 8:
        n8();
      break;

      case 9:
        n9();
      break;

      default:
      Err();
      break;

    }

  }

  void displayNumber(int Dig1,int Dig2){
    digitalWrite(pinComDig1, HIGH);  //off display1
    digitalWrite(pinComDig2, HIGH);  //off display1
    displayDigit(Dig1);
    digitalWrite(pinComDig1, LOW);  // on display1
    delay(delayDigitDisplay);
    digitalWrite(pinComDig1, HIGH); //off display1
    allOffWrite();

    displayDigit(Dig2);
    digitalWrite(pinComDig2, LOW);  // on display1
    delay(delayDigitDisplay);
    digitalWrite(pinComDig2, HIGH);  //off display1
    allOffWrite();

  }
  

  



  void setup() {
  for (int i=2; i<14; i++){
          pinMode(i,OUTPUT);
      }
    digitalWrite(pinComDig1, LOW);
    digitalWrite(pinComDig2, LOW);

  }

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

  displayNumber(3,4);



  }