I have the original software behaving well after sorting the inconsistencies of design choices and one flat-out error.
You won't need resistors.
You do have to remove the digitalWrites in setup to "close" and "open", they defeat the INPUT_PULLUP lines above it.
The limit switch sense is odd: one pair thinks between limits is a closed switch, the other pair thinks between limits is an open switch.
I simulated the project with those changes in mibd. I used LEDs for the motors, slide switches for the limit switches and NO pushbuttons and was careful about switch sense.
The serial reading responds well to
close#
open#
y#
The pushbuttons start the process they are named for, and the slide switches can be used to stop them when they get there.
It's a bit tricky to operate, use your common sense and ask if you can't get it to close and stop, open and stop with either the pushbuttons or serial input.
See it here
I'll stop working on this copy, any other contributors can run with a copy of it for themselves. I am working to make the entire thing more sensible whilst keeping it as unsophisticated as it is now. It works, you don't care so neither do I.
It is down to getting the wiring right. Once you say you can work the simulation, or if I find remaining errrs to fix, We can go over step by step exactly which switches need NC contacts and which were interpreted as NO, normal in this case meaning NOT at the limit.
I am happy to get this going with you. I am not happy with the code, and you may start to see suggestions and even full solutions coded in a more "correct" manner from other contributors. No worries, we do that all the time. Since you are without the skillz, I advise staying with the code which is now very close to deployable.
If at some point you decide you want to start to be able to do this kind of thing yourself, we here.
I'm not in the lab just now, but I will place comments in the code where I tweaked it when I get the chance.
a7
