极客工坊

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 10178|回复: 4

新人关于EEPROM demo 的疑问

[复制链接]
发表于 2013-1-9 20:59:01 | 显示全部楼层 |阅读模式
前几天偶然试了下IDE里自带的EEPROM READ例子,发现个有趣的事情:arduino运行例子后,每次打开IDE的串口监视窗,都会发现EEPROM的地址从0跑起。看了半天代码也没搞明白这是怎么做到的,请各位指点指点。谢谢
  1. #include <EEPROM.h>

  2. // start reading from the first byte (address 0) of the EEPROM
  3. int address = 0;
  4. byte value;

  5. void setup()
  6. {
  7.   // initialize serial and wait for port to open:
  8.   Serial.begin(9600);
  9.   while (!Serial) {
  10.     ; // wait for serial port to connect. Needed for Leonardo only
  11.   }
  12. }

  13. void loop()
  14. {
  15.   // read a byte from the current address of the EEPROM
  16.   value = EEPROM.read(address);
  17.   
  18.   Serial.print(address);
  19.   Serial.print("\t");
  20.   Serial.print(value, DEC);
  21.   Serial.println();
  22.   
  23.   // advance to the next address of the EEPROM
  24.   address = address + 1;
  25.   
  26.   // there are only 512 bytes of EEPROM, from 0 to 511, so if we're
  27.   // on address 512, wrap around to address 0
  28.   if (address == 512)
  29.     address = 0;
  30.    
  31.   delay(500);
  32. }
复制代码
回复

使用道具 举报

发表于 2013-1-9 21:05:32 | 显示全部楼层
串口一连,arduino就会自动重启
回复 支持 反对

使用道具 举报

发表于 2013-1-9 21:05:51 | 显示全部楼层
确实是么?也可能是IDE内存里记录后,监视器从里面读的
回复 支持 反对

使用道具 举报

发表于 2013-1-10 14:34:04 | 显示全部楼层
UNO上面不是有个reset的跳线嘛,把它断开就不会reset了..就不会从0起了
回复 支持 反对

使用道具 举报

发表于 2013-2-26 15:58:42 | 显示全部楼层
这个和EEPROM没什么关系i,所有的程序都会这样,如前面两位所言。把reset 与地间接个 大点的电容 470 uf ,或者参考官网接个220欧姆的电阻试试
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则 需要先绑定手机号

Archiver|联系我们|极客工坊

GMT+8, 2024-4-27 00:39 , Processed in 0.041208 second(s), 21 queries .

Powered by Discuz! X3.4 Licensed

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表