for each digit
select digit i by grounding common cathode
apply seven-segment drive for this digit
end for
This code will need to sequence through the digits at least 40Hz or faster.
However, don't scan too fast since that will reduce the apparent LED brightness.