diff --git a/examples/CAN_read/CAN_read.ino b/examples/CAN_read/CAN_read.ino new file mode 100644 index 0000000..74b8c9a --- /dev/null +++ b/examples/CAN_read/CAN_read.ino @@ -0,0 +1,33 @@ +#include +#include + +struct can_frame canMsg; +MCP_CAN mcp2515(10, MCP_CAN::MODE_NORMAL); + + +void setup() { + Serial.begin(115200); + mcp2515.begin(CAN_125KBPS); + Serial.println("------- CAN Read ----------"); + Serial.println("ID DLC DATA"); +} + +void loop() { + + if (mcp2515.readMessage(&canMsg) == MCP_CAN::ERROR_OK) { + + Serial.print(canMsg.can_id); // print ID + + Serial.print(canMsg.can_dlc); // print DLC + + for (int i = 0; i