Welcome to the Tweaking4All community forums!
When participating, please keep the Forum Rules in mind!
Topics for particular software or systems: Start your topic link with the name of the application or system.
For example “MacOS X – Your question“, or “MS Word – Your Tip or Trick“.
Please note that switching to another language when reading a post will not bring you to the same post, in Dutch, as there is no translation for that post!
[Solved] Compilation error
(@Anonymous)
Joined: 1 second ago
Posts: 0
Topic starter
August 22, 2023 11:02 AM
Arduino 2.0.4 Code - I am trying to learn to use CAN with Arduino. I downloaded this code to help with my learning curve. But it gives me this Compilation error: "cannot declare variable 'CAN' to be of abstract type 'MCP_CAN'" and highlights the 8th & 14th lines.
Can someone help me?
#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);
}
This topic was modified 2 years ago by
Anonymous
(@hans)
Famed Member Admin
Joined: 12 years ago
Posts: 2859
August 23, 2023 11:04 AM
My best guess, not knowing this library, or how to use it, is that library may have been updated or changed.
So I did some Google searching and found that this is indeed the case (see this post).
Looks like you can get the latest version here - please note that the developer mentions in his post that some code may need to change. Since you're just starting, I'd assume you're better off playing with their new examples. Hopes this helps!