boot crashes if inputs are not toggled. Why is this?

I notice that a couple of my programs will crash if the inputs are not toggled. What can cause this?

Which board, what inputs?

Do you mean that the sketch doesn't upload, or that your code hangs after upload?

Thanks! And yes I mean that it's the code that hangs when powered on. It does run just fine but it's delicate. I have to toggle at least one of the digital inputs to even get it to run.

This is on a Nano with 328P.

I will hazard a guess that the code waits for an input to change. But, that's pure speculation. If you post the code, we can offer a better suggestion.

As said above, post your complete code.

You can't toggle an input pin. You can only toggle outputs. Therefore what you are saying is wrong anyway. As well as being wrong in fact. You have something else going on that you don't realise and this action just has an accidental effect like providing a delay between operations or something similar.

I don't mean toggle, I do mean change states from hi/lo etc on the digital inputs.

Can you please post a copy of your sketch, using code tags?
They are made with the </> icon in the reply Menu.
See section 7,148850.0.html

Thanks… Tom… :slight_smile:

I don't mean toggle, I do mean change states from hi/lo etc on the digital inputs.

Toggle is the right word however:-
There is nothing you can do to an input pin to change its state from code. If you write to an input pin all you will do is to turn on and off the internal pull up resistor. As I said something else is happening that this just happens to fix just by chance.

Is it possible that your program is trying to read an input pin that is floating and thus giving random values.

This would be cleared up immediately if you post your code as requested in Reply #3


Reading between the lines, it sounds like the OP believes that his program hangs if he doesn't change the state of some digital inputs by actuating some input device. Maybe he's pressing a switch with his finger. My wild guess is that his code intentionally waits for an input to change state before proceeding. Until he posts code, though, along with a schematic, or at least a clear description of the inputs, it's just conjecture.