This is the mirror repository. Original repository is hosted under: https://github.com/gmamaladze/LegoRC.net

LEGO Power Functions IR RC Library

Let's assume you already assembled your favorite rover, railway or a robot using LEGO power functions. You might have used up to 8 motors, servos or LEDs. Every of 4 receivers is tuned to one of 4 channels and can be used to control 2 actuators. Controlling all that requires 4 IR transmitters or .. a Netduino + 1 x IR LED and this library.

Using this library is as simple a building LEGO.

Q: What is LEGO Power Functions?

Getting started

  1. You need a Netduino hardware
  2. .NET Micro Framework development environment
  3. An Infrared LED and an appropriate resistor

  4. Add LegoRC.Net NuGet package to your project. Or alternatively clone this repository and add the project Lego.PowerFunctions.csproj to your solution.

How to connect

This trivial circuit will work with most of IR LEDs and for short distances. For longer distances you would probably need a better circuit. See: Infrared transmitter driver for Netduino.

 

How to use

Using this library is literally like building you LEGO vehicle. Like in the reality you are putting components together. Components which won't work together don't fit together.

Example

Another Example

    public static void Main()
    {
        using (var transmitter = new Transmitter())
        {

            //Firts vehiclle
            var receiverTrain = new Receiver(transmitter, Channel.Ch1);
            var motor = new Motor(receiverTrain.RedConnector);
            var light = new Led(receiverTrain.RedConnector);

            //Rover on another channel
            var receiverRover = new Receiver(transmitter, Channel.Ch2);
            var drive = new Motor(receiverRover.BlueConnector);
            var steeringWheel = new Servo(receiverRover.RedConnector);

            //Now Control
            while (true)
            {
                motor.IncSpeed();
                light.TurnOn();

                drive.SetSpeed(100);
                steeringWheel.SetAngle180(45);

                Thread.Sleep(10000);

                steeringWheel.Center();
                motor.Brake();

                light.TurnOff();
            }
        }
    }

Component Design

Layering Diagram

Layering Diagram

Class Diagram

Class Diagram

Last edited Jun 13 at 11:28 PM by gmamaladze, version 2