Need help with 7-Segment Display

I'm still learning stuff right now so bare with me. I just wanted to know if I needed to add any resistor when I hook the digital display up to my arduino. I have 8 anode which I figure would all go to a pin on the arduino and 2 cathode which would hook up to the ground pin. Let me know if I'm doing it right so far. Also don't know if this stuff will help since I have no idea how to read it:

Maximum ratings
Forward current: 30mA
Forward voltage: 2V
Reverse voltage: 5V
Power dissipation: 100mW

Typical characteristics
Forward current: 20mA
Forward voltae: 1.7V
Peak wavelength: 655nm

Thanks alot for explaining stuff.

do you have a picture of the display or a link to a website where you bought it from?

the device i used had 8 pins. 1 for each led and 1 common ground. I connected each led pin a digital out on the arduino and the ground to ground.

Yes you always need a resistor with an LED (unless you have a current controlled source which you don't). It should be between 150 and 470 ohms, the smaller the value the brighter it will be.

oh yeah, im an idiot, forgot to mention the resistors!!

if you don't have any resistors available you can try connecting one of the segments to pin 13 and ground. pin 13 has a 1k pull up resistor which should be enough to get you a dim light going.

thats what I have.
Can I connect it like this:

anode F to 13
anode G to 12
anode E to 11
anode D to 10
anode C to 9
anode RHDP to 8
anode B to 7
anode A to 6

then connect the two cathode to ground.

Also where would I need the resistor at if it safe to connect it like that, and how would I figure out what size to use.

yeah you are going to need resistors in between the arduino digital out pins and the display.

you should be able to test one led though as 13 comes with an inbuilt resistor. connect it as so

13(arduino)----F(LED)-----ground(arduino).

then use the sample program for blink and it should blink the F LED

You will need eight resistors, one for each segment and one for the decimal point. A value around 220 Ohms is usually about right.

ok thank you, I did try before just hooking up 3 of them to the pin and turn them on each by themself but wasn't sure if that was a good idea to do. I will hook them all up to resistor this time before I continue on. I will try to put my code on here later.

For anyone who is new to electronics and wants to really get into it, the info here should be a big help.
http://www.rmcybernetics.com/science/cybernetics/electronics_volts_amps_watts.htm#ohmslaw

Don't know if that came out as an active link, but if you go to that site you can learn how to work out your own resistors and lots of other handy stuff.

Here is my code. I just made it count from 0 - 9. My question is, is there an shorter way of doing this. This my first big code lol, so just took example from LED tutorial.

int ledPinF = 13;
int ledPinG = 12;
int ledPinE = 10;
int ledPinD = 9;
int ledPinA = 8;
int ledPinB = 7;
int ledPinRHDP = 6;
int ledPinC = 5;

void setup()                    
{
  // Set pins to output.
  pinMode(ledPinF, OUTPUT);
  pinMode(ledPinG, OUTPUT);
  pinMode(ledPinE, OUTPUT);
  pinMode(ledPinD, OUTPUT);
  pinMode(ledPinA, OUTPUT);
  pinMode(ledPinB, OUTPUT);
  pinMode(ledPinRHDP, OUTPUT);
  pinMode(ledPinC, OUTPUT);
}

void loop()                     
{
  
  digitalWrite(ledPinA, HIGH);         // Turn on 0
  digitalWrite(ledPinB, HIGH);
  digitalWrite(ledPinC, HIGH);
  digitalWrite(ledPinD, HIGH);
  digitalWrite(ledPinE, HIGH);
  digitalWrite(ledPinF, HIGH);
  delay(1000);
  digitalWrite(ledPinA, LOW);         // Turn off 0
  digitalWrite(ledPinB, LOW);
  digitalWrite(ledPinC, LOW);
  digitalWrite(ledPinD, LOW);
  digitalWrite(ledPinE, LOW);
  digitalWrite(ledPinF, LOW);
  delay(100);
  digitalWrite(ledPinB, HIGH);         //Turn on 1
  digitalWrite(ledPinC, HIGH);  
  delay(1000);  
  digitalWrite(ledPinB, LOW);          // Turn off 1
  digitalWrite(ledPinC, LOW);
  delay(100);
  digitalWrite(ledPinA, HIGH);          // Turn on 2
  digitalWrite(ledPinB, HIGH);
  digitalWrite(ledPinG, HIGH);
  digitalWrite(ledPinE, HIGH);
  digitalWrite(ledPinD, HIGH);
  delay(1000);
  digitalWrite(ledPinA, LOW);          // Turn off 2
  digitalWrite(ledPinB, LOW);
  digitalWrite(ledPinG, LOW);
  digitalWrite(ledPinE, LOW);
  digitalWrite(ledPinD, LOW);
  delay(100);
  digitalWrite(ledPinA, HIGH);        // Turn on 3
  digitalWrite(ledPinB, HIGH);
  digitalWrite(ledPinG, HIGH);
  digitalWrite(ledPinC, HIGH);
  digitalWrite(ledPinD, HIGH);
  delay(1000);
  digitalWrite(ledPinA, LOW);          // Turn off 3
  digitalWrite(ledPinB, LOW);
  digitalWrite(ledPinG, LOW);
  digitalWrite(ledPinC, LOW);
  digitalWrite(ledPinD, LOW);
  delay(100);
  digitalWrite(ledPinF, HIGH);         // Turn on 4
  digitalWrite(ledPinG, HIGH);
  digitalWrite(ledPinB, HIGH);
  digitalWrite(ledPinC, HIGH);
  delay(1000);
  digitalWrite(ledPinF, LOW);         // Turn off 4
  digitalWrite(ledPinG, LOW);
  digitalWrite(ledPinB, LOW);
  digitalWrite(ledPinC, LOW);
  delay(100);
  digitalWrite(ledPinA, HIGH);        // Turn on 5
  digitalWrite(ledPinF, HIGH);
  digitalWrite(ledPinG, HIGH);
  digitalWrite(ledPinC, HIGH);
  digitalWrite(ledPinD, HIGH);
  delay(1000);
  digitalWrite(ledPinA, LOW);        //  Turn off 5
  digitalWrite(ledPinF, LOW);
  digitalWrite(ledPinG, LOW);
  digitalWrite(ledPinC, LOW);
  digitalWrite(ledPinD, LOW);
  delay(100);
  digitalWrite(ledPinF, HIGH);        // Turn on 6
  digitalWrite(ledPinE, HIGH);
  digitalWrite(ledPinD, HIGH);
  digitalWrite(ledPinC, HIGH);
  digitalWrite(ledPinG, HIGH);
  delay(1000);
  digitalWrite(ledPinF, LOW);         // Turn off 6
  digitalWrite(ledPinE, LOW);
  digitalWrite(ledPinD, LOW);
  digitalWrite(ledPinC, LOW);
  digitalWrite(ledPinG, LOW);
  delay(100);
  digitalWrite(ledPinA, HIGH);       // Turn on 7
  digitalWrite(ledPinB, HIGH);
  digitalWrite(ledPinC, HIGH);
  delay(1000);
  digitalWrite(ledPinA, LOW);        // Turn off 7
  digitalWrite(ledPinB, LOW);
  digitalWrite(ledPinC, LOW);
  delay(100);
  digitalWrite(ledPinA, HIGH);      // Turn on 8
  digitalWrite(ledPinB, HIGH);
  digitalWrite(ledPinC, HIGH);
  digitalWrite(ledPinD, HIGH);
  digitalWrite(ledPinE, HIGH);
  digitalWrite(ledPinF, HIGH);
  digitalWrite(ledPinG, HIGH);
  delay(1000);
  digitalWrite(ledPinA, LOW);        // Turn off 8
  digitalWrite(ledPinB, LOW);
  digitalWrite(ledPinC, LOW);
  digitalWrite(ledPinD, LOW);
  digitalWrite(ledPinE, LOW);
  digitalWrite(ledPinF, LOW);
  digitalWrite(ledPinG, LOW);
  delay(100);
  digitalWrite(ledPinA, HIGH);       // Turn on 9
  digitalWrite(ledPinF, HIGH);
  digitalWrite(ledPinG, HIGH);
  digitalWrite(ledPinB, HIGH);
  digitalWrite(ledPinC, HIGH);
  delay(1000);
  digitalWrite(ledPinA, LOW);        // Turn off 9
  digitalWrite(ledPinF, LOW);
  digitalWrite(ledPinG, LOW);
  digitalWrite(ledPinB, LOW);
  digitalWrite(ledPinC, LOW);
  delay(100);
  
}

rodmac thanks for that site. That will come in handy for me while I'm learning.

@demonic_crew: code looks good. don't know what you will be doing with it, so I don't know how much reducing can be made.

One simple way to reduce your code could be to create one method to turn off all the leds off. Then you don't have to turn all the LEDs off indivisually each time. Something like this should work (not tested it yet):

void turnLEDoff(){
  digitalWrite(ledPinA, LOW);
  digitalWrite(ledPinB, LOW);
  digitalWrite(ledPinC, LOW);
  digitalWrite(ledPinD, LOW);
  digitalWrite(ledPinE, LOW);
  digitalWrite(ledPinF, LOW);
  digitalWrite(ledPinG, LOW);
  digitalWrite(ledPinRHDP, LOW);
}

Then instead off turning off all the pins as so:

...
  digitalWrite(ledPinA, LOW);         // Turn off 0
  digitalWrite(ledPinB, LOW);
  digitalWrite(ledPinC, LOW);
  digitalWrite(ledPinD, LOW);
  digitalWrite(ledPinE, LOW);
  digitalWrite(ledPinF, LOW);
...

just call the function as so:

turnLEDoff()

demonic_crow: bought my Arduino card last friday and tested to make the same thing as you. Have a 7-seg display to count. Totally useless but I came up with this code:

const int num_pins = 8;                 // the number of pins used
const int numPatterns=10;               // number of patterns to display
int timer = 1000;                       // time to next pattern
int pins[] = {2, 3, 4, 5, 6, 7, 8, 9};  // pins used, first one to segment A, second to segment B...

// define all different patterns (numbers) to display
int patterns[numPatterns][num_pins]=
{
  {1,1,1,1,1,1,0,0},
  {0,1,1,0,0,0,0,0},
  {1,1,0,1,1,0,1,0},
  {1,1,1,1,0,0,1,0},
  {0,1,1,0,0,1,1,0},
  {1,0,1,1,0,1,1,0},
  {1,0,1,1,1,1,1,0},
  {1,1,1,0,0,0,0,0},
  {1,1,1,1,1,1,1,0},
  {1,1,1,1,0,1,1,0},
};

void setup()
{
  int i;

  for (i = 0; i < num_pins; i++)   // the array elements are numbered from 0 to num_pins - 1
    pinMode(pins[i], OUTPUT);      // set each pin as an output
  
}

void loop()
{
  int i;
  int p;
  
  for (i = 0; i < numPatterns; i++) {  // loop through all patterns
    for (p = 0; p < num_pins; p++) {   // loop through the pin states for pattern
      if (patterns[i][p]==1) 
      {
        digitalWrite(pins[p], HIGH);   // turning it on
      }
      else
      {
        digitalWrite(pins[p], LOW);    // turning it off
      }
    }
 
    delay(timer);                      // pausing

  }
}

Thanks, see I don't understand how to get the 1,0 thing to work. I know it seem like thats how you charlieplex also. I will have to go over it when I get off of work. Thanks for adding your own code here for me to look over. Also if you have any tip how you learn to program that way could you point me in the right direction or give me a few tips. Thanks alot

I'm still learning the code myself, but when I look at BD's code it makes sense to me. I think the fact that I understand how to use 7 seg. displays is the clue.
As I see it, each horizontal line of{1, 0, 1, 1......} controls which digit the display shows. 10 lines, 10 digits.
If you connect the arduino pins to the display pins exactly
like it says in line 4 of the code I think your display should count up from 0 to 9 in a continuous cycle.
Hadn't heard of charlieplex (had to look it up) but don't think it applies here. Forget about it for now & make sure you understand all about the display, then the code might make sense.

Each ({0,1,0,....}) describes the different patterns you want to display(the state of the 8 pins). In this case they describe the digits 0-9, but could be describing any pattern you want to display.

Example:
{1,1,1,1,1,1,0,0} - describes the digit "0". All segment are On except segment G.
{1,1,1,1,1,1,1,0} - describes the digit "8". All segments are On.

It's seven pins for the segments and one (last one) for the dot (I have one on my display). The dot is always off (last digit is 0).

Connect segement A on the display to the first pin defined in the pins[] variable (in my case pin 2), and segment B to the second pin defined in the pins[] variable (in my case pin 3)...

The pattern[][] variable is a two dimensional array. Maybe it's clear to a C programmer how to define it, but I had a lot of trouble get it to work. Finally I got i correct!

Thanks alot, I'm understanding it a whole lot more now. I don't know much about array so thats why its a little hard for me to understand. The one thing I want to know is how did you get it to read the 1 and 0. I figure you would have to add that in there some where or make it to read that. Is this how it read it:

if (patterns*[p]==1)*
I never use the == or any of the other. Thanks alot again for posting your code. It helped me understand more about programming the arduino.