SLAAEC7 September 2024
The Connected Diode Matrix example demonstrates how to use a matrix format to reduce the number of necessary GPIO pins when using six or more LEDs. This specific example uses nine LEDs and six GPIOs to form and control a 3 × 3 LED matrix. The matrix format creates a grid that uses two GPIOs per LED (or diode). This format is especially useful when creating a sign or display out of LEDs. The GPIO pins for the LED matrix are divided into row and column pins. When the row pins connect the cathodes of the LEDs, as Figure 1-1 shows, the matrix is a common row cathode. Common row anode is when the row pins connect the anodes of the LEDs. Depending on the configuration of the LEDs in the LED matrix, the row and column pins are set to active high or active low. For this subsystem example, the row pins are active low and the column pins are active high. For the LED matrix to function properly, the LEDs in the matrix must be controlled one row at a time. The application code for this example uses a state machine to cycle continuously through the rows to turn the LEDs on and off.