Hello, I’m trying to send a message with CAN BUS Shield.
I’m using this CAN BUS Shield
here is my code which i am using now
// demo: CAN-BUS Shield, send data
#include <mcp_can.h>
#include <SPI.h>
INT8U result;
void setup()
{
Serial.begin(115200);
// init can bus, baudrate: 500k
if(CAN.begin(CAN_500KBPS) ==CAN_OK) Serial.print("can init ok!!\r\n");
else Serial.print("Can init fail!!\r\n");
}
unsigned char stmp[8] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07};
void loop()
{
// send data: id = 0x00, standrad flame, data len = 8, stmp: data buf
result = CAN.sendMsgBuf(0x11, 0, 8, stmp);
if(result!=CAN_OK)
{
Serial.print(result);
}
else
{
Serial.print("Success\n");
}
delay(100); // send data per 100ms
}
/*********************************************************************************************************
END FILE
*********************************************************************************************************/
As you can see a result, to transmit occurs only 3 times. (Success means that sending has done)
but after 3times, message can’t be sent.
Could you tell me why it happen?
I attach the picture of Arduino + CAN BUS Shield.
Is there anything I need to do more?
I’m in hurry, please help me.
Thank you