Strange wiring for the segment led display

The only connections are made to IO pins. All pins are set to OUTPUT. I assembled it myself and it works but what is the path of the current?? There is no connection to ground!

Yes there is a connection to ground. When you set an Arduino pin to OUTPUT and LOW, the pin is connected to ground inside the chip.

Before you wire the circuit up like that, stop. It will damage your Arduino.

Those resistors (red, red, brown) are 220 Ohm. The leds in the display probably have a forward voltage of 1.8~2.0V. The current flowing through each led will be around 14mA, which is fine for the LEDs and fine for the Arduino pins connected to the segments. BUT... the Arduino pins connected to the digit common pins might have as much as 110~120mA flowing though them. The absolute maximum current for an Arduino pin is 40mA, and it is not recommended to exceed 25~30mA long term.

PaulRB:
Yes there is a connection to ground. When you set an Arduino pin to OUTPUT and LOW, the pin is connected to ground inside the chip.

Before you wire the circuit up like that, stop. It will damage your Arduino.

Those resistors (red, red, brown) are 220 Ohm. The leds in the display probably have a forward voltage of 1.8~2.0V. The current flowing through each led will be around 14mA, which is fine for the LEDs and fine for the Arduino pins connected to the segments. BUT... the Arduino pins connected to the digit common pins might have as much as 110~120mA flowing though them. The absolute maximum current for an Arduino pin is 40mA, and it is not recommended to exceed 25~30mA long term.

What way should I connect it then?

One option would be to connect it the same but swap the resistors for 1k ones.

Second option, use a transistor to drive the segments.

You have several choices.

You can increase the value of those resistors to 820R or 1K. That will reduce the current through the digit common pins to around 30mA or less. But it will make the display dimmer. Try it and see if you think that is bright enough for you.

If it is not bright enough, you can use some transistors to boost the current available from the Arduino pins. The type of transistor required will depend on the type of display you are using. Can you post the display's part number or a link to a page where you purchased it? The part number is often printed on the side of the display.

Another option is to use a chip which is designed to be used with this type of display. The most commonly used chip is max7219.

And it is a fairly bad idea to use pin 1.

Thanks for all your replies!!

I've only got an arduino learning kit, it has no transistors and only one IC (74HC595). Resistors I have are 8x 220, 5x 1k, 5x 10k. I gonna buy more stuff but atm it's all I have.

Thanks for mentioning max7219! It is definitely the way to go.

And yes, I'm now aware why using pin1 is a bad idea. I've spend like 30 mins to guess why the thing suddently behaved weird. It was because I wanted to debug something hence I put Serial.begin() into setup(). After that pin1 was high all the time even when I tried blinking a led with it.

So after everything here is what I've done to make it work safely:

/*
 * Code sample: show arduino uno r3 running time with a 4-digit led display scanning digits by segments
 * so only one segment is active at a time hence the current into grounded pins (one of d1..d4 at a time)
 * is limited to a current through a single led segment.
 * 
 * Author: https://forum.arduino.cc/index.php?action=profile;u=1055190
 * Wiring: http://wiki.keyestudio.com/images/0/02/6954.png
 * 
 * Resistors I used are 220 Ohm (because I only have 8x of those) but it is still OK since I only lit segments one at a time.
 * 
  */

int a = 1;
int b = 2;
int c = 3;
int d = 4;
int e = 5;
int f = 6;
int g = 7;
int dp = 8;

int segmentPins[] = {a, b, c, d, e, f, g, dp};

int d1 = 12;
int d2 = 11;
int d3 = 10;
int d4 = 9;

int selectPins[] = {d1, d2, d3, d4};

int digits[] = {
  B11111100,
  B01100000,
  B11011010,
  B11110010,
  B01100110,
  B10110110,
  B10111110,
  B11100000,
  B11111110,
  B11110110,
};

int digitsN = sizeof(digits) / sizeof(digits[0]);

void setup() {
  for (int i = 0; i < 8; i++) {
    pinMode(segmentPins[i], OUTPUT);
  }

  for (int i = 0; i < 4; i++) {
    pinMode(selectPins[i], OUTPUT);
  }
}

void loop() {
  int s = millis() / 1000;
  int m = s / 60;
  s %= 60;

  display(m / 10, m % 10, s / 10, s % 10, 1000);
}

void selectDigit(int pos) {
  pos--;

  for (int i = 0; i < 4; i++) {
    digitalWrite(selectPins[i], i == pos ? LOW : HIGH);
  }
}

void showDigit( int pos, int d) {
  selectDigit(pos);

  if (d >= 0 && d < digitsN) {
    int bits = digits[d];
    // Lit segments one by one.
    for (int i = 7; i >= 0; i--) {
      if (bits & 1 == 1) {
        digitalWrite(segmentPins[i], HIGH);
        delayMicroseconds(500);
        //delay(100); // Uncomment to observe the by-segment rendering.
        digitalWrite(segmentPins[i], LOW);
      }
      bits >>= 1;
    }
  }
}

void display(int d1, int d2, int d3, int d4, int duration) {
  unsigned long t = millis() + duration;

  do {
    showDigit(1, d1);
    showDigit(2, d2);
    showDigit(3, d3);
    showDigit(4, d4);
  } while (t > millis());
}

The thing running (don't pay attention to the ground wire in the bottom, it goes to a multimeter):

Ok, good solution, given your limited components. This should be safe. The effect of multiplexing the display one segment at a time will be similar to using higher value series resistors, making the display dimmer, by reducing the average current each segment receives. Instead of being lit for 25% of the time, each segment is lit for only 3% of the time. How do you find the brightness?

PaulRB:
Ok, good solution, given your limited components. This should be safe. The effect of multiplexing the display one segment at a time will be similar to using higher value series resistors, making the display dimmer, by reducing the average current each segment receives. Instead of being lit for 25% of the time, each segment is lit for only 3% of the time. How do you find the brightness?

It looks pretty bright. I cared more about flickering.