Why are continuously setting the pin modes in the loop? Once should be enough and in the setup function.
Paul