LIFI code is WORKING but putting it into packets is a problem

Below are working codes for LIFI transmitter and reciever....
I wanted to transmit and recieve them in packets...
I have set a baud rate(1 for communication b/w pc to arduino & 2nd for arduino to component led(tx) and photodiode(rx)....

Transmitter:
char x;
void setup() {
Serial.begin(115200);
Serial1.begin(115200);
}

void loop() {
if(Serial.available()>0)
{
x=Serial.read();
Serial1.print(x);
}}

RECIEVER:
char x ;
void setup() {
Serial3.begin(115200);
Serial.begin(115200);
}
void loop() {
if(Serial3.available()>0)
{
x=Serial3.read();
Serial.print(x);
}
}

The serial input basics tutorial may be of interest.

Saifullah006:
Below are working codes for LIFI transmitter and reciever....
I wanted to transmit and recieve them in packets...
I have set a baud rate(1 for communication b/w pc to arduino & 2nd for arduino to component led(tx) and photodiode(rx)....

. . . code . . .

You want to form a packet from a number of bytes ? What format packets ? X25 or what ?

Is this a continuation of a previous thread of yours: http://forum.arduino.cc/index.php?topic=605120.msg4110532#msg4110532

6v6gt:
You want to form a packet from a number of bytes ? What format packets ? X25 or what ?

Is this a continuation of a previous thread of yours: http://forum.arduino.cc/index.php?topic=605120.msg4110532#msg4110532

I was thinking of putting 100bits or any no. that is possible in a single packet...I just want to see if it is possible easily for my begginer level of study...

This post is continuation in sense I have implemented the code finally but without packets...

A byte is a packet of 8 bits, sent one at a time. You are already sending 1 byte packets.

A packet is a series of bytes, sent in a continuous stream.

OK, but if you do want to experiment with packets with a payload of around 100 bits, round the number to a multiple of 8 bits (so you have a whole number of bytes), plan to have a length indicator and maybe a byte (or more) for a checksum. Define a buffer that is long enough. Clean it out, put the payload in, the length and the check digit, then send it. At the other side, unpack it, check it and, optionally, send back and acknowledgement that it has been received. Repeat the whole process until the data source is exhausted.