0
0

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をZigbee調光電球[305.415.15]の調光リモコンにする

0
Last updated at Posted at 2026-06-05

Screenshot From 2026-06-06 05-38-17.png

結果

なんとなく動いた

Screenshot From 2026-06-06 05-41-45.png

プログラム



//net_zigbee_test_led2_m5nanoh2_1


//受信以外は、エラー
#ifndef ZIGBEE_MODE_ZCZR
#error "Zigbee end device mode is not selected in Tools->Zigbee mode"
#endif


//インクルド
#include "Zigbee.h"  //ジグビー


//定義 カラー調光器のスイッチ
ZigbeeColorDimmerSwitch zb_switch = ZigbeeColorDimmerSwitch(1);


//初期化
void setup() {

  //シリアルポートの開始
  Serial.begin(115200);

  Zigbee.addEndpoint(&zb_switch);  //エンドポイントの追加
  Zigbee.setRebootOpenNetwork(180);

  //ジグビーの開始
  Serial.println();
  Serial.println("Zigbee.begin()");
  if (!Zigbee.begin(ZIGBEE_COORDINATOR)) {

    Serial.println("Zigbee.begin() failed");
    abort();

  }  //endif


  //バインドされているか?
  Serial.println("Waiting for binding");
  while (!zb_switch.bound()) {

    Serial.print(".");
    delay(500);  //0.5秒待つ

  }  //while
  Serial.print("\n");

}  //setup


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

  //バインドされているか?
  if (!zb_switch.bound()) {

    return;

  }  //endif



  zb_switch.setLightLevel(0);delay(3000); // 0%

  zb_switch.setLightLevel(33);delay(3000); // 33%

  zb_switch.setLightLevel(66);delay(3000); // 66%

  zb_switch.setLightLevel(100);delay(3000); // 100%


  //zb_switch.lightToggle();  //スイッチをトグルする
  //delay(3000);  //3秒待つ

  //ライトの状態を切り替え
  //zb_switch.lightOn();
  //delay(3000);

  // ライトの状態を切り替え
  //zb_switch.lightOff();
  //delay(3000);

}  //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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?