Blog Post

LEGO Mindstorms EV3 API

Sign in to queue

The Discussion

  • User profile image
    AndrzejS

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

  • User profile image
    SanChan

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

  • User profile image
    hfpsc27

    Great! I love Lego...

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

    Awesome kiddy Fun with Lego and Windows Phone.

  • User profile image
    pa0akv

    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()
    {
    InitializeComponent();
    }
    
    private async void Grid_Loaded(object sender, RoutedEventArgs e)
    {
    _brick = new Brick(new NetworkCommunication("192.168.178.19"));
    _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 http://www.monobrick.dk/software/monobrick/
    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


    www.youtube.com/watch?v=vciztvXg4Yk‎

  • User profile image
    Kiran​Ravindranat​han

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

  • User profile image
    Troy

    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
    njsokalski

    @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
    Konstantin

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

  • User profile image
    kokani

    @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 email:sumbuko2000@yahoo.com

  • User profile image
    Coiledwire

    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);

  • User profile image
    Stefano

    During the part about the motors, each time I start the test app, it runs the motor during the form load part. It only does this if I sent a move forward or backwards motor command in a previous run. What is causing this? I am currently using the api from nugget.

Add Your 2 Cents