LoginSignup
0
0

More than 1 year has passed since last update.

Arduino UNOでI2C EEPROで遊ぶ2(連続読み)

Posted at

目的
I2C EEPROMのテスト

秋月で買ったichgojam用のやつ

o_con576.jpg

o_con577.jpg




//SER_I2C_EEPROM_0_15_read2_UNO_1
//連続して読み込む

#include <Arduino.h>
#include <Wire.h>

//初期化処理
void setup() {

  //シリアルの初期化
  Serial.begin(9600);

  //I2Cの初期化
  Wire.begin();


  //読み込みアドレスの設定
  //ダミー書き込み
  Wire.beginTransmission(0x50);
  //アドレス
  Wire.write(0x00);     //H
  Wire.write(0x00);     //L
  //データ
  Wire.endTransmission();
  delay(1);


  //16バイト連続読み
  unsigned int ii=0;
  unsigned char s[32+1];
  Wire.requestFrom(0x50, 16);
  //データが続くだけ読む
  while(Wire.available())  {    // 要求より短いデータが来る可能性あり
    s[ii++] = (int)Wire.read(); // 1バイトを受信
  }//while


  //受信データの表示
  for (int jj = 0; jj < 16; jj++) {
    //データ
    Serial.println( (int)s[jj] );
  }//for

}//setup

//メインループ
void loop()
{
}//loop




0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0