1
1

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で「A」を受信して遊ぶ。

Last updated at Posted at 2024-10-18

目的
I2Cのテスト

いろいろ
ネットを見ているとM5NanoC6を買ってきて、直ぐに使える、
便利なアプリが全然ないと書いてあったが
便利なアプリは、自分で作るんです。「エエエェェーーー」
おもに通信系が「全然」足りないみたい。
買ってすぐ「アンテナ」にする、アプリとか
アンテナてなんじゃー、送信機、受信機もアンテナに
含まれるのか?「エエエェェーーー」
ノンコード、ローコードでI2Cで無線で送受信
もしくは、接点情報の送受信

結果

o_coq524.jpg

o_coq525.jpg

プログラム

受信 I2Cスレーブ M5NanoC6



//I2C_READ_A_V1_M5NanoC6_1


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


//初期化
void setup() {

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

  //i2cの初期化
  Wire.begin( (0x80)>>1 );      //I2Cスレーブアドレスの設定
  Wire.onReceive(receiveEvent); //データが来ると呼ばれる関数

} //setup


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


//レシーブイベント
void receiveEvent(int howMany) {

  char c = Wire.read(); //I2C受信データの読み込み

  Serial.print(c); //一文字送信する。

} //receiveEvent


送信 I2Cマスター M5Stamp S3



//I2C_PUT_A_M5S3_1


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


//初期化
void setup() {

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

} //setup


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

  //'A'転送
  Wire.beginTransmission( (0x80)>>1 );
  Wire.write('A');
  Wire.endTransmission();
  delay(1000); //1秒待つ

} //loop

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?