author

steelhanzero

Inbox View Profile
2Comments

Tell us about yourself!

  • Yes We CAN BUS With Arduino in 30 Seconds!

    hello. thanks for the reply. i attached my sour code.some time it work. some time doesn't work..i don't know what is the problems.check the 2 can id using the if....and then send the can value of cluster..#include <mcp_can.h>#include <SPI.h>long unsigned int rxId;unsigned char len;unsigned char rxBuf[8];boolean k = false;boolean aj = false;MCP_CAN CAN0(9); // Set CS to pin 9void setup(){ Serial.begin(115200); if(CAN0.begin(MCP_STD, CAN_500KBPS, MCP_8MHZ) == CAN_OK) Serial.print("MCP2515 Init Okay!!\r\n"); else Serial.print("MCP2515 Init Failed!!\r\n");CAN0.setMode(MCP_NORMAL);}void loop(){if(!digitalRead(2)) // If pin 2 is low, read receive buffer { CAN0.readMsgBuf(&rxId, &len, rxBuf); // Read data: len = data length, buf…

    see more »

    hello. thanks for the reply. i attached my sour code.some time it work. some time doesn't work..i don't know what is the problems.check the 2 can id using the if....and then send the can value of cluster..#include <mcp_can.h>#include <SPI.h>long unsigned int rxId;unsigned char len;unsigned char rxBuf[8];boolean k = false;boolean aj = false;MCP_CAN CAN0(9); // Set CS to pin 9void setup(){ Serial.begin(115200); if(CAN0.begin(MCP_STD, CAN_500KBPS, MCP_8MHZ) == CAN_OK) Serial.print("MCP2515 Init Okay!!\r\n"); else Serial.print("MCP2515 Init Failed!!\r\n");CAN0.setMode(MCP_NORMAL);}void loop(){if(!digitalRead(2)) // If pin 2 is low, read receive buffer { CAN0.readMsgBuf(&rxId, &len, rxBuf); // Read data: len = data length, buf = data byte(s) if(rxId == 1056 && (rxBuf[1] & 0x04)) { // ID=1056 alert check state1 k=1; } if(rxId == 1461 && k==1 && rxBuf[1]==0x01) { // ID=1461 alert check state2 aj=1; } if(rxId == 1264 && aj==1) { //send cluster for release alert value of rxBuf[0]+2 k=0; aj=0; unsigned char stmp[8] = {rxBuf[0]+2,rxBuf[1],rxBuf[2],rxBuf[3],rxBuf[4],rxBuf[5],rxBuf[6],rxBuf[7]}; CAN0.sendMsgBuf(rxId,0,8,stmp); // rxId = 1264 Serial.println("sending"); Serial.println(a); delay(1); } } }

    View Instructable »