Arduino NANO 和外部 eemprom 问题

问题描述

我正在尝试将 EEPROM 芯片 24LC01B 连接到 Arduino Nano 328P,将数据写入其中,读取并在串行监视器中显示。

仅串行监视器显示

写... 阅读...

我不知道问题出在哪里。

#include <Wire.h>

#define memoryAddr 0x50
byte in=0x00;

void setup()
{
  Wire.begin(); // join i2c bus (address optional for master)
  Serial.begin(9600);
}


void loop()
{
  Serial.println("Writing...");
  
  Wire.beginTransmission(0x50); // This is the 24LC01B device address
  Wire.write(0x0);               // Start writing at address 0
  Wire.write("Hell");            // Send 4 bytes
  Wire.endTransmission();       
  delay(100);                    // Without a short delay,the EEPROM is still
                                // writing when you start to write the next block
                                // Feel free to experiment with the delay length
  
  Wire.beginTransmission(0x50);
  Wire.write(0x4);               // Write next four bytes starting at address 4
  Wire.write("o Wo");
  Wire.endTransmission();     
  delay(100);
  

  Wire.beginTransmission(0x50);
  Wire.write(0x8);               // Write last four bytes starting at address 8
  Wire.write("rld!");
  Wire.endTransmission();     
  delay(100);

  Serial.println("Reading...");

  Wire.beginTransmission(0x50); // Now we're going to read it back
  Wire.write(0x0);               // Sending address 0,so it knows where we'll want
  Wire.endTransmission();       // to read from

  Wire.requestFrom(0x50,12);    // Start new transmission and keep reading for 12 bytes
  while(Wire.available())    
  { 
    char c = Wire.read();    // Read a byte and write it out to the Serial port
    Serial.print(c);         
  } 
  Serial.println();

  delay(5000);
}

以下是我的连接方式:https://i.stack.imgur.com/m8EFc.jpg

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)