However, the LEDs cannot be switched independently: Six GPIOs are sufficient to switch 9 LEDs individually. Here these are column 2 (GPIO 2) and row 3 (GPIO 6), with which LED number 8 is switched on. To switch on any LED, the GPIO of the corresponding column must be set to HIGH signal, first and the GPIO of the corresponding row must be set to LOW signal afterwards. GPIO 2 is the current source, GPIO 5 is the current sink.īefore switching on the next LED, the initial state of Figure 7 should be restored. Here, GPIO 5 is set to LOW, which means that a current exits GPIO number 2 and flows through the resistor and LED 5 into GPIO number 5. Not until one of the GPIOs number 4, 5 or 6 goes LOW a current flows through the network. The diodes in column 3 (LEDs 2, 5, 8) have 5V applied to both the cathodes and the anodes, which means that no current can flow through any of the 3 LEDs. The LEDs in column 1 (LED 1, 4, 7) and column 3 (LED 3, 6, 9) are switched in reverse direction with 5V on the cathodes and 0V on the anodes. Here, this is the case for GPIO number 2. This is the better choice for the initial state of an LED matrix, because from this all LEDs remain switched off if GPIO number 1, 2 or 3 is now set to HIGH signal. Nothing changes when switching GPIO number 1 to LOW. Same as as at the beginning, all LEDs are finally switched off when GPIO number 5 is also set to a HIGH signal. 0V is present on both the anode and the cathode, which means that no current can flow through them. LEDs 5 and 6 are not shown in the equivalent circuit diagram. The equivalent circuit shows that only LED 4 is polarized in forward direction. In order to finally switch off LED 7 and only keep LED 4 ON, GPIO 6 must also be switched to HIGH level, i.e. Both are therefore at 0V level, with which LEDs 2 and 3 are switched in reverse direction and do not light up. The anode of LED 2 is connected to GPIO 2 via a series resistor, which also applies to the anode of LED3 and GPIO 3. The cathodes of LEDs 2 and 3 are also directly connected to GPIO number 4, which means that 5V are applied here. The equivalent circuit on the right shows that there is now 5V on the cathode of LED 1 - which is directly connected to GPIO 4 - and 2V on the anode, by what this diode is switched in reverse direction and no longer lights up. Now, GPIO number 4 is also set to HIGH level, which turns LED 1 OFF, while LEDs 4 and 7 remain ON. The three LEDs are connected in parallel as can be seen in the equivalent circuit to the right of the matrix. The resistor at GPIO number 1 forms a voltage divider with the three LEDs, polarized in forward direction. In the following, we assume that the logic level is 5V and the threshold voltage of the LEDs is 2V. The threshold voltage can be measured at the anodes that are directly connected to one another. This voltage depends on the type of LED used and is usually in the range of 1V to 3V. Consequently the threshold voltage drops across the LEDs. LOW signal, thus 0V, is on the cathodes (tip of the triangle with the dash at the diode symbol) of the three LEDs, the anodes (blunt side of the triangle) are connected to HIGH signal, i.e. Now GPIO number 1 is set to HIGH signal, with which LEDs number 1, 4 and 7 are connected in forward direction and so start to light up. There is a LOW signal on all GPIOs, with which no voltage can be measured at any point in the matrix - all LEDs are switched off. The three columns are connected to GPIOs 1, 2 and 3 via a 1kΩ resistor, the rows directly to GPIOs 4, 5 and 6.
0 Comments
Leave a Reply. |