carlos_oliveira_10:
Arduino 1:
- it has code to read sensores and send data(by RF433) to Arduino 2;
- it has also 2 digital outputs.
Arduino 2:
- it receive data from Arduino 1 (by RF433);
- and I want send a signal by RF433 to activate the digital outputs on Arduino 1.
Could some one help me to solve this problem?
For you it is easy, as you do not want to send and receive at the same time.
Just use two different Arduinos to develop your application: One Arduino as sender, and one Arduino as receiver.
Wenn ready with the programming logic, put the sending/receiving logic all together into one sketch. When using VirtaulWire as a library, the sending Arduino will never receive its own transmission, as the VirtualWire-Library is not able to send and receive at the same time.
But if you really would need a thing that one Arduino receives its own RF transmission, for debugging reasons or what else, it would be easy to develop such code for these cheap RF sender/transmitter pairs.
But you cannot use VirtualWire. You'd have develop your own code that works like this:
Sender logic:
The sender sends its bits from a user function that is blocking the Arduino while sending. So if the transmission lasts 30 milliseconds (for example) or more, the sender will user ON/delay/OFF/delay to push all the bits out to the sender. After 30 milliseconds everything is sent and the rest of the user code is executed.
Receiver logic:
The receiver has set up a hardware CHANGE interrupt on the Arduino: If something is received within the interrupt handler, the bits and bytes are stuffed into a receive buffer. When the receive buffer is complete, it is checked (CRC checksum) and if it is complete and correct, the contents is stuffed into a FIFO buffer. The user code can then later retrieve the data from the FIFO-buffer where the received data are waiting.
This is not rocket science, but it is a little bit more complicated than writing "#include <VirtualWire.h>" into your sketch.