Before you can start writing code that runs on ev3dev, you need to choose a programming language. Community members have built libraries that let you use features such as motors and sensors from your code. Choose the language you want from below and follow the link to the library’s homepage get started.
If the language you want isn’t listed, you still can use it, but you’ll have to do more of the heavy lifting yourself. You can look at the driver overview page for information on the interfaces you need to use to control devices. Once you get the hang of it, you can even write your own interface library and have it listed on the programming languages page!
https://github.com/ev3dev/ev3dev-lang-python
Python is a high-level, general-purpose, interpreted scripting language. It is great for beginners, while also powerful for experienced coders. If you are new to programming and unsure which language to choose, Python is a great choice!
If you are just starting programming ev3dev, take a look at ev3python.com by @ndward. The site is intended to help users of the LEGO MINDSTORMS EV3 to begin using the ev3dev Python programming language to control their robot.
There are also some sample programs at https://github.com/ev3dev/ev3dev-lang-python-demo.
Warning! There is another Python library named python-ev3
created by
@topikachu which is not the same as this one. When searching for documentation
online, make sure that you are reading about ev3dev-lang-python
.
https://github.com/pybricks/pybricks-micropython/tree/v2
MicroPython is a stripped down variant of the Python programming language. This brings some advantages, like programs starting significantly faster than regular Python, but comes at the cost at not being fully compatible with code written for regular Python.
MicroPython works as a different Python interpreter, rather than as a library.
It can be invoked by running it from the command line, for example:
micropython -c "import sys; print(sys.version)"
or
micropython -c "from ev3dev2.sound import Sound; Sound().speak('hello world')"
.
You may add this as the first line of your Python script to run it with MicroPython:
#!/usr/bin/env micropython
.
TIP: ev3dev-lang-python
is also partially compatible with MicroPython.
Pybricks is a specialized version of MicroPython for LEGO MINDSTORMS and LEGO Powered Up smart hubs. Pybricks v2.0 is used by LEGO Education as their Python for EV3 solution and is the same version that is available in ev3dev-stretch.
You may run Pybricks from command line like this:
brickrun -r -- pybricks-micropython -c "from pybricks.hubs import EV3Brick; EV3Brick().speaker.beep()"
.
You may add this as the first line of your Python script,
#!/usr/bin/env pybricks-micropython
,
and then run it from the brick’s file browser to run it with Pybricks.
TIP: If you are into using Python’s interactive mode when trying Pybricks,
you can use brickrun -r -- pybricks-micropython
, or its shortcut pybricks-repl
.
http://ev3dev-lang-java.github.io/
Java is a general-purpose computer programming language that is concurrent, class-based and object-oriented. In Java 8, the language added some functional features very interesting to learn.
The project has support for EV3 Sensors and Actuators. The project includes the support for LeJOS local navigation stack.
In this project, the Objects included in the different libraries follow the LeJOS Interfaces, not to be confused with another Java project based on ev3dev unified language binding for Java
https://github.com/ev3go/ev3dev
Go is a compiled, statically-typed language created at Google. It aims to be simple and light while still providing modern language features. While it is a compiled language, it has its own built-in cross-compiler, which means that you don’t need to spend time setting up special tooling like you do with most other compiled languages.
https://github.com/ddemidov/ev3dev-lang-cpp
C++ is a low-level, compiled language which is highly performant while still providing modern language features. It is best for applications which require the fastest execution or interaction with existing C++ libraries.
https://github.com/in4lio/ev3dev-c
C is a low-level, compiled language which is useful for interacting with other C-based code. It is very lightweight and often the most portable across platforms.
https://github.com/maweki/ev3dev-prolog
Prolog is a logic programming language that is often used in the context of AI and planning. Prolog programs allow for a high level of abstraction and a mix of declarative and imperative programming.
https://github.com/ev3dev/ev3devKit
Through GObject-introspection, this library can be used by languages including Vala and Genie, among many others. This is great for people who want to use higher-level syntax while still producing a performant application, or people who want a less error-prone API for C. The Brick Manager for ev3dev is written using this library.
https://github.com/pixix4/ev3dev-lang-rust
Rust is a low-level, compiled language which is highly performant while still providing modern language features. It provides memory safety without using garbage collection and is easy to interact with existing C libraries.
Some of the libraries above also implement interfaces for other languages. If you’re looking for an alternative implementation for any reason, try out the options below.
https://github.com/in4lio/ev3dev-c
ev3dev-c also has wrappers for Python, Ruby and Perl.
https://github.com/ev3dev/ev3devKit
Ev3devKit also has a Python wrapper. You can find demos of using ev3devKit from Python here.
Use them with caution, as some functionality will likely be broken. If you see a library below that you’d like to see in a better state, consider contributing to it to get it updated and ready to use.
https://github.com/wasabifan/ev3dev-lang-js
https://github.com/pgrudzien12/ev3dev-lang-csharp
https://github.com/mob41/ev3dev-lang-java
https://github.com/ev3dev/ev3dev-lang/tree/R-legacy/R
https://github.com/rhempel/ev3dev-lang-lua
https://github.com/noanoa07/ev3dev_ruby
https://github.com/annapawlicka/clj-ev3dev
https://github.com/topikachu/python-ev3
https://github.com/ldmberman/GoEV3