Infrared Remote-control Receiver Module "IRM-3638N3" was bought by way of experiment, and it tied to mbed.

There was something good remote control or it tried thinking that AppleRemote might be able to be used though it looked for.

Because AppleRemote is 38kHz in NEC IR Protocol, it is possible to receive it.



Sample Code


#include "mbed.h"
#include "AppleRemote.h"

Serial pc(USBTX, USBRX);
AppleRemote remote(p5);

int main() {


    while(1) {
            int code;
            code = remote.getc() & 0x0ff;
            pc.printf("code = %02X ",code);
                /* --- */
                case AppleRemote::MENU_1ST:   pc.printf("Menu (1st generation)\n"); break;
                case AppleRemote::PLAY_1ST:   pc.printf("Play (1st generation)\n"); break;
                case AppleRemote::RIGHT_1ST:  pc.printf("Right (1st generation)\n"); break;
                case AppleRemote::LEFT_1ST:   pc.printf("Left (1st generation)\n"); break;
                case AppleRemote::UP_1ST:     pc.printf("Up (1st generation)\n"); break;
                case AppleRemote::DOWN_1ST:   pc.printf("DOWN (1st generation)\n"); break;
                /* --- */
                case AppleRemote::CENTER_2ND: pc.printf("Center (2nd generation)\n"); break;
                case AppleRemote::MENU_2ND:   pc.printf("Menu (2nd generation)\n"); break;
                case AppleRemote::PLAY_2ND:   pc.printf("Play (2nd generation)\n"); break;
                case AppleRemote::RIGHT_2ND:  pc.printf("Right (2nd generation)\n"); break;
                case AppleRemote::LEFT_2ND:   pc.printf("Left (2nd generation)\n"); break;
                case AppleRemote::UP_2ND:     pc.printf("Up (2nd generation)\n"); break;
                case AppleRemote::DOWN_2ND:   pc.printf("DOWN (2nd generation)\n"); break;
                default: pc.printf("*** UNKNOWN ***\n"); break;

AppleRemote was different at all the key code at the first generation and the second generation.

It is signal with NEC IR Protocol the same.
However, the key code was not reversed.
It seems to return "Remote ID" instead of the reversing key code.


This program uses the interruption. The key code does buffering. The size is 15.

Because the serial is received in software, it is not suitable for a real-time key input.
However, if a real-time key input process is unnecessary, it might be convenient because only one pin is used.

I am not good at English. Please forgive me if the mistake is found.


You need to log in to post a comment