Two servos, two doors. They open as they should in the initial loop statement. Before the command to close the doors happens, the LED lights up when it shouldn't until the command to close them takes place. Eventually, the doors close, LED goes out and it starts again. If they run without the LED, they open and close as they should (test). It's like the code to close the doors doesn't even exist until the script is complete. Been working on this all day! Servos powered from Nano. Any help would be appreciated. Thanks in advance.
Text output is as it should be but doesn't sync with what's actually happening. See attached video.
Opening
closing L
closing R
turning on LED
turning off LED
opening
closing L
closing R
turning on LED
turning off LED
opening
closing L
closing R
turning on LED
turning off LED
opening
closing L
closing R
turning on LED
turning off LED
opening
closing L
closing R
turning on LED
turning off LED
opening
07:42:08.802 -> opening
07:42:13.795 -> closing L
07:42:13.843 -> closing R
07:42:18.862 -> turning on LED
07:42:23.884 -> turning off LED
07:42:23.884 -> opening
07:42:28.880 -> closing L
07:42:28.926 -> closing R
07:42:33.962 -> turning on LED
07:42:38.949 -> turning off LED
07:42:38.949 -> opening
07:42:43.915 -> closing L
07:42:44.009 -> closing R
07:42:49.024 -> turning on LED
07:42:54.008 -> turning off LED
07:42:54.008 -> opening
07:42:59.022 -> closing L
07:42:59.064 -> closing R
07:43:04.080 -> turning on LED
07:43:09.109 -> turning off LED
07:43:09.109 -> opening
07:43:14.094 -> closing L
07:43:14.141 -> closing R
07:43:19.181 -> turning on LED
07:43:24.188 -> turning off LED
How do you have the LED wired? Does it turn on when the output if LOW, or when the output is HIGH?
Please verify that the close position on the servos is actually closing the doors, and the open position is actually opening the doors. Would be confusing if you got that reversed.
LED wired with resistor on pin 12. The doors are actually opening and closing as per video. LED is just coming on too early midway while doors are open and turning off when it should be coming on, when doors close.
I can see the doors are opening and closing, but are they opening and closing as the code intends, or is the operation reversed so that they close when you send the commands to open and open when you send the commands to close?