Skip to content

IRremote library API

Max Buchholz edited this page Apr 19, 2019 · 4 revisions

The API uses an IRsend object to send a code, and an IRrecv object to receive a code. The library cannot send and receive at the same time, but can switch between sending and receiving.

Sending

IRsend irsend;

Creates a send object

irsend.sendNEC(data, bits)

Sends the value as an NEC-format IR code. bits specifies the length of the code, typically 16.

irsend.sendSony(data, bits)

Sends the value as a Sony-format IR code.

irsend.sendSAMSUNG(data, bits)

Sends the value as a Samsung-format IR code.

irsend.sendRC5(data, bits)

Sends the value as a RC5-format IR code.

irsend.sendRC6(data, bits)

Sends the value as a RC6-format IR code.

irsend.sendRaw(buf, len, hertz)

Sends a code corresponding to the buffer of raw durations.

Receiving

IRrecv irrecv(pin);

Creates a receiver object.

irrecv.enableIRIn();

Starts listening for an IR code.

int irrecv.decode(&results)

Returns 1 if there is a received code available, and 0 otherwise.
The fields of results are:

decode_type NEC, SONY, RC5, RC6, or UNKNOWN
value the received code value
bits The number of bits received
rawbuf[] Raw durations
rawlen Number of records in rawbuf
irrecv.resume()

This must be called after irrecv.decode() to resume listening for a code.