Approved content

The content below is provided by a partner.

1010technologies/pxt-makerbit-ir-receiver 1.5.14 GitHub

MakerBit IR Receiver

Build Status

MakeCode extension for Keyestudio Infrared Wireless Module Kit. The extension should also work with other with IR receivers and NEC compatible IR remotes.

MakerBit Board

The MakerBit connects to the BBC micro:bit to provide easy connections to a wide variety of sensors, actuators and other components.

http://makerbit.com/

MakerBit MakerBit+R
MakerBit MakerBit+R with motor controller

Documentation

makerbit.connectIrReceiver

Connects to the IR receiver module at the specified pin and configures the IR protocol.

makerbit.connectIrReceiver(DigitalPin.P0, IrProtocol.Keyestudio)

Parameters

makerbit.onIrButton

Do something when a specific button is pressed or released on the remote control.

makerbit.onIrButton(IrButton.Ok, IrButtonAction.Pressed, () => {})

Parameters

makerbit.irButton

Returns the code of the IR button that was pressed last. Returns -1 (IrButton.Any) if no button has been pressed yet.

makerbit.irButton()

makerbit.onIrDatagram

Do something when a specific button is pressed or released on the remote control.

makerbit.onIrDatagram(() => {})

Parameters

makerbit.irDatagram

Returns the IR datagram as 32-bit hexadecimal string. The last received datagram is returned or “0x00000000” if no data has been received yet.

makerbit.irDatagram()

makerbit.wasIrDataReceived

Returns true if any IR data was received since the last call of this function. False otherwise.

makerbit.wasIrDataReceived();

makerbit.irButtonCode

Returns the command code of a specific IR button.

makerbit.irButtonCode(IrButton.Number_9)

Parameters

MakeCode Example

makerbit.connectIrReceiver(DigitalPin.P0, IrProtocol.Keyestudio)

makerbit.onIrButton(IrButton.Ok, IrButtonAction.Released, function () {
    basic.showIcon(IconNames.SmallHeart)
})

makerbit.onIrButton(IrButton.Ok, IrButtonAction.Pressed, function () {
    basic.showIcon(IconNames.Heart)
})

basic.forever(function () {
    if (makerbit.wasAnyIrButtonPressed()) {
        basic.showNumber(makerbit.irButton())
    }
})

License

Licensed under the MIT License (MIT). See LICENSE file for more details.

Supported targets

MakerBit-IR-Receiver=github:1010technologies/pxt-makerbit-ir-receiver#v1.5.14