IR
Overview¶
The most easiest way to get a user input is using push button switches.
However, Many pins on mbed have a peripheral and we can't use their pin if we use the peripherals.
It's OK to add a few switches. But over 10 switches ... It's not good way to get a user inputs. It's not beautiful way for it.
So I created IR remote transmitter and receiver class library.
You can get a user inputs with only a pin if you use this class library.
Now we can control many machines that have a IR port.

The simple interfaces¶
To setup the receiver.
#include "ReceiverIR.h" ReceiverIR ir_rx(p15);
To use the receiver.
RemoteIR::Format format;
uint8_t buf[32];
int bitcount;
if (ir_rx.getState() == ReceiverIR::Received) {
bitcount = ir_rx.getData(&format, buf, sizeof(buf) * 8);
}
To setup the transmitter.
#include "TransmitterIR.h" TransmitterIR ir_tx(p21);
To use the transmitter.
RemoteIR::Format format = RemoteIR::SONY;
uint8_t buf[] = { 0x80, 0x00 };
int bitcount = 12;
if (ir_tx.getState() == TransmitterIR::Idle) {
bitcount = ir_tx.setData(format, buf, bitcount);
}
That's it all.
It's easy to setup your IR remote application.
API¶
Import library
Public Types |
|
| enum | State |
|
State. More... |
|
Public Member Functions |
|
| ReceiverIR (PinName rxpin) | |
|
Constructor.
|
|
| ~ReceiverIR () | |
|
Destructor.
|
|
| State | getState () |
|
Get state.
|
|
| int | getData (RemoteIR::Format *format, uint8_t *buf, int bitlength) |
|
Get data.
|
|
Import library
Public Member Functions |
|
| TransmitterIR (PinName txpin) | |
|
Constructor.
|
|
| ~TransmitterIR () | |
|
Destructor.
|
|
| State | getState (void) |
|
Get state.
|
|
| int | setData (RemoteIR::Format format, uint8_t *buf, int bitlength) |
|
Set data.
|
|
Library¶
Import libraryRemoteIR
RemoteIR.
Example application¶
Import programRemoteIR_TestProgram
A test program for RemoteIR library.
The receiver¶

The transmitter¶

