Simple dice

I would also recommand that you look up on arrays.

That way you can loop through all pins and set it according to another array. And by the time you get that down, you also might concider making it a function.

NOT TESTED:

/*
|| Demonstration of arrays and a simple comparason
||
||    ___1___ 
||   |       |
|| 2 |       | 5
||   |___6___|
||   |       |
|| 3 |       | 7
||   |_______| 
||      4     <> 8
*/

typedef unsigned char uchar;
#define DICE_PINS 8
//for instance, create an array of your pins
uchar ucMyDice[] = { 2, 3, 4, 5, 6, 7, 8, 9 };
//and then a new array for displaying '4'
uchar ucNumbers[][DICE_PINS]     = {
                                  { 1, 0, 0, 0, 1, 0, 1, 0 }, //pin 2 on, 3 off, 4 off, 5 on, 6 off, 7 on, 8 off
                                  { 1, 0, 1, 1, 1, 1, 0, 0 }, //2
                                  { 0, 0, 0, 0, 0, 0, 0, 0 }, //TODO implement
                                  { 0, 1, 0, 0, 1, 1, 1, 0 }, //TODO implement
                                  { 0, 0, 0, 0, 0, 0, 0, 0 }, //TODO implement
                                  { 0, 0, 0, 0, 0, 0, 0, 0 }  //TODO implement
                                };//  
//later you can loop through both and turn on/off ucMydice according to ucFour


void setup()
{
  for(uchar i=0; i<DICE_PINS; i++)
  {
    pinMode(ucMyDice[i],OUTPUT); //init all pins inside this array as outputs
  }
  lightANumber(2); //test
}

void loop()
{
  //
}

void lightANumber(unsigned char ucNumber)
{
  //loop through all pins according to the number
  for(unsigned char i=0; i<DICE_PINS; i++)
  {
    digitalWrite(ucMyDice[i],ucNumbers[ucNumber-1][i]);
  }
}