//   |x| |a| |b| |c| |d| |e| |f| |g|  |Heksa|
//0: |0| |1| |1| |1| |1| |1| |1| |0|  |0x7E |
//1: |0| |0| |1| |1| |0| |0| |0| |0|  |0x30 |
//2: |0| |1| |1| |0| |1| |1| |0| |1|  |0x6D |

int stRandom;
int count;

int digit[] = {0x7E, 0x30, 0x6D, 0x79, 0x33, 0x5B, 0x5F, 0x70, 0x7F, 0x7B};


/***** pinMode()    *******/

/*

void setup() {
  pinMode(7, INPUT_PULLUP);
  for(int x = 0; x < 7; x++) {
    pinMode(x, OUTPUT);
  }
  randomSeed(analogRead(A0));
  count = random(1, 10);
}

void loop() {
  int k = digit[count];
  if(digitalRead(7) == LOW && count > 0){
    count --;
    delay(300);
  }

  for(int x = 0; x < 7; x++){
    int temp = k & 0x01;
    digitalWrite(x, temp);
    k = k >> 1;
  }

}

*/

/**** REGISTRI *****/




void setup() {
  DDRD = 0x7F;
  PORTD = 1 << PD7; // PORTD |= 0x80; //PULL_UP
  randomSeed(analogRead(A0));
  count = random(1, 10);
}

void loop() {
  bool vhod = PIND & 0x80; //filter da dobimo samo pin 7

  if(vhod == LOW){
    count --;
    delay(300);
    if(count <= 0) count = 0;
  }

  PORTD = digit[count] | 0x80; // filter da dobimo vse pine razn 7
}