Arduino behaves non-deterministic?

What other inputs are you using? You may be getting E-M interference.