I at the moment am trying to make an EV3 robot which is capable of following a gradient decent method. The idea was to store a discretized function in a 2D matrix, and make several lookups in that 2D matrix where I compute the difference between its position and its neighbor's position. and then make the robot move in the direction with descending gradient.

To do so...

How do I use the EV3 software to:

  • Create a Matrix?
  • Store values in matrix?
  • Make lookups in matrix?
  • Subtract those lookups?

This could be way easier in C++, but is there any supported firmware capable of running C or C++ in the same way as with NXC or something like this? Something with some form of documentation?

  • Have you looked at LeJOS? Java for the EV3 ... pretty sure you can get this done there.
    – Phil B.
    Commented Jan 19, 2016 at 14:35
  • Java.. yeah, could i be done using c/c++?
    – Bob Burt
    Commented Jan 19, 2016 at 14:37
  • Sure, check out RobotC
    – Phil B.
    Commented Jan 19, 2016 at 14:52
  • Problem is that i have to buy it, and the trial only runs for 10 days, which wouldn't be sufficient amount of time to test it, and see whether the coded solution has the wanted easiness..
    – Bob Burt
    Commented Jan 19, 2016 at 14:57
  • 1
    Then check out this post on our sister site StackOverflow: stackoverflow.com/questions/28526200/…
    – Phil B.
    Commented Jan 19, 2016 at 14:59

2 Answers 2


This application does seem to be pushing the limits of the official software provided by LEGO. If you are interested in C/C++ (or any other programming language), check out http://www.ev3dev.org.

I like to say that ev3dev is not firmware since it runs from a microSD card and is not loaded into the flash memory on the EV3. Nevertheless, it is an alternate operating system for the EV3 with the goal of being able to program in any language that you like. You can find a list of existing programming libraries here.

  • I think i'll try this and see how it goes.. :)
    – Bob Burt
    Commented Jan 27, 2016 at 13:07

EV3-G supports single dimensional arrays only. You could write one array that is m times n in length where m is the number of rows, and n is the number of columns. The correct row of the single dimensional array would be (col-1)*n+row. You would have to write a myBlock to convert 2D index values to 1D index values and vice versa. However, doing matrix manipulations in EV3-G is painful. Using the array block, all you can really do is read at an index, write at an index, append, and calculate array length. This would cover most of your goals (assuming you convert the 2D to a 1D array). Possible, but painful. ev3dev, LeJOS, or RobotC all would be better methods and they support multidimensional arrays.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.