the Seven Segment Display where is the ground?

My basic Arduino kit included a HS420361K-32 device and I hooked it up and it works just fine, but no ground?

// assigning arduino digital pins for the various led display pins
int pinA = 3;
int pinB = 7;
int pinC = 12;
int pinD = 10;
int pinE = 9;
int pinF = 4;
int pinG = 13;
int pinDP = 11; // the decimal point pin
int D1 = 2;
int D2 = 5;
int D3 = 6;
int D4 = 8;
int t = 250; // time delay

void setup() 
{                
  // initialise the digital pins as outputs.
  pinMode(pinA, OUTPUT);     
  pinMode(pinB, OUTPUT);     
  pinMode(pinC, OUTPUT);     
  pinMode(pinD, OUTPUT);     
  pinMode(pinE, OUTPUT);     
  pinMode(pinF, OUTPUT);     
  pinMode(pinG, OUTPUT);   
  pinMode(pinDP, OUTPUT);  
  pinMode(D1, OUTPUT);  
  pinMode(D2, OUTPUT);  
  pinMode(D3, OUTPUT);  
  pinMode(D4, OUTPUT);  
}

void loop() 
{ 
  write_D1(); //function call to turn on D1 to write characters for the first digit
  print_3(); // function call to display 3
  print_decimal(); // function call to display the decimal point
  delay(1);

  write_D2(); //function call to turn on D2 to write characters for the second digit
  print_1(); // function call to display 1
  delay(1);

  write_D3(); //function call to turn on D3 to write characters for the third digit
  print_4(); // function call to display 4
  delay(1);

  write_D4(); //function call to turn on D4 to write characters for the fourth digit
  print_2(); // function call to display 2
  delay(1);
}



/* THE FUNCTIONS */



// the functions for selecting the common pin to turn on
void write_D1()
{
  digitalWrite(D1, LOW);
  digitalWrite(D2, HIGH);
  digitalWrite(D3, HIGH);
  digitalWrite(D4, HIGH); 
}

void write_D2()
{
  digitalWrite(D1, HIGH);
  digitalWrite(D2, LOW);
  digitalWrite(D3, HIGH);
  digitalWrite(D4, HIGH); 
}

void write_D3()
{
  digitalWrite(D1, HIGH);
  digitalWrite(D2, HIGH);
  digitalWrite(D3, LOW);
  digitalWrite(D4, HIGH); 
}

void write_D4()
{
  digitalWrite(D1, HIGH);
  digitalWrite(D2, HIGH);
  digitalWrite(D3, HIGH);
  digitalWrite(D4, LOW); 
}

// the functions for writing characters to the display
void print_0() // writing 0
{
  digitalWrite(pinA, HIGH);   
  digitalWrite(pinB, HIGH);   
  digitalWrite(pinC, HIGH);   
  digitalWrite(pinD, HIGH);   
  digitalWrite(pinE, HIGH);   
  digitalWrite(pinF, HIGH);   
  digitalWrite(pinG, LOW);
  digitalWrite(pinDP, LOW); // the decimal point is always off by default
}

void print_1() // writing 1
{
  digitalWrite(pinA, LOW);   
  digitalWrite(pinB, HIGH);   
  digitalWrite(pinC, HIGH);   
  digitalWrite(pinD, LOW);   
  digitalWrite(pinE, LOW);   
  digitalWrite(pinF, LOW);   
  digitalWrite(pinG, LOW);
  digitalWrite(pinDP, LOW);
}

the display has LEDs powered by two pins, however there is no ground used here. Somehow a pin is called D4 and it becomes the cathode when set low. I thought you had to have a ground somewhere to get current to flow. I am lost.

(deleted)

It needs a potential difference, but I see a pin, any pin, as being either plus, or off and if it is off nothing can flow in either direction. That is my conundrum. For example, if I connect a table lamp that has the 110 side connected to another table lamp at the 110 side that is off, no current will flow because the second unit being off means that circuit is open on the 110 side. Yes, if I connect it to the neutral side of the second lamp it will of course work, but a pin has only one side.

(deleted)

sevenoutpinball:
but I see a pin, any pin, as being either plus, or off and if it is off nothing can flow in either direction.

Now there is your misunderstanding. If the pin is an output it's either HIGH (aka, connected to Vcc) or LOW (aka, connected to GND). That's why we call it HIGH and LOW, not ON and OFF.

Only when you make the pin an input the pin will float which is closest to your definition of OFF.

This LED doesn't have a ground.

Uh oh, I may learn something here, so ground can also mean not just a neutral source of electrons but only has to be a different in potential source of electrons and flow will take place such that one becomes equal to the other. Ok. I get it now. I hope.

Now in the picture by dougp, is the Q a pin? If so I guess you could argue the diode is connected to a leg of a transistor and in turn connected to gnd by the transistor. Am I right?

Ground is simply the point in the circuit you choose to call 0V, and its common that signals
are defined with respect to this point (aka "referenced to ground").

Since absolute voltages are meaningless, you have to define a reference point to assign numbers
for voltages on nodes of a circuit.

A multi-digit 7-segment display is a multiplexed array of LEDs, its completely passive. There are
two sorts, common anode and common cathode, and these are good search terms for finding
example circuits using them.

I hate to beat a dead horse, but how does this part work, I mean suppose you want to light segment A on d1 and segment B on d2, both digits 1 and 2 have to be on so wouldn't that light A and B on both digits?

Its designed to be multiplexed. You'll need to understand multiplexing to use this. Each digit is lit up in turn, and sequenced rapidly so the eye doesn't notice.

Wow. I always understood multiplexing as using multiple frequencies on the same piece of wire. So are you saying that indeed for a microsecond the thing they are all lit as I describe somehow?

This is time multiplexing.
4 digits, 28 time periods. (QB thru QG and their resistor are not shown)

  1. Q1 and QA turn on to light up DA (digit 1 segment A).
  2. Q2 and QA turn on to light up DB. (digit 2 segment A).
  3. Q3 and QA turn on to light up DB. (digit 3 segment A).
  4. Q4 and QA turn on to light up DB. (digit 4 segment A).

Repeat for Segment B, then C, D, E, F, G.

Alternately, Q1 and All segments needed for digit 1 can be turned.

Multiplexing is having multiple signals sharing a channel, can be FDM (frequency division multiplexing)
or TDM (time division multiplexing). The latter is used here, with the segment wires (abcdefg & DP)
being multiplexed over time between the different digit's data.

Time multiplexing is hardware dependent too.
If cycling thru all 28 digits, 11 IO pins can be used directly, as only 1 segment is ever on.

If cycling thru 4 digits, then the common transistor (for the anode in my diagram, but could as easily be the cathodes, depends on the display type selected) needs to be an external transistor as it is controlling current for 7 or 8 LEDs together (all 7 segments plus decimal point), which is more than an IO pin can handle (unless the current for each segment is limited to like 4mA, which could be on the dim side when a digit is only on 1/4 of the time).

Display Multiplexing

fascinating, I never knew they were flickering all the time.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.