// CAN Send Example // #include #include MCP_CAN CAN0(10); // Set CS to pin 10 void setup(void) { Serial.begin(115200); // Initialize MCP2515, masks and filters disabled. if(CAN0.begin(MCP_ANY, CAN_125KBPS, MCP_8MHZ) == CAN_OK) Serial.println("MCP2515 Initialized Successfully!"); else Serial.println("Error Initializing MCP2515..."); CAN0.setMode(MCP_NORMAL); // Change to normal mode to allow messages to be transmitted } byte data[8] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07}; void loop() { // repeated ini for testing CAN0.begin(MCP_ANY, CAN_125KBPS, MCP_8MHZ); CAN0.setMode(MCP_NORMAL); // send data: ID = 0x100, Standard CAN Frame, Data length = 8 bytes, 'data' = array of data bytes to send byte sndStat = CAN0.sendMsgBuf(0x100, 0, 8, data); if(sndStat == CAN_OK){ Serial.println("Message Sent Successfully!"); } else { Serial.println("Error Sending Message..., returncode = "+String(sndStat)); } delay(1000); // send data per 100ms }