Added some more projects and libraries.
This commit is contained in:
parent
f7151392ab
commit
1e1459fa50
94 changed files with 11904 additions and 0 deletions
|
|
@ -0,0 +1,33 @@
|
|||
#include <SPI.h>
|
||||
#include <mcp2515.h>
|
||||
|
||||
struct can_frame canMsg;
|
||||
MCP2515 mcp2515(10);
|
||||
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
|
||||
mcp2515.reset();
|
||||
mcp2515.setBitrate(CAN_125KBPS);
|
||||
mcp2515.setNormalMode();
|
||||
|
||||
Serial.println("------- CAN Read ----------");
|
||||
Serial.println("ID DLC DATA");
|
||||
}
|
||||
|
||||
void loop() {
|
||||
if (mcp2515.readMessage(&canMsg) == MCP2515::ERROR_OK) {
|
||||
Serial.print(canMsg.can_id, HEX); // print ID
|
||||
Serial.print(" ");
|
||||
Serial.print(canMsg.can_dlc, HEX); // print DLC
|
||||
Serial.print(" ");
|
||||
|
||||
for (int i = 0; i<canMsg.can_dlc; i++) { // print the data
|
||||
Serial.print(canMsg.data[i],HEX);
|
||||
Serial.print(" ");
|
||||
}
|
||||
|
||||
Serial.println();
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue