Seven segment displays are basically 8 LED in a pattern. The most convenient way of connecting would be to hook up each LED to one pin of a port, but usually this is not possible because ports have different uses and there is always a certain port you wish to use for a certain purpose. In this case the RX/TX pins in PORT B are used for the serial input, and RA4 is used for the I2C communication. This means we have to select other pins. This design avoids fancy PWM output to the LED and just allows them to be on and off. To avoid the LED dying from current drain I added 330 Ohm resistors. For a brighter result one can go as low as 220 Ohm, to save power you can go as high as 1k Ohm. The part of the software for controlling the LED display is very simple in this case: it just consists of subroutines that send the appropriate output to the port. Normally one would not do it this way, as this is inefficient. A lookup table would be better. In this case, however, there are a limited number of values, and it was meant as a prototype anyway.
Note that it might seem attractive to use a single resistor on the ground pin of the LED display. This, however, will cause the brightness to fluctuate and can even cause damage to the display, and is therefore not recommended.
Geen opmerkingen:
Een reactie posten