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
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?
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;
}
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).