Contents:
The following code samples uses the CAN-BUS Shield, wired up as shown:
The following library has two dependencies. These dependencies must install for compile your code.
- arduino-mcp2515 https://github.com/autowp/arduino-mcp2515
- TrueRandom https://github.com/sirleech/TrueRandom
- Download the ZIP file from https://github.com/bertrand-sifre/domo-can/archive/master.zip
- From the Arduino IDE: Sketch -> Include Library... -> Add .ZIP Library...
- Restart the Arduino IDE to see the new "domo-can" library with examples
Construct a DomoCan object on your global variable. On your setup function config your DomoCan, you can call function addXXX for indicate your configuration, after this just call function init.
For the moment the bitrate is hard coded at 500KBPS with a 8Mhz quartz.
To create a DomoCan with a relay just use this code:
#include "domo_can.h"
DomoCan domocan;
void setup() {
domocan.addRelay(&(setRelay), &(resetRelay), &(getStatus));
domocan.init();
}
void loop() {
// do something.
}
boolean getStatus() {
// do something
return false;
}
void resetRelay() {
// reset relay.
}
void setRelay() {
// set relay.
}