|
我想把几个参数放到EERPOM里面,本人新手才开始学EERPOM,写了下面的一段程序,求高手给指点。另外求推荐一本这方面的书。谢谢!
[mw_shl_code=cpp,true]#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);
} [/mw_shl_code]
显示的结果是83,完全不对呀!!
|
|