Code works in setup() but not in loop()

My code is reading two 8 bit shift registers and returning the 16 bit number. I first wrote the code with the load pulse and shift in in void setup() and it worked exactly as I want it to. However I move it into void loop() all i get in the serial monitor are zeros's. I dont have my o'scope with me so I am not ever sure if I am getting the load pulse.

int clockPin = 9;
int dataPin = 10;
int load = 8;
unsigned int valuelow = 0;
unsigned int valuehigh = 0;
unsigned int value = 0;
 
void setup(){
  
Serial.begin(9600);
pinMode(8, OUTPUT);
pinMode(10, INPUT);
pinMode(9, OUTPUT); 
pinMode(7, INPUT); 


  }
 

void loop(){
 

digitalWrite(load, HIGH);
delay(10);
digitalWrite(load, LOW);
valuelow = shiftIn(dataPin, clockPin, MSBFIRST);
valuehigh = shiftIn(dataPin, clockPin, MSBFIRST);
value = valuehigh * 256 + valuelow;
Serial.print(valuehigh); 
Serial.print("  ");
Serial.println(valuelow); 
Serial.println(value);

delay(2000);
 
}

You have problems with some code, so you posted some other code. I have to ask why?

I see your point, edited.

“I dont have my o'scope with me so I am not ever sure if I am getting the load pulse.”

Add a LED and 220R resistor to the pin.

Slow things down.

Does the LED follow digitalWrite(load, HIGH); and digitalWrite(load, LOW); ?

Show us a good schematic & image of your circuit wiring.
Posting images:

Attached is my schematic. The code worked fine when it was in setup, I don’t understand why i wouldn’t work when I move it into the loop.

test circuit parralel to serial .pdf (203 KB)

Does the LED in my posted suggestion toggle?

Is there a clock on the bottom shift register?

What is the part number?

Let’s see the wiring.

You need 100nF decoupling capacitors on the I.C.s

This code works and returns the proper value

int clockPin = 9;
int dataPin = 10;
int load = 8;
unsigned int valuelow = 0;
unsigned int valuehigh = 0;
unsigned int value = 0;

void setup(){
 
Serial.begin(9600);
pinMode(8, OUTPUT);
pinMode(10, INPUT);
pinMode(9, OUTPUT); 
pinMode(7, INPUT); 
digitalWrite(load, HIGH);
digitalWrite(load, LOW);
valuelow = shiftIn(dataPin, clockPin, MSBFIRST);
valuehigh = shiftIn(dataPin, clockPin, MSBFIRST);
value = valuehigh * 256 + valuelow;

 }


void loop(){



Serial.print(valuehigh); 
Serial.print("  ");
Serial.println(valuelow); 
Serial.println(value);

delay(2000);

}

So I connected my o'scope viewing load, clock, and data

I get a load pulse and clock pulses, but no data. I do get data on the very first run of the function, but on the subsequent loops there is no data pulses.

It's seems that I am able to load and shift out once fine, the following loads are not executing there for it shifts out zeros.

I will try to add a clear signal to see if that helps.

Any chance you could give us the part number?

SN74LS299N

Up until i now I have been downloading the code or hitting the reset button to run the code. I beleive the loss of power at board startup reset the logic. But shouldn't I load into the register when I ever I apply a load pulse?