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.