explain how a wrong state or a race condition is transforming
for (pos = maxPos; pos >= 1; pos -= 1) { // goes from max to 0 degrees @ 1 degree steps
shutterServo.write(pos); // tell servo to go to position in variable 'pos'
delay(15); // waits 15 ms for the servo to reach each position
}
into a mere shutterServo.write(0);
whilst
for (pos = maxPos; pos >= 1; pos -= 1) { // goes from max to 0 degrees @ 1 degree steps
shutterServo.write(pos); // tell servo to go to position in variable 'pos'
delay(20); // waits 15 ms for the servo to reach each position
}
would not
I don't see it. that code is blocking, there is no outside variables being taken into consideration
sure maxPos could somehow have been overwritten if there was some kind of memory overflow somewhere but there is no pointer or array walkthrough that could do that, it's pretty straightforward code
My bet is that it's not code related but there is something else at play, hardware wise possibly.
There are two things being controlled:
Shutters which open at, let's say, 80 F and close at 75 F,
and a fan, which turns on at say 85 F and off at 80 F.
Based on a similar program I saw, I thought I'd need two flag variables apiece.
If I understand you correctly, I just need one for each operation.
Thanks for pointing this out - I'll play with the code some more...
Not fan speed, just fan on/off. It's just a temperature reading from the sensor.
Tells the code to do different things depending on temperature.
Not OK?
That sounds like what I'm experiencing, running the servo from a 5V 2A source. For some reason, increasing the delay to write servo position seems to have resolved the issue. The strange thing was that it only affected the servo rotation in one direction, so increased load one way was suspected -- but there was no load on servo.