write()
描述
写一个 byte 值到 EEPROM。
语法
EEPROM.write(address, value)
参数
address
: 写入的位置,从 0 开始 (int 型别)
value
: 写入的值,从 0 ~ 255 (byte 型别)
回传
无回传值
注意
假如你使用 16K 的 flash 虚拟 EEPROM,写入会花较长的时间来完成 (平均约 200 ~ 250 微秒);由于虚拟 EEPROM 是使用内建 flash 来实作的,所以会受到 flash 写入/抹除次数的限制,在使用上可能要留意写入的总次数。
使用 200 byte 的 CMOS 虚拟 EEPROM 来写入,速度会比较快,平均约 2 ~ 3 微秒,并且没有上面的限制。但是,如果你移除板子上的电池,CMOS 虚拟的 EEPROM 内容会全部消失。
范例
#include <EEPROM.h> void setup() { for (int i = 0; i < 200; i++) EEPROM.write(i, i); } void loop() { }
See also
- EEPROM.read()
The text of the 86Duino reference is a modification of the Arduino reference, and is licensed under a Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain.