美文网首页Arduino互动设计入门
实例 3.7 不能说的秘密

实例 3.7 不能说的秘密

作者: chenzhenlindx | 来源:发表于2018-11-18 19:01 被阅读12次
  1. 面包板 略

  2. 原理图 略

  3. PCB 略

  4. ArduBlock


    image.png
  5. Arduino

#include <EEPROM.h>

/********************************************************
 * A way to read int (2 Bytes)from EEPROM 
 * EEPROM library natively supports only bytes
 ********************************************************/
int eepromReadInt(int address){

  union u_tag {
    byte b[2];
    int INTtime;
  } 
  time;
  time.b[0] = EEPROM.read(address);
  time.b[1] = EEPROM.read(address+1);
  return time.INTtime;
}

/*******************************************************************
 * A way to write an 'int' (2 Bytes) to EEPROM 
 * EEPROM library natively supports only bytes. 
 * Note it takes around 8ms to write an int to EEPROM 
 *******************************************************************/
void eepromWriteInt(int address, int value){
  union u_tag {
    byte b[2];        //assumes 2 bytes in an int
    int INTtime;
  } 
  time;
  time.INTtime=value;

  EEPROM.write(address  , time.b[0]); 
  EEPROM.write(address+1, time.b[1]); 
}


void setup()
{
  Serial.begin(9600);
  Serial.print("Read from Arduino");
  Serial.println();

  Serial.print(eepromReadInt( 10 ) );
  Serial.println();

  Serial.print(eepromReadInt( 11 ) );
  Serial.println();

  Serial.print(eepromReadInt( 12 ) );
  Serial.println();

  Serial.print(eepromReadInt( 13 ) );
  Serial.println();

  Serial.print(eepromReadInt( 14 ) );
  Serial.println();

  delay( 1000 );

  eepromWriteInt( 10 , 1 ) ;

  eepromWriteInt( 11 , 2 ) ;

  eepromWriteInt( 12 , 3 ) ;

  eepromWriteInt( 13 , 4 ) ;

  eepromWriteInt( 14 , 5 ) ;

}

void loop()
{
}

相关文章

  • 实例 3.7 不能说的秘密

    面包板 略 原理图 略 PCB 略 ArduBlockimage.png Arduino

  • 3.7 应用实例

    例题1 8*8棋盘矩阵,其中1、3、5、7行&&0、2、4、6列的元素值为1, 1、3、5、7列&&0、2、4、6...

  • 2021-11-06

    不能说的秘密

  • 你有没有为了一首歌,而特意选择去看一部电影?

    1.不能说的秘密·周杰伦—《不能说的秘密》插曲 作为周董的处女作,同名电影《不能说的秘密》就像是专门为其打造的歌曲...

  • Lucky Cookie ------来自《新喜剧之王》

    一、不能说的秘密 不剧透。 不能说的秘密,这个秘密,每个人都有。这个秘密只不过是迷茫、失败、汗水、泪水等的狼狈。如...

  • 不能说的秘密

    电影不能说的秘密

  • 不能说的秘密

    不能说的秘密/不能窃取的欢愉/那怎样/这是秘密/不能说的秘密/无奈舍弃的轮回/我不想/大梦一场/我想说/我要说/我...

  • 秘密

    我有一个秘密 一个不能说的秘密 因为不能说 所以我写下 因为是秘密 所以我把它留在心里 等—— 秘密布满灰尘时 我...

  • 城市中的秘密花园(三)

    NO.3不能说的秘密 文/...

  • 无话可说但不得不说

    想当年,周杰伦的电影《不能说的秘密》首映时,冯小刚对记者说:“周杰伦拍了部电影,叫《不能说的秘密》,但这个秘密又不...

网友评论

    本文标题:实例 3.7 不能说的秘密

    本文链接:https://www.haomeiwen.com/subject/scggfqtx.html