スケッチの作成
(1)(Serial.begin(9600);→Serial.begin(115200);に変更変更します。**注(1)
(2)電源投入直後の改行を追加します。**注(2))
//EEPROM24FC256-I/P
#include
#define disk1 0x50 //Address of 24LC256 eeprom chip
void setup(void)
{
Serial.begin(115200);//**注(1)
Wire.begin();
unsigned int address;
Serial.println("");//**注(2)
for(address=0;address<10;address++)
{
writeEEPROM(disk1, address, 255-address);
Serial.print(address, DEC);
Serial.print("\t");
Serial.println(readEEPROM(disk1, address), DEC);
}
}
void loop(){}
void writeEEPROM(int deviceaddress, unsigned int eeaddress, byte data )
{
Wire.beginTransmission(deviceaddress);
Wire.write((int)(eeaddress >> 8)); // MSB
Wire.write((int)(eeaddress & 0xFF)); // LSB
Wire.write(data);
Wire.endTransmission();
delay(5);
}
byte readEEPROM(int deviceaddress, unsigned int eeaddress )
{
byte rdata = 0xFF;
Wire.beginTransmission(deviceaddress);
Wire.write((int)(eeaddress >> 8)); // MSB
Wire.write((int)(eeaddress & 0xFF)); // LSB
Wire.endTransmission();
Wire.requestFrom(deviceaddress,1);
if (Wire.available()) rdata = Wire.read();
return rdata;
}