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.