Automated locking system with accelerometer

Hi everyone.
I am recently doing a school project which the title is Automated Locking system.
The project consist of :
Arduino UNO
Accelerometer ADXL 345
Electric LOCK

The project is such that at a range of value of X, Y and Z of the accelerometer, i want the eletric lock to lock by itself and at a given range it unlocks automatically.
Eg. if(X< 200)
electrick.lock is unlock
else if (X > 200)
electric lock is lock.

However I am having some trouble with the sketch of how to write it.
I would really appreciate if anyone can help me.

Best Regards

Post your best attempt at the sketch and we will try to help.

I suspect you should have a dead-band between LOCK and UN-LOCK. For example

if (x < 200) {
  // unlock
}
if (x > 220) {
  // lock
}

...R

Duplicate locked.