pdf-icon

Arduino Quick Start

2. Devices & Examples

6. Applications

NanoC6 IR NEC Transmitter

NanoC6 IR NEC transmitter related APIs and sample program. This example uses the Arduino-IRremote library to implement NEC encoding.

Sample Program

Compilation Requirements

  • M5Stack board manager version >= 3.2.5
  • Development board option = M5NanoC6
  • IRremote library version >= 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 38 39 40 41
#include <IRremote.hpp>
#define IR_TX_PIN 3  // IR transmitter pin for NanoC6

uint8_t sCommand = 0x34;
uint8_t sRepeats = 0;

void setup() {
  Serial.begin(115200);

  // Initialize IR transmitter
  IrSender.begin(IR_TX_PIN, DISABLE_LED_FEEDBACK);

  Serial.println("NanoC6 IR NEC Transmitter");
  Serial.println("Sending incremental NEC codes...");
}

void loop() {
  Serial.println();
  Serial.print("Send now: address=0x1111, command=0x");
  Serial.print(sCommand, HEX);
  Serial.print(", repeats=");
  Serial.print(sRepeats);
  Serial.println();

  // Display on Serial
  Serial.println("--- IR NEC SEND ---");
  Serial.println("ADDR: 0x1111");
  Serial.print("CMD: 0x");
  Serial.println(sCommand, HEX);
  Serial.println("-------------------");

  // Send NEC IR signal
  Serial.println("Sending standard NEC with 16 bit address");

  IrSender.sendNEC(0x1111, sCommand, sRepeats);

  // Increment command for next transmission
  sCommand += 1;

  delay(1000);  // Wait 1 second between transmissions
}

This program sends NEC protocol signals through the onboard IR transmitter and outputs messages to the serial monitor:

API

The NanoC6 IR NEC transmitter driver uses the IrSender_Class from the IRremote library. For more related APIs, please refer to the documents below:

On This Page