The key is "multiplex" for a reduction of the number of pins. 10 switches or LED can be addressed by 5+2=7 pins, in 5 rows of 2
columns. Or with 3+4 pins for a 3*4 matrix, for up to 12 items. Additional hardware is required for addressing rows and columns of the matrix.