How to use a common anode 7-segment, 4-digit display?
Just as a complement to Paul's answer, I wrote a short program to show
how to drive the 7-segment 4-digit display of his figure:



This is actually a common cathode display, so the program assumes that,
as well as the particular wiring of the figure. The interesting part is
the refresh_display() function, which should be called periodically.
The algorithm is as follows:


drive the 7 anodes with the appropriate signals for one of the digits
we want to show
set HIGH the output that controls that digit's cathode through the
NPN transistor
wait for 2.5 ms (for a refresh rate of 100 Hz)
set LOW the cathode-controlling output
move to the next digit.


It should be noted that the waiting is done without blocking the CPU, by
using the technique described in the Blink Without
Delay Arduino
tutorial. Here is the program:

const int NB_DIGITS     = 4;  // 4-digit display
const int FIRST_ANODE   = 2;  // anodes a..g on pins 2..8
const int FIRST_CATHODE = 9;  // cathodes, right to left, on pins 9..12

// Digits to display, from right to left.
uint8_t digits[NB_DIGITS];

// Set all the used pins as outputs.
void init_display()
{
    for (int i = 0; i &lt; 7; i++)
        pinMode(FIRST_ANODE + i, OUTPUT);
    for (int i = 0; i &lt; NB_DIGITS; i++)
        pinMode(FIRST_CATHODE + i, OUTPUT);
}

// This should be called periodically.
void refresh_display()
{
    // Our 7-segment "font".
    static const uint8_t font[10] = {
        //abcdefg
        0b1111110, // 0
        0b0110000, // 1
        0b1101101, // 2
        0b1111001, // 3
        0b0110011, // 4
        0b1011011, // 5
        0b1011111, // 6
        0b1110000, // 7
        0b1111111, // 8
        0b1111011  // 9
    };

    // Wait for 2.5 ms before switching digits.
    static uint32_t last_switch;
    uint32_t now = micros();
    if (now - last_switch &lt; 2500) return;
    last_switch = now;

    // Switch off the current digit.
    static uint8_t pos;
    digitalWrite(FIRST_CATHODE + pos, LOW);

    // Set the anodes for the next digit.
    pos = (pos + 1) % NB_DIGITS;
    uint8_t glyph = font[digits[pos]];
    for (int i = 0; i &lt; 7; i++)
        digitalWrite(FIRST_ANODE + i, glyph &amp; 1 &lt;&lt; (6-i));

    // Switch digit on.
    digitalWrite(FIRST_CATHODE + pos, HIGH);
}

/***********************************************************************
 * Example usage.
 */

void setup()
{
    init_display();
}

void loop()
{
    uint32_t now = millis();

    // Change the number displayed every second.
    static uint32_t last_change;
    if (now - last_change &gt;= 1000) {
        digits[3] = digits[2];
        digits[2] = digits[1];
        digits[1] = digits[0];
        digits[0] = (digits[0] + 1) % 10;
        last_change = now;
    }

    refresh_display();
}


Paul provided a link to a tutorial on
Parallax
that suggests using the
Multiplex7Seg
Arduino library. That library is more general than the example code
above, as it does not make assumptions about the pins used. But the big
difference between the library and this code is in the way the timings
are managed:


The library is driven by the Timer 2 overflow interrupt. This should
provide a very steady timing, at the cost of having one timer
dedicated to this job.
The code above relies on the user calling refresh_display() often
enough. It doesn't require dedicated hardware resources, but it
doesn't play well with programs that take too long to loop(): it
won't like you calling delay().