“EEPROM:EEPROM”的版本间的差异
来自YFRobotwiki
(以“:EEPROM {| border="0" cellpadding="20" width="100%" |- |width="100%" valign="top" align="left"| <font color="olivedrab" size="+3">'''EEPROM[]'''</font...”为内容创建页面) |
|||
第10行: | 第10行: | ||
<font color="orange" size="+1">'''描述'''</font> | <font color="orange" size="+1">'''描述'''</font> | ||
− | + | This operator allows using the identifier `EEPROM` like an array. EEPROM cells can be read and written directly using this method. | |
− | |||
− | + | <font color="orange" size="+1">'''语法'''</font> | |
− | + | EEPROM[address] | |
− | |||
− | <font color="orange" size="+1">''' | + | <font color="orange" size="+1">''' 参数'''</font> |
− | the | + | address: the location to read/write from, starting from 0 (int) |
− | |||
− | < | + | <font color="orange" size="+1">'''返回值'''</font> |
− | + | ||
− | + | A reference to the EEPROM cell | |
− | + | ||
− | |||
− | |||
− | |||
− | |||
− | + | <font color="orange" size="+1">'''示例'''</font> | |
− | + | ||
− | + | ||
− | + | <pre style="color:dimgray"> | |
− | + | #include <EEPROM.h> | |
− | + | ||
− | + | ||
− | + | void setup(){ | |
− | + | unsigned char val; | |
− | + | ||
− | + | //Read first EEPROM cell. | |
+ | val = EEPROM[ 0 ]; | ||
+ | |||
+ | //Write first EEPROM cell. | ||
+ | EEPROM[ 0 ] = val; | ||
+ | |||
+ | //Compare contents | ||
+ | if( val == EEPROM[ 0 ] ){ | ||
+ | //Do something... | ||
+ | } | ||
} | } | ||
+ | |||
+ | void loop(){ /* Empty loop */ } | ||
</pre> | </pre> |
2015年7月14日 (二) 10:36的版本
EEPROM[]
描述 This operator allows using the identifier `EEPROM` like an array. EEPROM cells can be read and written directly using this method.
EEPROM[address]
address: the location to read/write from, starting from 0 (int)
A reference to the EEPROM cell
#include <EEPROM.h> void setup(){ unsigned char val; //Read first EEPROM cell. val = EEPROM[ 0 ]; //Write first EEPROM cell. EEPROM[ 0 ] = val; //Compare contents if( val == EEPROM[ 0 ] ){ //Do something... } } void loop(){ /* Empty loop */ } |
更多建议和问题欢迎反馈至 YFRobot论坛