(IMP)RF signal control interupt(help fast plz)

Well both the codes work perfectly and i recieve "RKANE IS AWESOME" on the recieving terminal.
What i want help with is the that i want to control the sending of this data with interupt,i.e when i interupt only then the rf shuld transmit.This is a bit complex code as i have used machester coding (i refered a few sites and found it),in reality i am not really requiring such a complex code ALL i really want to do is that i shuld reicieve a signal at the reciever when interupt is detected at the transmtter end. any help is much appreciated.

Well in my project i am using rf 434 to send and recieve data heres my code

Transmitter:

void setup(){
  pinMode(2, OUTPUT);
}

void loop(){
  
 
  rf_send('R');
  rf_send('K');
  rf_send('A');
  rf_send('N');
  rf_send('E');
  rf_send(' ');
  rf_send('I');
  rf_send('S');
  rf_send(' ');
  rf_send('A');
  rf_send('W');
  rf_send('E');
  rf_send('S');
  rf_send('O');
  rf_send('M');
  rf_send('E');
  rf_send('#');
  delay(5000);
  //v++;
}

void rf_send(byte input){
  int i;
  
  for(i=0; i<20; i++){
  digitalWrite(2, HIGH);
  delayMicroseconds(500);
  digitalWrite(2, LOW);
  delayMicroseconds(500);
}

  digitalWrite(2, HIGH);
  delayMicroseconds(3000);
  digitalWrite(2, LOW);
  delayMicroseconds(500);
  
    
  for(i=0; i<8; i++){
  if(bitRead(input,i)==1)
  digitalWrite(2, HIGH);
  else
  digitalWrite(2, LOW);
  delayMicroseconds(500);
  
  if(bitRead(input,i)==1)
  digitalWrite(2, LOW);
  else
  digitalWrite(2, HIGH);
  delayMicroseconds(500);
}//i

  
  digitalWrite(2, LOW);
}

RECEIVER

int i, good, k;
byte data_in;
void setup(){
  attachInterrupt(1,data_incoming,RISING);
  pinMode(3, INPUT);
  pinMode(13, OUTPUT);
  Serial.begin(115200);
}//setup

void loop(){
  
  
}//loop






void data_incoming(){
    
    
    for(i=0; i<100; i++){
      delayMicroseconds(20);
      good=1;
      if(digitalRead(3)==LOW){
      good=0;
      i=100;
      }
    }//for
      
    if(good==1){
    detachInterrupt(1);
    while(1){
      if(digitalRead(3)==LOW){
        delayMicroseconds(750);

        for(i=0; i<8; i++){
          if(digitalRead(3)==HIGH)
          bitWrite(data_in, i, 1);
          else
          bitWrite(data_in, i, 0);
          delayMicroseconds(1000);
        }//for
        if(data_in=='#')
        Serial.println("");
        else
        Serial.print(char(data_in));

       break;//secondtwhile
      }//low kickoff
      
    }//second while
    
    }//good check

  attachInterrupt(1,data_incoming,RISING);
  
  
  
}//routine

ALL i really want to do is that i shuld reicieve a signal at the reciever when interupt is detected at the transmtter end

What is going to generate the interrupt? I'm nearly certain that you do NOT need interrupts.

PaulS:

ALL i really want to do is that i shuld reicieve a signal at the reciever when interupt is detected at the transmtter end

What is going to generate the interrupt? I'm nearly certain that you do NOT need interrupts.

A 5v supply is coming from a IR sensor which must interupt the rf tamsmitter and then it shuld transmit

Like all Arduino projects you need to go about this step by step.

First of all get the Arduino to transmit whenever a switch is pressed - that will be simpler than the IR decoder. That will allow you to develop the logic for controlling the transmission.

Then write a piece of code to blink an LED when the IR signal is detected. The blink will be equivalent to the switch press.

Then merge the two concepts.

I share @PaulS's suspicion that an interrupt is unnecessary. Interrupts can be very difficult to debug. Why not just check the status of the pin the LED input is connected to in every iteration of loop?

...R

Robin2:
Like all Arduino projects you need to go about this step by step.

First of all get the Arduino to transmit whenever a switch is pressed - that will be simpler than the IR decoder. That will allow you to develop the logic for controlling the transmission.

Then write a piece of code to blink an LED when the IR signal is detected. The blink will be equivalent to the switch press.

Then merge the two concepts.

I share @PaulS's suspicion that an interrupt is unnecessary. Interrupts can be very difficult to debug. Why not just check the status of the pin the LED input is connected to in every iteration of loop?

...R

Thks for ur reply following are simple codes which i am using

Interupt

long start = 0;

volatile long lastButtonPush = 0;

void setup()
{
  //start the serial
  Serial.begin(9600);
  
  //LED output
  pinMode(13,OUTPUT);
  //switch input
  pinMode(2,INPUT);
  
  //set the pull-up on the switch
  digitalWrite(2,HIGH);
  
  //seed the random number generator
  randomSeed(millis());
  
  //wait random time from 1 to 3 seconds
  delay(random(1000,3000));
  
  //turn the light on
  digitalWrite(13,HIGH);
  
  //attach the interrupt
  attachInterrupt(0,react,FALLING);  
  
  //get the start time
  start = millis();
}

void loop()
{
}

void react()
{
  long fin = millis();
  
  if(fin - lastButtonPush > 500)
  {  
    Serial.print("Your reaction time: ");
    Serial.println(fin - start);
  }
  
  lastButtonPush = fin;
}

RF transmitter

#include <VirtualWire.h>
#include <VirtualWire_Config.h>

void setup()
{Serial.begin(9600);

vw_setup(2000);
vw_set_tx_pin(8);
}
void loop()
{
  if(Serial.available())
  {
    char c = Serial.read();
    if(c == '1')
    {
      vw_send((uint8_t *)c,1);
    }
    else if (c == '0')
    {
      vw_send((uint8_t *)c,1);
    }
  }
  
}

RF reciever

#include <VirtualWire.h>
#include <VirtualWire_Config.h>

void setup()
{
  pinMode(13,OUTPUT);
  digitalWrite(13,LOW);
  
  vw_setup(2000);
  vw_set_rx_pin(7);
  vw_rx_start();
}

void loop()
{
  uint8_t buflen = VW_MAX_MESSAGE_LEN;
  uint8_t buf[buflen];
  
  if(vw_get_message(buf, &buflen))
  {
    for(int i=0;i<buflen;i++)
    {
      if(buf[i] == '1')
      {
        digitalWrite(13,HIGH);
      }
      else if(buf[i] == '0')
      {
        digitalWrite(13,LOW);
      }
    }
  }
}

i want to merge the interupt and rf transmitter code and in the above code i am able to control the led on the reciever by giving input on the serial monitor of the transmitter .
what i wish do is to be able to blink the led on the reiciever arduino once when interup is detected on the arduino with RF transmitter.

Why have you any delay() in the setup() for the interrupt code? Why is is random? I doubt if either is needed.

NEVER NEVER put serial.print() statements in an interrupt routine. Just use the routine to record the time and quit - do the comparisons elsewhere, outside the interrupt routine.

What is the timing supposed to do? I thought you just want to transmit something when an IR signal is detected? Why not just record True of False depending on whether the IR signal is detected?

Where does vw_setup() come from? - there seems to be some code missing.

The transmitter code seems to be designed to transmit if it receives a '1' from the serial monitor. If you want that to be sent when the IR signal arises then that test has to replace the if(Serial.available ... etc).

...R