loading
1 Comments

Tell us about yourself!

Complete Your Profile
  • Hack your vehicle CAN-BUS with Arduino and Seeed CAN-BUS Shield

    this complies OK at least on my IDE#include <SPI.h>#include <mcp_can.h>INT32U canId = 0x000;unsigned char len = 0;unsigned char buff[8];char str[20];const int SPI_CS_PIN = 10; // select your can shield cs pinMCP_CAN CAN(SPI_CS_PIN); // Set CS pinvoid setup(){ Serial.begin(115200);START_INIT:if(CAN_OK == CAN.begin(CAN_125KBPS)) { Serial.println("CAN BUS Shield init ok!"); } else { Serial.println("CAN BUS Shield init fail"); Serial.println("Init CAN BUS Shield again"); delay(100); goto START_INIT; }}void loop(){ if(CAN_MSGAVAIL == CAN.checkReceive()) { CAN.readMsgBuf(&len, buff); canId = CAN.getCanId(); Serial.print(canId);Serial.print(","); for(int i = 0; i<len; i++) { Serial.print(buff[i]);Serial.print(&qu...see more »this complies OK at least on my IDE#include <SPI.h>#include <mcp_can.h>INT32U canId = 0x000;unsigned char len = 0;unsigned char buff[8];char str[20];const int SPI_CS_PIN = 10; // select your can shield cs pinMCP_CAN CAN(SPI_CS_PIN); // Set CS pinvoid setup(){ Serial.begin(115200);START_INIT:if(CAN_OK == CAN.begin(CAN_125KBPS)) { Serial.println("CAN BUS Shield init ok!"); } else { Serial.println("CAN BUS Shield init fail"); Serial.println("Init CAN BUS Shield again"); delay(100); goto START_INIT; }}void loop(){ if(CAN_MSGAVAIL == CAN.checkReceive()) { CAN.readMsgBuf(&len, buff); canId = CAN.getCanId(); Serial.print(canId);Serial.print(","); for(int i = 0; i<len; i++) { Serial.print(buff[i]);Serial.print(","); } Serial.println(); }}

    View Instructable »