Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <mcp_can.h>
- #include <SPI.h>
- #include "setup.h"
- MCP_CAN CAN0(10); // Set CS to pin 10
- void setup()
- {
- Serial.begin(115200);
- // Initialize MCP2515 running at 16MHz with a baudrate of 500kb/s and the masks and filters disabled.
- if(CAN0.begin(MCP_ANY, CAN_500KBPS, MCP_8MHZ) == CAN_OK) Serial.println("MCP2515 Initialized OK!");
- else Serial.println("Error Initializing MCP2515...");
- CAN0.setMode(MCP_NORMAL); // Change to normal mode to allow messages to be transmitted
- }
- void loop()
- {
- for(byte x = 0; x<16; x++)
- {
- byte sndStat = CAN0.sendMsgBuf(Devices[x], 0, 8, matrixArray[16][8]);
- delay(32);
- Serial.println();
- // send data: ID = 0x100, Standard CAN Frame, Data length = 8 bytes, 'data' = array of data bytes to send
- //byte sndStat = CAN0.sendMsgBuf(0x280, 1, 8, data0);
- /*if(sndStat == CAN_OK){
- Serial.println("Message Sent OK!");
- } else {
- Serial.println("Error Sending Message...");
- }*/
- //delay(1); // send data per 1s
- }
- }
- /*********************************************************************************************************
- END FILE
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement