/lego-power-functions-receiver

A Particle library enabling communication with LEGO Power Functions IR Receiver.

Primary LanguageC++OtherNOASSERTION

lego-power-functions-receiver

A Particle library for controllling the Lego Power Functions IR Receiver.

Credit where credit is due: This library is based on jurriaan's code as well as the 1.2 specification of the ir receiver. Thanks!

Usage

This library enables communication with the IR receiver.

#include "lego-power-functions-receiver.h"

const int ir_led_pin = D0; 
LegoPowerFunctions lpf(ir_led_pin, channel, LPF_RECEIVER_BLUE);

void setup() {
  Serial.begin(9600);
  lpf.step_forwards();  
}

void loop() {

  lpf.go();
}

See the examples folder for more details.

Documentation

This is a library that enables control of a Lego Train. Just like a the remote, but programatically, through Particle.

Arguments

  1. ir_led_pin: the pin of the IR LED, on your Particle device
  2. channel: Must match the selected channel on the receiver (1-4)
  3. output: The receiver has one red and one blue output, respectively: LPF_RECEIVER_RED and LPF_RECEIVER_BLUE

Methods

  • .go, sends signal to move at selected speed
  • .step_forwards increases speed, until maximum
  • .step_backwards decreases speed, until minimum
  • .stop sends signal to stop

Contributing

Here's how you can make changes to this library and eventually contribute those changes back.

To get started, clone the library from GitHub to your local machine.

Change the name of the library in library.properties to something different. You can add your name at then end.

Modify the sources in and with the new behavior.

To compile an example, use particle compile examples/usage command in Particle CLI or use our Desktop IDE.

After your changes are done you can upload them with particle library upload or Upload command in the IDE. This will create a private (only visible by you) library that you can use in other projects. Do particle library add lego-power-functions-receiver_myname to add the library to a project on your machine or add the lego-power-functions-receiver_myname library to a project on the Web IDE or Desktop IDE.

At this point, you can create a GitHub pull request with your changes to the original library.

If you wish to make your library public, use particle library publish or Publish command.

LICENSE

Copyright 2020 @olaven

Licensed under the license