|
You know how the LED works, right? If you
multiply what you know by 8, you get a 7-segment display with a dot aside.
Various colours and sizes. No difference.

There is only one thing to remember here, all LEDs in a
7-segment display have either their positive or negative legs tied together.
The "tied legs" are to be connected either to 5V or GND. On
the other side of each LED you have to place a resistor. The ones we 've
got are common anode version, all positive LED legs are connected together
at pins 1 and 6. Again, we need 2V across each LED and about 10mA. You
may look at the schematic and the datasheet. Now, which pin is which LED ...

As you imagined, when you ground one of the pins through
a resistor, you will see the corresponding LED turned on. You see the
story, for each digit we have to decide which LEDs to turn on. You may
find the following definitions handy.
// 7SEG
#define a0 PORTB &= ~(1<<2)
#define b0 PORTB &= ~(1<<1)
#define c0 PORTC &= ~(1<<0)
#define d0 PORTD &= ~(1<<5)
#define e0 PORTD &= ~(1<<6)
#define f0 PORTB &= ~(1<<0)
#define g0 PORTD &= ~(1<<7)
#define a1 PORTC &= ~(1<<4)
#define b1 PORTC &= ~(1<<5)
#define c1 PORTD &= ~(1<<2)
#define d1 PORTD &= ~(1<<4)
#define e1 PORTC &= ~(1<<1)
#define f1 PORTC &= ~(1<<2)
#define g1 PORTD &= ~(1<<3)
// LED
#define ledoff PORTB |= (1<<4)
#define ledon PORTB &= ~(1<<4)
|