begin()

Description

Initialize CANBus function library

Syntax


CAN.begin()
CAN.begin(speed)

Parameters

speed:Data transmission speed for CAN bus. When not set, the default 10KBPS setting is used.

  1. CAN_10KBPS
  2. CAN_20KBPS
  3. CAN_50KBPS
  4. CAN_83K3BPS
  5. CAN_100KBPS
  6. CAN_125KBPS
  7. CAN_250KBPS
  8. CAN_500KBPS
  9. CAN_833KBPS
  10. CAN_1000KBPS

Returns

None

Examples

#include <CANBus.h>
unsigned char buf[8] = {0, 1, 2, 3, 4, 5, 6, 7};

void setup() {
    Serial.begin(115200);
    CAN.begin(CAN_500KBPS); // Configure CAN bus transmission speed to 500KBPS
}

void loop() {
    CAN.beginTransmission(0x00, CAN_STDID);    // Set the CAN device ID to 0x00, using standard data grame.
    CAN.write(buf, 8);                         // Sent 8 bytes of data
    CAN.endTransmission();                     // End transmission
    delay(10);
}

See also

beginTransmission()
write()
endTransmission()


Libraries Reference Home

The text of the 86Duino reference is licensed under a Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain.