Page 1 of 1
Forum

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!



Compilation error
 
Share:
Notifications
Clear all

[Solved] Compilation error

2 Posts
2 Users
0 Likes
942 Views
(@Anonymous)
Joined: 1 second ago
Posts: 0
Topic starter  

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 8 months ago by Anonymous

   
ReplyQuote
 Hans
(@hans)
Famed Member Admin
Joined: 11 years ago
Posts: 2680
 

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!


   
ReplyQuote
Share: