Compare hex string to command arduino pin

Hi ,
Need little help in arduino programming

I want to operate arduino pin , when the hex string comes.

This strings is 0x7B, 0x52,0x01,0x04,0x01,0x00, 0xFE to switch pin on arduino.

Please help

Can you explain what it is you want to do?

I have a another microcontroller which communicate with arduino via serial port, and that microcontroller send hex string as mentioned above ,
I want to control arduino pin ,when arduino detect this hex string,
the arduino pin(e.g arduino pin 1) becomes high ...

So, you said you need a little help.
What have you already done?

read carefully this post:
Serial Input Basic

if you follow this tutorial you can read data from a serial connection and act accordingly.

Which one of the following commands you are using at the transmitter side to send these data bytes: 0x7B, 0x52,0x01,0x04,0x01,0x00, 0xFE.

Serial.print("7B5201040100FE");

OR

Serial.write(myDataArray, sizeof(myDataArray);

OR

for(int i = 0; i<sizeof myDataArray; i++)
{
   Serial.write(myDataArray[i]);
}

noiasca:
read carefully this post:
Serial Input Basic

if you follow this tutorial you can read data from a serial connection and act accordingly.

Thanks for your support

#include <SoftwareSerial.h>

String A = 7B521410FE;
SoftwareSerial mySerial(D2, D3); // RX, TX
byte msg[] ={ 0x7B, 0x52, 0x01, 0x04, 0x01, 0x00, 0xFE};
void setup()
{
// Open serial communications and wait for port to open:
Serial.begin(115200);
pinMode(D1,OUTPUT);
digitalWrite(D1,LOW);
mySerial.begin(9600);
}

void loop() // run over and over
{
if (mySerial.available())
{
Serial.print(mySerial.read());
String x =String( mySerial.read(),HEX) ;
if(strcmp(x,A )==0)
{
digitalWrite(D1,HIGH);// ~DO SOMETHING~
delay(1000);
digitalWrite(D1,LOW);
}
}
if(Serial.available()>0)
{
int x = Serial.read();
Serial.println(x,DEC);
if(x==49)
{
byte msg[]={0x7B,0x00,0x06,0x01,0xFF};
mySerial.write(msg, sizeof(msg));
delay(50);
}
}

}

Program is mentioned above , but not working plz rectify if necessary on do something part in program..

GolamMostafa:
Which one of the following commands you are using at the transmitter side to send these data bytes: 0x7B, 0x52,0x01,0x04,0x01,0x00, 0xFE.

Serial.print("7B5201040100FE");

OR

Serial.write(myDataArray, sizeof(myDataArray);

OR

for(int i = 0; i<sizeof myDataArray; i++)

{
  Serial.write(myDataArray[i]);
}

The tranmitter side is cypress ic , which is totally different
If you can help in arduino...

Serial.print(mySerial.read());
    String x =String( mySerial.read(),HEX) ;

This code prints out odd numbered characters and then uses even numbers characters.
Every Serial read removes a character from the buffer.

More over, if you have received one character then you go on the read two. The second one probably hasn’t arrived yet.
The mySerial.available() returns a number, use that so you do not read the buffer until at least the number of characters you are going to read have arrived in the buffer.

Did you really read and understand that link?

If i have done wrong plz mention in program .
I am stuck in this !!!

Ajay-Siswal:
If i have done wrong plz mention in program .
I am stuck in this !!!

Sorry we do not write code for you. Please ask about what you don’t understand about my answer.

#include <SoftwareSerial.h>
SoftwareSerial mySerial(D2, D3); // RX, TX

const byte numBytes = 6;
byte receivedBytes[numBytes];
byte numReceived = 0;

boolean newData = false;

void setup()
{
Serial.begin(115200);
mySerial.begin(9600);
pinMode(D8,OUTPUT);
digitalWrite(D8,LOW);

}

void loop() {
recvBytesWithStartEndMarkers();
showNewData();
}

void recvBytesWithStartEndMarkers() {
static boolean recvInProgress = false;
static byte ndx = 0;
byte startMarker = 0x7B;
byte endMarker = 0xFE;
byte rb;

while (mySerial.available() > 0 && newData == false) {
rb = mySerial.read();

if (recvInProgress == true) {
if (rb != endMarker&&ndx<=6) {
receivedBytes[ndx] = rb;
ndx++;
if (ndx ==6 ) {//ndx>=numBytes
//ndx = numBytes-1 ;
receivedBytes[ndx] = rb;
recvInProgress = false;
numReceived = ndx;
newData = true;
receivedBytes[ndx] = '\0';
ndx=0;
}
/* else if (ndx == numBytes)
{
receivedBytes[ndx] = rb;
numReceived = ndx ;
newData = true;

}*/
}
else {
receivedBytes[ndx] = '\0'; // terminate the string
recvInProgress = false;
numReceived = ndx; // save the number for use when printing
ndx = 0;
newData = true;
}
}

else if (rb == startMarker) {
recvInProgress = true;
}
}
}

void showNewData() {
if (newData == true) {
Serial.print("This just in (HEX values)... ");
Serial.print("no receiver ");
Serial.print(numReceived);
Serial.print("...");

for (byte n = 0; n < numReceived; n++)
{
Serial.print(receivedBytes[n]);
Serial.print(' ');
}
//for (byte n = 0; n < numReceived; n++)
if(receivedBytes[4]==0x00&& receivedBytes[3]==0x01)
{
Serial.println("HIGH");
digitalWrite(D8,HIGH);
}
if(receivedBytes[4]==0xFF&& receivedBytes[3]==0x01)
{
Serial.println("LOW");
digitalWrite(D8,LOW);
}
if(receivedBytes[4]==0xFF&& receivedBytes[3]==0x05)
{
Serial.println("LOW");
digitalWrite(D8,LOW);
}
if(receivedBytes[4]==0xFF&& receivedBytes[3]==0x05)
{
Serial.println("LOW");
digitalWrite(D8,LOW);
}

Serial.println();
newData = false;
}
}

tnx for your support , program has made !!!