user23451: I want to communicate Arduino A to Arduino B by using RF module. But my RF module (Tx- XLPCF20, Rx- XY-R01A) only consist of 4 pins of data pin where it can send 4 bits of data only. So, I want to develop a new encoding to send data by using 4 bits of data. How should i do for the coding since I don't want to use serial write for coding. Any suggestion? Help me please. If u can give me the coding, I'm beyond thankful.

user4143: You have 4 channels of raw HIGH/LOW communication.  How you use them is up to you.
The simplest method is to use an asynchronous serial protocol:

Use Serial: Connect the TX of one Arduino to channel 1 at the TX, and RX channel 1 to RX on the other Arduino
Use SoftwareSerial: The same as above but you choose the pins
Use VirtualWire: very similar to SoftwareSerial

For higher speeds, since you have 4 channels, you could use a synchronous serial communication protocol. It should be perfectly possible to connect three of the channels to SPI and communicate as if it were talking directly to an SPI device - one channel to SCK, one to MOSI and one to SS. The other end has SCK, MOSI and SS but running in slave mode.
No need to "invent" a 4-bit protocol, it's too much work.

23451: <p>I want to communicate Arduino A to Arduino B by using RF module. But my RF module (Tx- XLPCF20, Rx- XY-R01A) only consist of 4 pins of data pin where it can send 4 bits of data only. So, I want to develop a new encoding to send data by using 4 bits of data. How should i do for the coding since I don't want to use serial write for coding. Any suggestion? Help me please. If u can give me the coding, I'm beyond thankful.</p>
 4143: <p>You have 4 channels of raw HIGH/LOW communication.  How you use them is up to you.</p>

<p>The simplest method is to use an asynchronous serial protocol:</p>

<ul>
<li>Use Serial: Connect the TX of one Arduino to channel 1 at the TX, and RX channel 1 to RX on the other Arduino</li>
<li>Use SoftwareSerial: The same as above but you choose the pins</li>
<li>Use VirtualWire: very similar to SoftwareSerial</li>
</ul>

<p>For higher speeds, since you have 4 channels, you could use a <em>synchronous</em> serial communication protocol. It should be perfectly possible to connect three of the channels to SPI and communicate as if it were talking directly to an SPI device - one channel to SCK, one to MOSI and one to SS. The other end has SCK, MOSI and SS but running in slave mode.</p>

<p>No need to "invent" a 4-bit protocol, it's too much work.</p>
