The matrix is controlled by a micro-controller. For the above 16-button 4x4 matrix, 8 pins of the micro controller will…