View on GitHub

lego-pf-receiver

Receiving commands from LEGO Power Functions remote controls.

Power Functions Receiver

Receiving commands from LEGO Power Functions remote controls using IR Receiver Module Iduino ST1089. Running given function when specific button is pressed or released.

Features:

References:

:warning: Warning!

Lighting the diode and the IR receiver with sunlight :sunny: or from an ordinary light bulb :bulb: may interfere with the signal reception.

Documentation

pfReceiver.connectIrReceiver

Connects to the IR receiver module at the specified digital pin.

pfReceiver.connectIrReceiver(DigitalPin.P2)

Parameters

pfReceiver.onCommand

Do something when a specific command is sent.

pfReceiver.onCommand(0, 0b110, 0b100, PfAction.Pressed, () => {
    basic.showIcon(IconNames.Happy)
})

Parameters

pfReceiver.onSpeedRCcommand

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

pfReceiver.onSpeedRCcommand(PfReceiverChannel.Channel1, PfSpeedControl.RedIncrement, PfAction.Pressed, () => {
    counter += 1;
})

Parameters

pfReceiver.onRCcommand

Do something when a specific state of buttons on the PF remote control is achieved.

pfReceiver.onRCcommand(PfReceiverChannel.Channel1, PfControl.Forward, PfControl.Float, PfAction.Pressed, () => {
    basic.showIcon(IconNames.SmallHeart)
})

Parameters

pfReceiver.startRecord

Starts saving commands from the PF remote controls from given channels.

pfReceiver.startRecord([0]);

Parameters

pfReceiver.stopRecord

Stops saving commands.

pfReceiver.stopRecord();

pfReceiver.getRecordedCommands

Returns recorded commands.

pfReceiver.getRecordedCommands();

MakeCode Example

pfReceiver.connectIrReceiver(DigitalPin.P2)

pfReceiver.onRCcommand(PfReceiverChannel.Channel1, PfControl.Forward, PfControl.Float, PfAction.Pressed, () => {
    basic.showIcon(IconNames.Heart)
})

pfReceiver.onRCcommand(PfReceiverChannel.Channel1, PfControl.Forward, PfControl.Float, PfAction.Released, () => {
    basic.clearScreen()
})

Disclaimer

LEGO® is a trademark of the LEGO Group of companies which does not sponsor, authorize or endorse this project.

License

Copyright (C) 2021 Adam Orczyk

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

Supported targets