1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

保留中)M5NanoC6、スレーブI2Cで「46」を返して遊ぶ。(M5NanoC6は、よみだしモードに対応してなさそう?

Last updated at Posted at 2024-10-19

工事中

いろいろ
I2C系をakb48の歌のようにヘビーローテーションする予定
ついて、来れるかな
もしかしたら、M5NanoC6は、よみだしモードに対応してなさそう?
(UNO3 I2Cホスト READモード)←→(StampS3 I2Cスレーブ )は、いった

たぶんうごかない




//I2C_Slave_A_M5NanoC6_1


//インクルド
#include <Arduino.h>
#include <Wire.h>


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

  //i2cの初期化
  Wire.begin( (0x80)>>1 );      //I2Cスレーブアドレスの設定
  Wire.onRequest(requestEvent);

}//setup


//メインループ
void loop() {
  delay(1); //ダミー
}//loop


//I2Cの読み取り関数
void requestEvent() {

  //値の送信
  Wire.write( 'A' );

}//requestEvent






//I2C_MAIN_A_M5StampS3_1


//インクルド
#include <Arduino.h>
#include <Wire.h>   //I2C


//初期化
void setup()
{

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

} //setup


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

  // I2Cスレーブにデータを要求する
  Wire.requestFrom( (0x80)>>1 , 1);

  // データを取得する
  char data_read[32] = {0xFF}; //データバッファー
  int ii = 0;
  while (Wire.available())  {   // 要求より短いデータが来る可能性あり
    data_read[ii++] = Wire.read();       // 1バイトを受信
  }//while

  if(ii != 0 ){
    Serial.print( data_read[0] ); //受信した文字を表示する
  }else{
    Serial.print( "[ERR]" );
  }
  delay(1000); //1秒待つ

} //loop


1
2
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
1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?