write()
描述
送出指定的資料。
語法
CAN.write(val)
CAN.write(buf, len)
參數
val:要傳送的資料 (unsigned char 型別)
buf:要傳送的資料陣列
len:陣列大小
回傳
寫出去的 byte 數
範例
#include <CANBus.h>
unsigned char buf[8] = {0, 1, 2, 3, 4, 5, 6, 7};
void setup() {
Serial.begin(115200);
CAN.begin(CAN_500KBPS); // 設定 CANBus 的傳輸速度為 500KBPS
}
void loop() {
CAN.beginTransmission(0x00); // 外部 CAN device 的 ID 為 0x00,使用標準資料幀
CAN.write(buf, 8); // 送出 8 bytes 資料
CAN.endTransmission(); // 結束傳送
delay(10);
}
See also
- beginTransmission()
- endTransmission()
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.
