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(){
Serial.begin(9600);
irrecv.enableIRIn();
irrecv.blink13(true);
pinMode(vibrdigPin, INPUT);
pinMode(buzzerPin, OUTPUT);
}
void loop() {
if (irrecv.decode(&results)){
switch(results.value){
case 0xFFA25D: //Keypad button “1”
int dvalue = digitalRead(vibrdigPin);
Serial.print("Digital value: “);
Serial.print(dvalue);
Serial.print(” ");
if (dvalue == 1)
{
digitalWrite(buzzerPin, HIGH);
delay(1000);
}
}
switch(results.value){
case 0xFF629D: //Keypad button “2”
digitalWrite(buzzerPin, LOW);
}
switch(results.value){
case 0xFFE21D: //Keypad button “3”
digitalWrite(buzzerPin, HIGH);
}
irrecv.resume();
}
}