#include "pico/stdio.h"
#include "pico/stdlib.h"

uint trn[] = {
  0x3f, // 0
  0x06, // 1
  0x5b, // 2
  0x4f, // 3
  0x66, // 4
  0x6d, // 5
  0x7d, // 6
  0x07, // 7
  0x7f, // 8
  0x6f  // 9
};

int main() {
    const uint LED_PIN = PICO_DEFAULT_LED_PIN;
    gpio_init(LED_PIN);
    gpio_set_dir(LED_PIN, GPIO_OUT);

    for (uint i=0; i<8; i++)
    {
      gpio_init(i);
      gpio_set_dir(i, GPIO_IN);
    }

    for (uint i=8; i<20; i++)
    {
      gpio_init(i);
      gpio_set_dir(i, GPIO_OUT);
    }

    uint a = 0;
      
    while (true) {
      uint n = 0;    
      for (uint i=0; i<8; i++)
      {
        uint bit = gpio_get(i); 
        n += bit << i;
        
      }

      if (n != a) { printf("%d\n", n); }
      a = n;

      uint d1 = a % 10;
      uint s1 = trn[d1];

      gpio_put(16, 1);

      for (uint i=0; i<8; i++)
      { 
        uint bit = (s1 >> i) % 2;
         
        gpio_put(8+i, !bit);
      }

    }
}
BOOTSELLED1239USBRaspberryPiPico©2020RP2-8020/21P64M15.00TTT