7-Segment Display Wiring and Programming

Yes - altho you can find it less expensively if you look around.
Example,
http://parts.digikey.com/1/parts/527098-ic-pwr-8-bit-shift-regis-20-dip-tpic6b595n.html

Alright, so I think I understand the wiring. I just want to tackle this stage before I start code.

So is the 1 pin of the 7-segment display the positive and the 5 the negative or vice versa?

Or are both positive? I think it's that, right?

So then the wiring for the rest of the 7-segment is, for example,
DRAIN0 (on shift register)-33 OHM Resistor-Pin 7 on 7-segment display

(The batteries I'm using actually are 1,500 mAh)

I have a common ground to the shift register (just to one of the GND pins, right?), battery pack, and Arduino.

So the SER IN is the shift_data_out line and SER OUT goes to the next SER IN.

I assume that the pins of the Arduino for the shift_data_out line, shift_out_clock line, and the load_data line don't matter?

I think I'm just a bit confused about those 3 lines in general.

I believe I understand the shift_data_out line.

What pins on the shift register does the shift_out_clock line and load_data line go to?

Answers mixed in below:

So is the 1 pin of the 7-segment display the positive and the 5 the negative or vice versa?
Or are both positive? I think it's that, right?

Both pins 1 & 5 go to the positive of the supply. They are internally connected on the device.

So then the wiring for the rest of the 7-segment is, for example,
DRAIN0 (on shift register)-33 OHM Resistor-Pin 7 on 7-segment display

Yes.

(The batteries I'm using actually are 1,500 mAh)

If you have all 7 segments of a digit on, that's 7 x 20mA = 140mA, I don't remember how many digits you have altogether. 4? Then if you all 4 displaying "8888" you can expext to draw 560mA, you will get maybe 3 hours of life form 1500mA batteries. Most likely longer as you will have fewer segments on at any one time.

I have a common ground to the shift register (just to one of the GND pins, right?), battery pack, and Arduino.

Connect all 3 grounds from the shift register.

So the SER IN is the shift_data_out line and SER OUT goes to the next SER IN.

Yes.

I assume that the pins of the Arduino for the shift_data_out line, shift_out_clock line, and the load_data line don't matter?

Correct.

I think I'm just a bit confused about those 3 lines in general.

I believe I understand the shift_data_out line.

What pins on the shift register does the shift_out_clock line and load_data line go to?

shift_out_clock goes to SRCK
load_data goes to RCK
Low on SRCLR will clear the input register, tie it high if not used.
Low on G will enable the output transistors so 0s & 1s will show up on your display. With G high, no outputs will turn on.

I finished the wiring, but I'm not getting any response to the code. I imagine the other code is only for that shift register mentioned and I'll need to do a lot more work to get this one running.

I currently only have one display connected. I wanted to make sure this way works before I made more.

Post your code and a schematic of what you have so far, I'm sure we can get you going.

Wait, do I need to connect the positive of the battery power to Vcc?

Basically this is the idea, plug your parts in the correct places.
You may not need the diode to drop the voltage a little to the shift register, the recommended operating voltage is 5.5, absolute max is 7, so you may be okay with just the 4 batteries as the 1.5V/battery will drop some as they are used.

So I can not use SRCLR by tying it high meaning connecting it to 5V? And I don't have to do anything with G?

I just connected Vcc to the Arduino's 5V.

Is either SRCK or RCK connected to ground?

Basically I just need to know which is clock, data, and latch.

I assume data is SER IN, but I don't know which of the other two is which.

You need to get a copy of the datasheet

SRCK clocks the 8 bits into the Input Register one by one.
RCK then clocks all 8 bits together into the Output Register to drive the LED segments.
G/ can be tied low.
SRCLR/ can be tied high (Vcc) if you do not want to clear all the input registers at once.
SER IN is the data to be shifted in
SER OUT is the data to be shifted into the next device in line.

I read that part, but the Arduino site said that the latch pin needs to be connected to ground:

So is that right and if so, which is the latch pin line?

You have to look at the specific part being used.
The 74HC595 will die with the higher voltage you need for your multiple-LED/segment display.
The TPIC6B595 has a different pinout & functionality, you will need the 2 clock inputs as I described. Electrical Engineer, trust me on this one.

Oh ok, I used the TPIC6B595. So is there a latch pin at all then?

Right now I have SER IN, SRCK, and RCK connected to the Arduino.

Vcc and G to 5 volts and all three grounds and SRCLR connected to ground.

G needs to go to ground, that is the active low output enable.
SRCLR needs to be high, it clears the input register when it is low.
SRCK shifts in the 8 bits.
RCK clocks the 8 bits into the output register to control your segments.

So there is no Latch pin - the functionality is different, you need an edge to clock the register.

Right, I switched those somehow. The code you mentioned had a latch pin, so I don't think it will work.

So I send in the 8 bits through SRCK? I thought that was what SER IN did. I can try writing some code once I figure out what information each input needs sent.

Sorry this is taking so long. I appreciate your help. I was sent this site:

and I tried to use that but it seems to be about the other shift register configuration that uses a latch pin. Both shift registers are 595s though.

You'll need something like this:

shiftOut(shiftdatapin, shiftclockpin, MSBFIRST, shiftregdata); // puts the bits into the input register
digitalWrite (RCK, LOW);
digitalWrite (RCK, HIGH); // puts the bits into the output register.

where shiftdatapin connects to SER IN,
shiftclockpin connects to SRCK.
MSBFIRST says bit 7 of your data is going out first,
and shiftregdata is your segment data (bit 0-7 representing segments A-G & DP for example).
595 has lots if variations. Need to read the datasheets and wire accordingly.

Wow that works great! Thanks!

Do you know how I could get the code to interpret numbers into bytes that needs to be sent?

int shiftdatapin = 48;
int shiftclockpin = 50;
int RCK = 52;

byte numbers[10] =
{
  B00111111, // 0
  B00000110, // 1
  B01010011, // 2
  B01001111, // 3
  B01100110, // 4
  B01101101, // 5
  B01111101, // 6
  B00000111, // 7
  B01111111, // 8
  B01101111  // 9
};

void setup() {
  //set pins to output so you can control the shift register
  pinMode(shiftdatapin, OUTPUT);
  pinMode(shiftclockpin, OUTPUT);
  pinMode(RCK, OUTPUT);
}

void loop() {
shiftOut(shiftdatapin, shiftclockpin, MSBFIRST, B01111111); // puts the bits into the input register
digitalWrite (RCK, LOW);
digitalWrite (RCK, HIGH); // puts the bits into the output register.

}

The above code works, but I'd like to be able to put a variable into the code instead of B01111111.

Would the above code work for multiple digits too? For example, could I send 1493 to a string of 4 digits of the display and it'd work or do I have to somehow separate 1493 into individual numbers and send them out?

Easy question first : 1493. Do you have 4 shift registers connected together, so that the output of one feeds the input of 2, two's output feeds 3's input, etc?
If so, you can just do 4 shiftouts in a row. If not, do 4 shiftouts to the individually controlled registers. Shiftout is a software feature, pretty similar to:
digitalWrite (pin, bit0);
digitalWrite (clock low);
digitalWrite (clock, high);
//repeat 7 times for bit1, bit2, ...bit7.
You can also do a hardware controlled shiftout that would go faster using SPI, but you have to use specific pins for it. Go do some reading about it.

shiftregdata = byte1;
shiftOut(shiftdatapin, shiftclockpin, MSBFIRST, shiftregdata); // puts the bits into the input register
digitalWrite (RCK, LOW);
digitalWrite (RCK, HIGH); // puts the bits into the output register.
shiftregdata =  byte2;
shiftOut(shiftdatapin, shiftclockpin, MSBFIRST, shiftregdata); // puts the bits into the input register
digitalWrite (RCK, LOW);
digitalWrite (RCK, HIGH); // puts the bits into the output register.
shiftregdata  = byte3;
shiftOut(shiftdatapin, shiftclockpin, MSBFIRST, shiftregdata); // puts the bits into the input register
digitalWrite (RCK, LOW);
digitalWrite (RCK, HIGH); // puts the bits into the output register.
shiftregdata  = byte4;
shiftOut(shiftdatapin, shiftclockpin, MSBFIRST, shiftregdata); // puts the bits into the input register
digitalWrite (RCK, LOW);
digitalWrite (RCK, HIGH); // puts the bits into the output register.

now, making bytex= numbers[x], maybe something like this:
shiftregdata[1] = numbers[ones_seconds];
shiftregdata[2] = numbers[tens_seconds];
shiftregdata[3] = numbers[ones_hours];
shiftregdata[4] = numbers[tens_hours];

and the 4 shifts above could be pulled into a loop? Defined as:
for (initialization; condition; increment) {
//statement(s);
}

This loop should do 4 shiftouts, fancier than anything I've tried yet:

//for (x=1 to 4)
for (x=0;  x<5; x=x+1;){  //maybe x==4, and x++ instead x=x+1?? x=x+1 is clearer (to me). Try it.
shiftOut(shiftdatapin, shiftclockpin, MSBFIRST, shiftregdata[x]); // load input register
digitalWrite (RCK, LOW);
digitalWrite (RCK, HIGH); // load output register.
//Serial.writeln shiftregdata[x];  // to make sure
}

I have 4 in a row, but the second data input seems to just overwrite the first.

int shiftdatapin = 48;
int shiftclockpin = 50;
int RCK = 52;
int shiftregdata;

byte numbers[10] =
{
  B00111111, // 0
  B00000110, // 1
  B01010011, // 2
  B01001111, // 3
  B01100110, // 4
  B01101101, // 5
  B01111101, // 6
  B00000111, // 7
  B01111111, // 8
  B01101111  // 9
};

void setup() {
  //set pins to output so you can control the shift register
  pinMode(shiftdatapin, OUTPUT);
  pinMode(shiftclockpin, OUTPUT);
  pinMode(RCK, OUTPUT);
}

void loop() {
shiftregdata =  B00000111;
shiftOut(shiftdatapin, shiftclockpin, MSBFIRST, shiftregdata); // puts the bits into the input register
digitalWrite (RCK, LOW);
digitalWrite (RCK, HIGH); // puts the bits into the output register.
shiftregdata =  B00000111;
shiftOut(shiftdatapin, shiftclockpin, MSBFIRST, shiftregdata); // puts the bits into the input register
digitalWrite (RCK, LOW);
digitalWrite (RCK, HIGH); // puts the bits into the output register.

}