Here are some suggestions for developing code:
Start from a known working point, such as an example sketch.
Write the skeleton of your program using English language pseudo-code in comments. Say things like
// check the ambient light level
// if the light level is bright, check the door state (open or closed)
// if the door is closed, open it
// if the light level is dark, check the door state
// if the door is open, close it
Now start writing the real code, using your comments as a guide. Click the 'Verify' button in the IDE FREQUENTLY, as in, every statement or three. If verification fails, fix it before you move on. If you write a whole bunch of code and then go to verify, you'll have a harder time finding the problem.
Also as a tip, for your constants, avoid generic names like HIGH or LOW. Define and use things like DOOROPEN or DOORCLOSED, makes debugging a lot easier.