Network issue

I am having a problem with my Arduino project staying connected to my Ethernet switch, it keeps losing connection, I have my board set up with a photo sensor to work as a counter. It connects to my network but constantly drops out loses the connections and I have to recycle power and or switch ports... Really need help on why this keeps happening, tried everything, built new boards, replaced Cat5 and connectors but same results.

I have attached my code if anyone can see if there is something in it that would cause it to drop out from my Network

Thanks

BreakBeamCounter12.ino (2.64 KB)

Ethernet switch implies hardwired.

What tells you that you are losing the connection?

.

Yes hard wired in to the switch...it keeps losing connections with the switch...no LED status on board or switch, loss communications...to re-establish connection I change ports or reboot

The only issue I know with the W5100 Ethernet Shield are with the resistors. The clones have the wrong values.

.

Cape1verdean:
tried everything, built new boards, replaced Cat5 and connectors but same results.

You have said nothing to suggest the code or the Ethernet shield are suss.
What is Arduino itself actually doing while you are having all this grief?
How is this all powered?

The Arduino still works as designed, takes counts but just stops communicating with the switch, it is powered with a 12VDC power supply...I have attached how the screw shield is wired