My pro mini is writing values from a photocell to the serial monitor, reading correctly until exceeding the threshold, then stops and will not restart, even when the cell is returned to darkness. Assuming this is a software error. Would appreciate advise. Thanks.

Sorry, should have named them appropriately for the forum. I have a bunch of pro mini boards, each with a photocell installed within a short length of pipe on one end and an LED on the other. The LED responds to a Maxsonar sensor. I need everything; servos, dc motors, LED's, sound, and steppers, to all fire at the same time. I am sure this can be accomplished programmatically but after months of advise and experiment, I opted for this not so elegant method. The moment the LED lights, the whole shebang cranks up.

The sketch worked fine before writing the "if statement", the stepper responding perfectly to the switches as it passes back and forth (a printer salvage).

The sketch worked fine before writing the "if statement", the stepper responding perfectly to the switches as it passes back and forth (a printer salvage).

I can understand your frustration, but it doesn't help if you don't describe what now happens. As the light level goes up, the motor starts moving back and forth. When the light level drops, what happens?

No more serial prints? No more stepper movement? The stepper doesn't stop at the limit switches?

There is nothing obviously wrong with the code, that I can see.

Quote

The LED responds to a Maxsonar sensor.

What LED? What Max Sonar sensor? Neither of these appear to be part of your sketch.

At this point, nothing happens. The serial monitor reads the values right up until it arrives at the threshold, then stops, gets stuck at 900, and ceases to continue reading. Only after exceeding the threshold is the stepper supposed to begin which, of course, is impossible without current data. I have noticed similar behavior with the other boards but the intended action occurs, even though the data stops at the threshold. When the photocells are covered, the serial monitor once again lists the values.

Now the serial monitor displays nothing until the threshold has been surpassed, then just a single digit and locks up as before. If the marked out Serial.println is included, the lesser values are listed up to the threshold but stop. Whew! This would seem a simple analog problem, no different that the previous five boards with what seems to be the exact same setup.

It should not have been necessary, and if the problem has 'gone away' when you added these then you are just avoiding it by a coincidence of timing and have not really fixed the problem. The print statements were intended to let you know what was happening inside your sketch, not to change the behaviour.

I only provide help via the forum - please do not contact me for private consultancy.