74hc595 still works without 5V or GND

I have been playing around with a 74hc595 and 8 leds (following an Elegoo tuto) and all seems to be working. I only added a capacitor to VCC/GND because I read it should be mandatory.

Anyway, if I pull the 5V, the LED's still light up. a bit less bright but they do. If I connect 5V again and pull GND, the first 3/4 LED's will still light up.

This happens with and without the capacitor.

Is this normal?

Just to be sure the code:

//www.elegoo.com
//2016.12.9 

int tDelay = 100;
int latchPin = 11;      // (11) ST_CP [RCK] on 74HC595
int clockPin = 9;      // (9) SH_CP [SCK] on 74HC595
int dataPin = 12;     // (12) DS [S1] on 74HC595

byte leds = 0;

void updateShiftRegister()
{
   digitalWrite(latchPin, LOW);
   shiftOut(dataPin, clockPin, LSBFIRST, leds);
   digitalWrite(latchPin, HIGH);
}

void setup() 
{
  pinMode(latchPin, OUTPUT);
  pinMode(dataPin, OUTPUT);  
  pinMode(clockPin, OUTPUT);
}

void loop() 
{
  leds = 0;
  updateShiftRegister();
  delay(tDelay);
  for (int i = 0; i < 8; i++)
  {
    bitSet(leds, i);
    updateShiftRegister();
    delay(tDelay);
  }
}

This is called "parasitic powering". Current is finding its way to the chip and then to ground by whatever route it can find, any other connections. This is not good for the chip and can lead to its premature failure.

Ok, but how to prevent? (next to just leave gnd and 5V plugged)

You can't. You, as the designer of the circuit, must ensure that 5V and ground are connected whenever parasitic powering could otherwise occur.

It is because each input on the chip has diodes to Vcc and GND, this means if just one input is high it can draw Vcc power from that and one low input will give it GND.
This also explains how you can avoid parasitic power, just set all signals to low and there is nowhere the chip can get its power.

Makes sense. Thank you!

HKJ-lygte:
This also explains how you can avoid parasitic power, just set all signals to low and there is nowhere the chip can get its power.

Quite correct. Or set all signals to high, so there is no way for current to reach ground. Either way, current cannot flow, and parasitic powering cannot occur.

PaulRB:
Quite correct. Or set all signals to high, so there is no way for current to reach ground.

Only if it is the ground to the chip and all outputs that has been disconnected. :astonished:

In the case of a HCMOS logic chip, there is never any reason not to connect 5 V as the quiescent current consumption is trivial. :roll_eyes: