Skip to content

Instantly share code, notes, and snippets.

@elktros
Created August 23, 2018 10:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save elktros/d7a64f7becc6b067e2d0dcb145392acf to your computer and use it in GitHub Desktop.
Save elktros/d7a64f7becc6b067e2d0dcb145392acf to your computer and use it in GitHub Desktop.
Transmitter code for Interfacing MCP2515 CAN Module with Arduino.
#include <SPI.h>
#include <mcp_can.h>
const int spiCSPin = 10;
int ledHIGH = 1;
int ledLOW = 0;
MCP_CAN CAN(spiCSPin);
void setup()
{
Serial.begin(115200);
while (CAN_OK != CAN.begin(CAN_500KBPS))
{
Serial.println("CAN BUS init Failed");
delay(100);
}
Serial.println("CAN BUS Shield Init OK!");
}
unsigned char stmp[8] = {ledHIGH, 1, 2, 3, ledLOW, 5, 6, 7};
void loop()
{
Serial.println("In loop");
CAN.sendMsgBuf(0x43, 0, 8, stmp);
delay(1000);
}
@udayasreeM
Copy link

I am doing same but i got an error (exit status 1
mcp_can.h: No such file or directory) like this. I have downloaded the libraries of MCP_CAN 2515 related but still same error is coming. I am using arduino 1.8.1 version and the board is arduino mega 2560. please look at above code and where i am doing mistake please give me replay .

@aadithya2410
Copy link

I am getting the same error as well

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment