problems with cases

I am working on a project that uses cases to do things. It’s a dead bolt that uses RF key fob. It checks for unlock or lock button press and also checks if the lock is locked or not. I thin for some reason the lock state isn’t changing because I am only getting cases 2 and 4.

I watered down the output actions to light blinks for each case (case 1 blinks once case 2 twice etc…)

after each case executes it changes the Boolean lock state (locked = true)

Code

/*
This code will open a deadbolt
with RF remote or buttons and
knows the position of the lock
based on last action

12 RF/Button lock
13 RF/Button unlock
10 button lock
11 button unlock

8 Buzzer
9 Servo

A0 Servo location

4 LED lock
5 LED unlock

*/
const int lockrf = 12; //input to lock rf
const int ulockrf = 13; //input to unlock rf
const int butlock = 10; // button lock
const int butulock = 11; // button unlock
const int ulockled = 4; //led in lock button
const int lockled = 2; //led in ulock button

#include <Servo.h>
boolean lockstate = true;

void setup()
{
Servo deadbolt;

deadbolt.attach(9);
pinMode(butlock,INPUT);
pinMode(butulock,INPUT);
pinMode(ulockrf,INPUT);
pinMode(lockrf,INPUT);

pinMode(ulockled,OUTPUT);
pinMode(lockled,OUTPUT);

}
void loop()
{
//variables for code

int lockdeg = 0;
int ulockdeg = 90;

int lock_case = 0;

digitalWrite(ulockled,LOW);
digitalWrite(lockled,LOW);

if (digitalRead(lockrf)==HIGH || digitalRead(butlock)==HIGH && lockstate == true )//locked press lock
{
lock_case=1;
}

if (digitalRead(lockrf)==HIGH || digitalRead(butlock)==HIGH && lockstate == false) // ulocked press lock
{
lock_case=2;
}
if (digitalRead(ulockrf)==HIGH || digitalRead(butulock)==HIGH && lockstate == true)//locked press ulock
{
lock_case=3;
}

if (digitalRead(ulockrf)==HIGH || digitalRead(butulock)==HIGH && lockstate == false) // ulocked press ulock
{
lock_case=4;
}

switch(lock_case)
{
case 1:
{

digitalWrite(lockled,HIGH);
delay(500);

digitalWrite(lockled,LOW);

delay(10);
lockstate=true;
break;
}
case 2:
{
digitalWrite(lockled,HIGH);
delay(500);

digitalWrite(lockled,LOW);
delay(500);
digitalWrite(lockled,HIGH);
delay(500);

digitalWrite(lockled,LOW);
lockstate=true;
break;
}
case 3:
{
digitalWrite(lockled,HIGH);
delay(500);

digitalWrite(lockled,LOW);
delay(500);
digitalWrite(lockled,HIGH);
delay(500);

digitalWrite(lockled,LOW);
delay(500);
digitalWrite(lockled,HIGH);
delay(500);
digitalWrite(lockled,LOW);
lockstate=false;
break;
}
case 4:
{
digitalWrite(lockled,HIGH);
delay(500);

digitalWrite(lockled,LOW);
delay(500);
digitalWrite(lockled,HIGH);
delay(500);

digitalWrite(lockled,LOW);
delay(500);
digitalWrite(lockled,HIGH);
delay(500);
digitalWrite(lockled,LOW);
delay(500);
digitalWrite(lockled,HIGH);
delay(500);
digitalWrite(ulockled,LOW);

delay(10);
lockstate=false;
break;
}
}
}

I feel like I've already answered exactly this one today.

When I make code like this:

if (digitalRead(lockrf)==HIGH || digitalRead(butlock)==HIGH && lockstate == true )

I always tend to err on the side of too many parenthesis even if they aren't absolutely necessary just in case I got my order of operations messed up.

Do you mean:

if ((digitalRead(lockrf)==HIGH || digitalRead(butlock)==HIGH) && lockstate == true )

or

if (digitalRead(lockrf)==HIGH || (digitalRead(butlock)==HIGH && lockstate == true) )

When posting code, always use code tags.

The box where you post your message has some symbols above it: </> B I U S and so forth. Click on the </> symbol to get the code tags.