Since we can source a maximum of 10mA per pin for PORTB, hence we can just
sufficiently to use PORTB to drive 7 Seg. LED display directly. Below
shows the circuit where the 2 common cathode 7-SEG LEDs are connected to PORTB with
120 Ohms current limiting resistors. The same segment of the two LEDs are tied
in parallel to B. Q1 and Q2 are activated by logic high on PD0 and DA1 which
switch on ground to the respective common cathode pins. PD2 and PD3 pin are use
to read the inputs S1 or S2 push-button switches.
The following code,
demonstrate how to drive two 7-segment LEDs.
The program first display digits on the Left LEDs and counts
from 0 to 9 with a delay of 1 second between each digit. Then
it switches to the Right LED and repeats the same tasks and
then the whole sequence is repeated all over again from the