Relay Controlled Door with Limit switches.

tuffyt:
I wrote the code the door opened and closed no problem. Limit switches are working properly.
I made several attempts with this code but main lock switch (lockPin) did not work properly.
If the main lock is off can not perform any function. This must be the first priority. As I told,
code works perfectly in this state but main lock (lockPin) I can't control switch.

Well, I can't figure out from this paragraph, exactly what your problem is.

What does the relay do? What causes lockPin to change state? What makes the lock actually move?
What do you mean by "If the main lock is off" and "can not perform any function" and "I can't control switch"?

To clarify, what is "off" in terms of "main lock"? what is "main lock"? Do you mean that if it's off, you can not perform and function, or that if it's off, you don't want it to perform any function?

You really need to describe your problem more clearly. Tell us what you expect the code to do, and what it's actually doing. The terms you use to tell us these things need to be in the same terms you use in the code.

You can start by telling us what activates the input pins, and if they are switches exactly how you have them wired. For example, if lockPin is connected to a switch, what is the other end of the switch connected to? Are there any resistors in that switch circuit (if you say no, you'd better change something).