“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>
  
Reads a byte from the EEPROM. Locations that have never been written to have the value of 255.
+
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">'''Syntax'''</font>
 
  
EEPROM.read(address)
+
<font color="orange" size="+1">'''语法'''</font>
  
<font color="orange" size="+1">'''Parameters'''</font>
+
EEPROM[address]
  
address: the location to read from, starting from 0 (int)
 
  
<font color="orange" size="+1">'''Returns'''</font>
+
<font color="orange" size="+1">''' 参数'''</font>
  
the value stored in that location (byte)
+
address: the location to read/write from, starting from 0 (int)
  
<font color="orange" size="+1">'''Example'''</font>
 
  
<pre style="color:dimgray">
+
<font color="orange" size="+1">'''返回值'''</font>
#include <EEPROM.h>
+
  
int a = 0;
+
A reference to the EEPROM cell
int value;
+
  
void setup()
 
{
 
  Serial.begin(9600);
 
}
 
  
void loop()
+
<font color="orange" size="+1">'''示例'''</font>
{
+
  value = EEPROM.read(a);
+
  
  Serial.print(a);
+
<pre style="color:dimgray">
  Serial.print("\t");
+
#include <EEPROM.h>
  Serial.print(value);
+
  Serial.println();
+
  
  a = a + 1;
+
void setup(){
  
   if (a == 512)
+
   unsigned char val;
    a = 0;
+
  
   delay(500);
+
   //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

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 */ }


返回EEPROM库

返回Arduino库菜单

返回首页

更多建议和问题欢迎反馈至 YFRobot论坛