Recording commands from LEGO Power Functions remote controls and playing them. Using IR Receiver Module Iduino ST1089 and IR 940 nm emitting diode.
LEGO Power Functions RC documentation: https://www.philohome.com/pf/LEGO_Power_Functions_RC.pdf
- all PF remote controls are supported
- saveing 10 recordings
- possibility to play in reverse order
- possibility to reverse commands from specified channel and output
- start/stop record - Button A or Rremote Control Red Forward
- start/stop play - Button B or RC Red Backward
- next record number - Button AB or RC Blue Forward
- previous record number - RC Blue Backward
- playing commands in reverse order - RC Red and Blue Forward
- playing reversed commands (from channel 1) in reverse order - RC Red and Blue Backward
** Sometimes program registers more commands because some commands are missed by LEGO PF receiver.**
Lighting the diode and the IR receiver with sunlight ☀️ or from an ordinary light bulb 💡 may interfere with the signal reception.
Initialize recorder.
pfRecorder.init(
DigitalPin.P2,
AnalogPin.P0,
PfReceiverChannel.Channel2,
false
)
irReceiverPin
- the digital pin where IR Receiver Module is connected, eg: DigitalPin.P2irTransmitterPin
- the analog pin where IR diode is connected, eg: AnalogPin.P0recorderControlChannel
- the channel (0-3) for controlling recorder from PF remote control, eg: 1skipAllStop
- if true, in Combo Direct Mode skips state: Red Float, Blue Float
Returns commands list in reversed order.
let commandsInReversedOrder = pfRecorder.reverseOrder(recordedCommands);
commands
- the recorded commands
Processes and returns command list reversing only commands from given channel and output.
let reversedCommands = pfRecorder.reverseCommands(recordedCommands, 0, 0);
commands
- the recorded commandschannel
- the channel (0-3), eg. 0output
- the output: 0 (Red), 1 (Blue), eg. 0
Plays commands recorded by PF Receiver extension.
pfRecorder.play(commands)
commands
- the array with data of recorded commands
Stops playing commands and stops all used outputs channels.
pfRecorder.stopPlaying()
pfRecorder.init(
DigitalPin.P2,
AnalogPin.P0,
PfReceiverChannel.Channel2,
false
)
LEGO® is a trademark of the LEGO Group of companies which does not sponsor, authorize or endorse this project.
Copyright (C) 2021 Adam Orczyk
Licensed under the MIT License (MIT). See LICENSE file for more details.
- for PXT/microbit