How to change the code so that it continue monitor Input

Guys help please!
So i have this problem, i want to combine vibration sensor and IR remote control so that it become a remote control vibration alarm. But then i realize when i press ‘1’ in control, the vibration sensor will only sense the input it read during the moment i press the ‘1’. I want to modify my code so that it can continue monitor the input of vibration sensor when i press ‘1’, until i press other button or until it is triggered, it won’t stop monitoring the input, HELP!!

This is my messy code
#include <IRremote.h>

const int RECV_PIN = 7;

const int buzzerPin = 10;
const int vibrdigPin = 6;
IRrecv irrecv(RECV_PIN);
decode_results results;

void setup(){
pinMode(vibrdigPin, INPUT);
pinMode(buzzerPin, OUTPUT);


void loop() {

if (irrecv.decode(&results)){
case 0xFFA25D: //Keypad button “1”
int dvalue = digitalRead(vibrdigPin);
Serial.print("Digital value: “);
Serial.print(” ");
if (dvalue == 1)
digitalWrite(buzzerPin, HIGH);


case 0xFF629D: //Keypad button “2”
digitalWrite(buzzerPin, LOW);

case 0xFFE21D: //Keypad button “3”
digitalWrite(buzzerPin, HIGH);


Make yourself a variable to hold the state of your program. When you get a 1 from the remote set it to 1. Then later in the loop you can test that variable and decide what the program should do.


int state = 0;

if (get a '1' from remote){
   state = 1;

if (get '2' from remote){
   state = 2;

if (state == 1){

   read whatever sensor and do state 1 stuff
 else if (state == 2){
   do state 2 stuff

extra credit for changing the if else if part into a switch case.