wdb_9955 发表于 2014-6-16 16:18:06

求教EERPOM 的使用方法

我想把几个参数放到EERPOM里面,本人新手才开始学EERPOM,写了下面的一段程序,求高手给指点。另外求推荐一本这方面的书。谢谢!

#include <Wire.h>   
#include <math.h>
#include <LiquidCrystal_I2C.h>
#include <EEPROM.h>
LiquidCrystal_I2C lcd(0x27,20,4);
void canshu()
{int tem_h = 50;
int tem_l = 20;
int hum_h = 40;
int hum_l = 15;
int lux_h = 30;
int lux_l = 10;
byte temByte_h = (int)(tem_h);
EEPROM.write(0,temByte_h);
byte temByte_l = (int)(tem_l);
EEPROM.write(1,temByte_l);
byte humByte_h = (int)(hum_h);
EEPROM.write(2,humByte_h);
byte humByte_l = (int)(hum_l);
EEPROM.write(3,humByte_l);
byte luxByte_h = (int)(luxByte_h);
EEPROM.write(4,luxByte_h);
byte luxByte_l = (int)(luxByte_l);
EEPROM.write(5,luxByte_l);
}
void setup()
{lcd.init();
   Wire.begin();
}
void loop()
{ lcd.clear();
lcd.backlight();
lcd.setCursor(0,0);
lcd.print(EEPROM.read(0));
delay(1000);
}
显示的结果是83,完全不对呀!!

pathletboy 发表于 2014-6-16 17:53:49

canshu未被调用,都没往eeprom中写入,你期望读出什么?

wdb_9955 发表于 2014-6-17 10:16:04

pathletboy 发表于 2014-6-16 17:53 static/image/common/back.gif
canshu未被调用,都没往eeprom中写入,你期望读出什么?

确实呀,真大意,谢谢了!
页: [1]
查看完整版本: 求教EERPOM 的使用方法