/*          a
          _____
        |       |
     f  |       |  b
        |   g   |
          _____
        |       |
     e  |       |  c
        |       |
          _____ 
            d

// prvo število je lahko 1 ali 0, ni važno, ampak popravi hexadec zapis

 / g f e d c b a| rez   | stev
 0 0 1 1 1 1 1 1| 0x3F  | 0
 0 0 0 0 0 1 1 0| 0x06  | 1
 0 1 0 1 1 0 1 1| 0x5B  | 2
 0 1 0 0 1 1 1 1| 0x4F  | 3
 0 1 1 0 0 1 1 0| 0x66  | 4
 0 1 1 0 1 1 0 1| 0x6D  | 5
 0 1 1 1 1 1 0 1| 0x7D  | 6
 0 0 0 0 0 1 1 1| 0x07  | 7
 0 1 1 1 1 1 1 1| 0x7F  | 8
 0 1 1 0 0 1 1 1| 0x67  | 9

// common pin v 7 segment display
skupna anoda - anoda vseh ledic (-)
skupna catoda - catoda vseh ledic (+)

*/

char digits[] = {0x3F, 0x06, 0x5B, 0x4F, 0x66, 0x6D, 0x7D, 0x07, 0x7F, 0x67};
char pin[] = {9, 10, 2, 3, 4, 8, 7};
int stev = 0;

void setup() {
  for (int x = 0; x < 7; x++){
    pinMode(pin[x], OUTPUT);
  }


  while (stev < 10) {
    /* // check if its wired correctly
    for (int x = 0; x < 7; x++){
      digitalWrite(x, HIGH);
      delay(500);
    }*/
    static int y = 0;
    int i = digits[y];
    for (int x = 0; x < 7; x++){
      int temp = i & 0x01; // iz hexadec nam vrne izpis zadnjega bita iz hexadec stevila v digits (i)
      digitalWrite(pin[x], temp); 
      i = i >> 1; // izpiše
      // 0 1 1 0 0 0 0 1 - i & 0x01 -> 1
      // i >> 1
      // 0 0 1 1 0 0 0 0 - i & 0x01 -> 0
      // i >> 1
      // 0 0 0 1 1 0 0 0 - i & 0x01 -> 0
      // i >> 1
      // 0 0 0 0 1 1 0 0 - i & 0x01 -> 0
      // i >> 1
      // 0 0 0 0 0 1 1 0 - i & 0x01 -> 0
      // i >> 1
      // 0 0 0 0 0 0 1 1 - i & 0x01 -> 1
      // i >> 1
      // 0 0 0 0 0 0 0 1 - i & 0x01 -> 1
    }
    y ++, stev ++;
    delay(500);
  }
}

void loop() {
  for (int x = 0; x < 7; x ++) {
    digitalWrite(pin[x], LOW);
  }
}