execute CAN BUS message

I am able to read the CAN bus message, but how can I execute the a particular message for my purpose? For example, if I receive a certain message I want, I want to turn on a LED. I cannot find a example for this. All I can find from web search are related the reading the information from OBDII.

Thanks.

You can do something like this …

I am receiving a canbus message on one of the arduino and if I receive this data with the first character as ‘1’ then I will take it and print the data which I have received or else I will simply print " This Data is not for me" …

#include <SPI.h>
#include “mcp_can.h”

int slave_num=1;
long unsigned int rxId;

unsigned long rcvTime;

unsigned char len = 0;
char buf[8];
int flag2=0;

const int SPI_CS_PIN = 10;

MCP_CAN CAN(SPI_CS_PIN); // Set CS pin

void setup()
{
Serial.begin(9600);

while (CAN_OK != CAN.begin(CAN_250KBPS)) // init can bus : baudrate = 500k
{
Serial.println(“CAN BUS Module Failed to Initialized”);
Serial.println(“Retrying…”);
delay(200);
}
Serial.println(“CAN BUS Module Initialized!”);

}

void loop()
{

if(CAN_MSGAVAIL == CAN.checkReceive()) // check if data coming
{

//Serial.println(“hi”);
CAN.readMsgBuf(&len, buf); // read data, len: data length, buf: data buf

if(buf[0]==‘1’)
{
rxId= CAN.getCanId();
Serial.println(buf);

}
else
{
Serial.println(“NOT FOR ME”);
}
}

}

Thank you, I will give it try.