pdf-icon

Arduino入門

2. デバイス&サンプル

5. 拡張モジュール&サンプル

アクセサリー

6. アプリケーション

Unit PoE-P4 IR 赤外線送信

Unit PoE-P4 の IR 赤外線送信に関するライブラリとサンプルプログラム。

サンプルプログラム

コンパイル要件

  • M5Stack ボードマネージャー版 >= 3.2.6
  • 開発ボード選択 = M5UnitPoEP4
  • M5Unified ライブラリ版 >= 0.2.13
  • IRremote ライブラリ版 >= 4.5.0
cpp
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
#include <IRremote.hpp>
#include <M5Unified.h>

#define IR_SEND_PIN    14      

// Demo parameters for NEC protocol
uint16_t address = 0x0000;     // Starting device address
uint8_t  command = 0x55;       // Starting command value
uint8_t  repeats = 0;          // Number of repeat transmissions

void setup() {
    M5.begin();                // Initialize M5Stack device
    Serial.begin(115200);      // Start serial communication at 115200 baud
    delay(200);                // Wait for serial port to stabilize

    Serial.println("Unit PoE-P4 IRremote example");

    // Initialize IR communication
    IrSender.begin(DISABLE_LED_FEEDBACK);  // Initialize IR sender without LED feedback
    IrSender.setSendPin(IR_SEND_PIN);      // Assign transmitter pin

    Serial.printf("IR Send Pin: %d\n", IR_SEND_PIN);
    delay(500); // Wait for hardware components to stabilize
}

void loop() {
    // Send infrared signal using NEC protocol
    Serial.printf("Send NEC: addr=0x%04x, cmd=0x%02x\n", address, command);
    IrSender.sendNEC(address, command, repeats);

    // Update transmission parameters for next cycle
    address += 0x0001;  // Increment device address
    command += 0x01;     // Increment command code
    repeats  = 0;        // Disable repeat frames (set >0 to test repeats)

    delay(2000);
}

Unit PoE-P4 は 2 秒ごとに NEC 赤外線フレームを送信します。アドレスとコマンドはそれぞれ 0x0000 と 0x55 から始まり、送信ごとにインクリメントされます。NEC プロトコル対応の赤外線受信機を使って受信を確認できます。

ドライバライブラリ

On This Page