I have connected the Rx of the arduino(A) to Tx of the arduino(B) and Tx to Rx.
//Arduino(B)*********************************
byte crypt [8];
void loop(){
while(Serial.available() <=0); // wait for incoming serial data
if (Serial.available() >= 8 ) // wait for eight bytes
{
for(int i=0;i <=8; i++) crypt = Serial.read();
for (int j=0;j<8;j++)*
{*
if (crypt[j]<0x10){*
Serial.print("0");*
}*
Serial.print(crypt[j],HEX);*
Serial.print(" ");*
}*
Serial.println("");*
}* } what i get from serial monitor for this code is 37 45 20 30 35 20 42 44 20 45 42 20 31 41 20 33 20 36 45 20 39 31 20 0D //********************************************************************************************************************* The problem is how do i read the bytes in arduino(B) and put it into a byte array like it was in the arduino(A)? Any help would be appreciated
The problem is that you are converting binary data to ASCII data, and now you want to convert it back to binary data. The question is why? Why not send the data in binary, so that no conversion is required on either end?
Of course, you could not visualize that data in the Serial Monitor, but, the Serial Monitor is not where that data is needed, is it?
Does that mean i have to send it using "Serial.write" rather than "Serial.print"?
No, its not the serial monitor where the data is needed. I just wanted to be sure the received data is put into a byte array exactly like it was sent, so that i can take it and process it in the other end(in arduino B).
I have connected the Rx of the arduino(A) to Tx of the arduino(B) and Tx to Rx.
//Arduino(B)*********************************
byte crypt [8];
void loop(){
while(Serial.available() <=0); // wait for incoming serial data
if (Serial.available() >= 8) // wait for four bytes
{
for(int i=0;i <=8; i++) crypt*=Serial.read();*
for (int j=0;j<8;j++)*
{*
if (crypt[j]<0x10){*
Serial.print("0");*
}*
Serial.print(crypt[j],HEX);*
Serial.print(" ");*
}*
Serial.println("");*
}* } what i get from serial monitor for this code is 7E 05 BD EB 1A 3A 6E 91 //just like how i wanted it //*********************************************************************************************************************