Hello,
I am trying to control some dials out of a bmw mini over the can-bus.
I am pretty new to coding and am getting a bit stuck.
I have got an arduino uno and the can-bus shield but am having no luck with the code.
I have loaded in the right library (i think - GitHub - coryjfowler/MCP_CAN_lib: MCP_CAN Library)
But even when i try and load the examples they don't seem to work,
// demo: CAN-BUS Shield, send data
#include <mcp_can.h>
#include <SPI.h>
MCP_CAN CAN0(10); // Set CS to pin 10
void setup()
{
Serial.begin(115200);
// init can bus, baudrate: 500k
if(CAN0.begin(CAN_500KBPS) == CAN_OK) Serial.print("can init ok!!\r\n");
else Serial.print("Can init fail!!\r\n");
}
unsigned char stmp[8] = {0, 1, 2, 3, 4, 5, 6, 7};
void loop()
{
// send data: id = 0x00, standrad flame, data len = 8, stmp: data buf
CAN0.sendMsgBuf(0x00, 0, 8, stmp);
delay(100); // send data per 100ms
}
/*********************************************************************************************************
END FILE
I am looking at the serial monitor and just getting random characters back, from my understanding i should be seeing "can init ok!!" or "Can init fail!!"
Can any one offer any advice.
Thanks
Iain