// 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

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

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 displayNum(int num){
  switch(num){
    case 0:
      n0();
    break;

    case 1:
      n1();
    break;

    case 2:
      n2();
    break;

    case 3:
      n3();
    break;

    default:
    allOffWrite();
    break;

  }
  

  

}

  void setup() {
for (int i=2; i<10; i++){
        pinMode(i,OUTPUT);
    }


}

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

n0();
delay(1500);
n1();
delay(1500);
n2();
delay(1500);
n3();
delay(1500);
n4();
delay(1500);
n5();
delay(1500);
n6();
delay(1500);
n7();
delay(1500);
n8();
delay(1500);
n9();
delay(1500);
*/

displayNum(2);
delay(1500);
displayNum(8);
delay(1500);  

for (int j=0; j<4; j++){
  displayNum(j);
  delay(500);
}

}