Need help writing code for project after using AI bots didn't work

that is a good idea. I will do that shortly.... done (post #39)

If the sensor is at the door pointing out, it can't sense inside 2cm so to the sensor, the cat isn't there. It's why I say sense the area in front of the door from above or to the side.

Wokwi doesn't have real cats or real sensors.
It tests a simulation where what works is defined.

Same with people in a hall and I don't know what they wear,
I sense the floor from above instead and watch for that distance to change.

My Arduino randomly became unrecognizable by my PC so I had to return it and get another but I finally got this thing working. It may be an unpopular opinion here but ChatGPT was very helpful in generating code as someone with limited coding experience. It saved me a lot of time. It can take awhile to debug ChatGPT's code though which is annoying.

The main issue was getting the sensors to detect objects while the motor was running so I think I used "non-blocking" code to fix this.

Another issue was figuring out how to make sure the motor stopped when the door was at the fully closed and fully open positions. I tried to make it work by doing something along these lines:

Once the door is fully open (which can be timed based on how fast the nut on the lead screw moves) then try to close the door if the path is clear. If the path becomes obstructed (cat in doorway) while the door is closing then reverse motor direction to re-open door. In order to get door to fully open position again Arduino needs to time the duration of how long the motor was moving in the "closing door" direction so it can reopen it to the same position.

Couldn't figure this out and I figured it would be safer to just use a couple of cheap limit switches instead.

The stepper motor was also getting real hot but hopefully integrating the enable pins to disable the motor driver while it is not in use will help.

My next step will be to design and 3dprint mounts for the motor, switches, and sensors.