There was an error when loading a sketch to NANO.
error code:
An error occurred while uploading the sketch
Invalid library found in C:\Program Files (x86)\Arduino\libraries\utility: no headers files (.h) found in C:\Program Files (x86)\Arduino\libraries\utility
Invalid library found in C:\Program Files (x86)\Arduino\libraries\utility: no headers files (.h) found in C:\Program Files (x86)\Arduino\libraries\utility
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
#include <mcp_can.h>
#include <mcp_can_dfs.h>
// the cs pin of the version after v1.1 is default to D9
// v0.9b and v1.0 is default D10
const int SPI_CS_PIN = 9;
MCP_CAN CAN(SPI_CS_PIN); // Set CS pin
unsigned char flagRecv = 0;
unsigned char len = 0;
unsigned char buf[8];
char str[20];
void setup()
{
////Serial.begin(115200);
Serial.begin(9600);
while (CAN_OK != CAN.begin(CAN_1000KBPS)) // init can bus : baudrate = 500k
{
Serial.println("CAN BUS Shield init fail");
Serial.println(" Init CAN BUS Shield again");
delay(100);
}
Serial.println("CAN BUS Shield init ok!");
attachInterrupt(0, MCP2515_ISR, FALLING); // start interrupt
}
void MCP2515_ISR()
{
flagRecv = 1;
}
void loop()
{
if (flagRecv)
{ // check if get data
flagRecv = 0; // clear flag
// read data, len: data length, buf: data buf
CAN.readMsgBuf(&len, buf);
// print the data
for (int i = 0; i < len; i++)
{
Serial.print(buf[i]); Serial.print("\t"); ////exit status 1 call of overloaded 'print(unsigned char [8])' is ambiguous
}
Serial.println();
}
}
[code/]