Programming 7- segment with Arduino

Hello everyone!
I have been trying to program a 7 segment display today and have had some luck. I have uploaded this code and the bottom and the DP light up. I have hooked up the segment to the arduino via pins 5-13. The common anode is at pin 13 and is working currently. I have no idea on how I got the decimal to light up, because I just initialized it as an output. All I am trying to do now is light up a number on the 7 segment display. After I make and complete this, I will try to make a dice, and then a library for the Arduino. Any help on just trying to make it display a number?

Thanks, qtechknow

/*
  7-Segment Display
 */
const int DP = 5;
const int CA = 13; 

int ledPins[] = { 6, 7, 8, 9, 10, 11, 12 }; 
int zero[] = { 7, 12, 6, 8, 10, 9 };
int one[] = { 6, 10 };
int two[] = { 7, 6, 11, 8, 9 };
int three[] = { 7, 6, 11, 10, 9 };
int four[] = { 12, 11, 6, 10 };
int five[] = { 7, 12, 11, 10, 9 };
int six[] = { 7, 12, 11, 8, 9, 10 };
int seven[] = { 7, 6, 10 };
int eight[] = { 7, 6, 12, 11, 10, 9, 8 };
int nine[] = { 7, 12, 6, 11, 10 };

void setup() {                
  // initialize the digital pins as outputs
  pinMode(CA, OUTPUT);
  pinMode(DP, OUTPUT);
  pinMode(ledPins[6, 7, 8, 9, 10, 11, 12], OUTPUT);
}

void loop() {
  digitalWrite(13, HIGH);   // set the Common Anode high
  digitalWrite(zero[7, 12, 6, 8, 9, 10], LOW);  // display 0
}

digitaWrite(pin, value) --> the pin number has to be a single number - not an array. You have to write a for() loop.

Actually I haven't got a clue what the construct
digitalWrite(zero[7, 12, 6, 8, 9, 10], LOW); 
does. It should fail to compile, but as Arduino is C++ there is some fancy stuff beyond me. I do know it does NOT write to a list of oins.

Lastly, do not use the Arduino IO pins as power supplies. You have a nice +5V pin you can use for this experiment as the anode supply. Really there should be a resistor of 220 Ohm in series between each of the 5-12 pins and the LED segement.

What is your plan to turn off unneeded segments?
Ex.
You write out an 8, all segments on.
Then you write out a 1 - 2 segments on.
What turns off the rest of them?

You can do a for:next loop to go thru the pins in array and one at a time write the pins in the number array.
Or you can do this

numbers[] = {
B00111111,  //0
B00000110, // 1
B01011011, // 2
etc where BPgfedcba represents the LED segments
   a
f     b
   g
e    c
   d    P
then to write a digit:
PORTX = numbers[number_to_displau];

However, you're not using a part that has 8 bit ports accessible, so need to do something different.
Bigger chip! No, wait.

Write a for:next loop that will write the value of each bit in numbers[x] to the pins in ledPins:

for (x=1; x<0x80; x=x<1){  //
digitalWrite (ledPins[x], (numbers[number_to_display] && x));
}
where 
numbers[number_to_display] && x
should be True (i.e !=0) if the masking result is not equal to 0
result of B00000001 && numbers[number_to_display] for segment A
B00000010 && && numbers[number_to_display] for segment B, etc.

will mask off

I just did a tutorial that uses the 7 segment display as an example of how to code:-
http://www.thebox.myzen.co.uk/Tutorial/Arrays.html

Grumpy_Mike:
I just did a tutorial that uses the 7 segment display as an example of how to code:-
Arrays

nice!