Blog Post

LEGO Mindstorms EV3 API

Download this episode

Download Video

Download captions

Download Captions


As developers, we're always excited to see the next generation take interest in science, technology, engineering and mathematics (STEM). That interest is shared by our friends over at LEGO Education, the people responsible for the new LEGO MINDSTORMS EV3. Inspired by their new robotics kits, we created SentryBot with MINDSTORMS, two Surface Pros and new Windows 8.1 APIs to demo at Build 2013

Now that Windows 8.1 and the MINDSTORMS EV3 are available publically, we're releasing an API for you to make whatever robotic future you (or your kids) can dream up. The API provides access to control the motors and read real-time data from the sensors. You can connect to and control your LEGO EV3 brick over Bluetooth, WiFi, or USB. The project provides libraries that are usable from the Windows desktop, Windows Phone 8, and WinRT (via .NET, WinJS and C++), along with full source code and samples.

Head over to CodePlex and check out the source code at

  1. [05:49] Getting Started
  2. [12:31] Controlling Motors
  3. [24:16] Controlling Sensors
  4. [30:12] Using System Command



Available formats for this video:

Actual format may change based on video formats available and browser capability.

    The Discussion

    • User profile image

      It's awesome! I must buy it Big Smile Controlling LEGO robot via WP8 is a nice feature.

    • User profile image

      Cool! thanks a lot for that introduction to LEGO MINDSTORMS EV3

    • User profile image

      Great! I love Lego...

    • User profile image
      pretty coooool, i gonna be get one for fun
    • User profile image

      Awesome kiddy Fun with Lego and Windows Phone.

    • User profile image

      First time using the API!

      using System;
      using System.Collections.Generic;
      using System.Linq;
      using System.Text;
      using System.Threading.Tasks;
      using System.Windows;
      using System.Windows.Controls;
      using System.Windows.Data;
      using System.Windows.Documents;
      using System.Windows.Input;
      using System.Windows.Media;
      using System.Windows.Media.Imaging;
      using System.Windows.Navigation;
      using System.Windows.Shapes;
      using Lego.Ev3.Core;
      using Lego.Ev3.Desktop;
      namespace andre_probeer_lego_ev3
      /// <summary>
      /// Interaction logic for MainWindow.xaml
      /// </summary>
      public partial class MainWindow : Window
      private Brick _brick;
      Int16 _vooruit = 5;
      Int16 _achteruit = -5;
      Int16 _snelheid = 10;
      uint _tijd = 1000;
      public MainWindow()
      private async void Grid_Loaded(object sender, RoutedEventArgs e)
      _brick = new Brick(new NetworkCommunication(""));
      _brick.BrickChanged += _brick_BrickChanged;
      await _brick.ConnectAsync();
      await _brick.DirectCommand.PlayToneAsync(20, 850, 1000);
      Project.Content = "Lego EV3 PA0AKV 2013";
      Display.Content = "Start";
      void _brick_BrickChanged(object sender, BrickChangedEventArgs e)
      //throw new NotImplementedException();
      private async void Achteruit_Click(object sender, RoutedEventArgs e)
      await _brick.DirectCommand.TurnMotorAtPowerForTimeAsync(OutputPort.B | OutputPort.C,_achteruit,_tijd, false);
      private async void Vooruit_Click(object sender, RoutedEventArgs e)
      await _brick.DirectCommand.TurnMotorAtPowerForTimeAsync(OutputPort.B | OutputPort.C, _vooruit, _tijd, false);
      private async void Links_Click(object sender, RoutedEventArgs e)
      _brick.BatchCommand.TurnMotorAtPowerForTime(OutputPort.B, _vooruit, _tijd, false);
      _brick.BatchCommand.TurnMotorAtPowerForTime(OutputPort.C, _achteruit, _tijd, false);
      await _brick.BatchCommand.SendCommandAsync();
      private async void Rechts_Click(object sender, RoutedEventArgs e)
      _brick.BatchCommand.TurnMotorAtPowerForTime(OutputPort.C, _vooruit, _tijd, false);
      _brick.BatchCommand.TurnMotorAtPowerForTime(OutputPort.B, _achteruit, _tijd, false);
      await _brick.BatchCommand.SendCommandAsync();
      private void Regelaar_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
      _snelheid = Convert.ToInt16(Regelaar.Value);
      Display.Content = Regelaar.Value;
      Vooruit1.Content = _snelheid;
      Achteruit1.Content = _snelheid * -1;
      _vooruit = _snelheid;
      _achteruit =Convert.ToInt16(_vooruit * -1);

      It opens a form and with the slider you can manage the speed!

      It is important to change the wifi IP adress otherwise the brick cannot connect! Perplexed

      If you like the program I can mail it to you!

      This is my first C# program and it is not documented yet but it will come!


    • User profile image
      Gert Heriksen

      You could also use the MonoBrick library found at
      It works with Mac OS, Linux and Windows using Mono. Apparently it also works with Windows Phone and Android.

    • User profile image
      andre koopman

      You are right, I also made the same thing with monobrick. I still do not know wich is the easiest way!

    • User profile image
      bart dagelet‎

    • User profile image

      Thanks for this nice Video. Time to get into it. 

    • User profile image

      How do you record this video? What software do you use?

    • User profile image
      Richard Chang

      Can you provide a link to the sample program with the 4 buttons.
      The sample download doesn't have that example and I don't know XAML.

      Thanks, RC

    • User profile image
      Richard Chang

      Also, with the Lego EV3 IDE you can create a Project and create programs and then download to the brick to run.

      Can we do that ( create a program and download to the brick ) with the API ?

      Thanks, RC

    • User profile image

      @Gert Heriksen: I tried to use MonoBrick, and I'm sure that it works when done correctly, but I found this one much easier to configure. I spent a long time trying to get MonoBrick to work, but never succeeded. But when I found this, I was able to get it installed, setup, and working in just a day or two. I think both are probably great and probably relatively easy to use once they are setup, but I still recommend Lego.EV3 because CodePlex has good forums and is very reliable. Also, the fact that Lego.EV3 can be installed using NuGet in Visual Studio is a good bonus.

    • User profile image

      Does the .net API presented in he video allow to get motor stress level from servos?
      Thank you

    • User profile image

      @pa0akv: Just got the link and am a beginner in C# Programming. Already doing pretty well with the building of the LEGO ROBOTS. The programming part now is my interest. Please send me the program I give it a try. My

    • User profile image

      can any one help me how to control ev3 motor by angle.

      for example - what code I use to lets say move motor 30 degree angle.

      I am trying to use following function that has steps input but I don't feel like steps and angle are related as I get different degree for same steps.

      await _brick.DirectCommand.StepMotorAtPowerAsync(OutputPort.A, fwd_power, _steps, false);

    Comments closed

    Comments have been closed since this content was published more than 30 days ago, but if you'd like to continue the conversation, please create a new thread in our Forums, or Contact Us and let us know.