极客工坊

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 10527|回复: 2

求教EERPOM 的使用方法

[复制链接]
发表于 2014-6-16 16:18:06 | 显示全部楼层 |阅读模式
我想把几个参数放到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,完全不对呀!!
回复

使用道具 举报

发表于 2014-6-16 17:53:49 | 显示全部楼层
canshu未被调用,都没往eeprom中写入,你期望读出什么?
回复 支持 反对

使用道具 举报

 楼主| 发表于 2014-6-17 10:16:04 | 显示全部楼层
pathletboy 发表于 2014-6-16 17:53
canshu未被调用,都没往eeprom中写入,你期望读出什么?

确实呀,真大意,谢谢了!
回复 支持 反对

使用道具 举报

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

本版积分规则

Archiver|联系我们|极客工坊

GMT+8, 2026-6-10 00:41 , Processed in 0.049168 second(s), 18 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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