Block Virtual Wire Receive Data

Hi everyone,

I have a bit of a problem that I have not been able to solve yet.

I have 2 arduinos. 1 sends a signal when low voltage is seen on my alarm (door is open). The other gets that signal and then starts my stereo system for when I return home.

The problem is that I currently have it set up so that it turns on when i leave. This is because the arduino in my closet (the one tied into my security system) senses the low voltage and sends the signal to the arduino next to my music player. Then, the whole thing starts. I need to find a way to disable the receiver function for a time period when i leave.

I have tried to delay reading for messages when i make my escape and it does not solve the issue. As soon as the delay runs out the chip picks up the message from the chip and the music starts. It seems like the message is being held in a buffer or the receiver chip somehow. I need to find a way to wipe all of the messages out of the chip after i have escaped. I have also tried to stop the receiver with (extern void vw_rx_stop():wink: and then I do (extern void vw_rx_start():wink: once i have had ample time to leave the house.

Closet file is the one that picks up low voltage and sends the signal (only when the door is open)

Main hub is the one that does most of the action. It is structured with a switch case for multiple modes. Right now i am only trying to get the first case to work properly.

Once the 1st case is executed the chip is primed to get the signal from the sender. Unfortunately the closet file sends the signal as soon as i leave.

If possible, i would like to only modify the main hub file as the closet file has been working flawlessly.

Any help you can provide will be greatly appreciated.

Thanks,

John

Main_Hub_File_Rev3.ino (13 KB)

Closet_File_Rev_2.ino (681 Bytes)

    TurnOn = 1;
    
  

  if (TurnOn = 1);

The assignment operator (=) is rarely used in an if statement. The equality operator (==) is far more common.

On the other hand, testing that a variable contains the value you just assigned to it is useless.

Your code format sucks. Put EVERY { on a new line. Put EVERY } on a line ALL BY ITSELF. Use Tools + Auto Format.

I don’t understand where you expect the delay to happen. If you want the alarm pin value to be above the threshold for some period of time, you need to record when it goes above the threshold. Set the time to 0 when the pin value goes below the threshold.

Periodically, if the time is not 0, see if now - then is greater than the interval you want. If it is, send the message.