Lego WeDo 4 Java

Just for the sake of indexation and for the only purpose of sharing almost a week of reverse engineering, I’m writing this post about a small project which allows you to interact with Lego WEDO Kits Motors and Sensors using Java. When I’ve started with the Rolo The Robot project, I’ve first look into the Lego WeDo kits, because they looked simple and modular. After finding out their limitations, I’ve decided to at least write a small lib in java to interact with those motors and sensors. Based on Ian Daniher’s WeDoMore project for Python, I’ve did a similar version in Java. The Java version allows you to read the sensors and interact with the motors at the same time, which I believe that it was a limitation from the Python version of the library.

This lib is in a very initial but usable version, and I don’t see too many reasons to continue improving it, but I know that it can be very helpful for people which is looking forward to create simple applications for educational purposes. In order to use it you will need to have the following items:

As you can see it is not a cheap thing to buy, but if you have a couple of those, you can build a small robot with two motors and two sensors, which for kids this could be very handy.

I’ve provided support for Distance and Tilt sensor as well as for the Medium Motor.

Medium Lego Motor:

Motion/Distance Sensor:

Tilt Sensor:

Feel free to fork the project  and drop me a line if you are interested in using the project, I can quickly extend it for your particular needs if its necessary. All the source code is under the Apache License V2, so there is no restriction to use it or distribute it. You can find all the source code here:

4 thoughts on “Lego WeDo 4 Java”

  1. Hey Salaboy,

    i did nearly the same in August ’12. With the codeminders hid api I wrote a mod to control the Lego Wedo in Minecraft.
    While I sniffed the usb traffic, I saw that you I can use the motors as a rotation sensor, in both directions. Maybe that’s interesting for you?
    Last week I adapted my work to the arduino leonardo, which can work as a hid device.

    I’m curious: Who is rolo the robot?



    1. Hi infchem,
      First of all thanks a lot for your comment, I’m really happy to see that people is using Lego WeDo to do cool stuff.
      What you mention about using the motors as rotation sensors is more than interesting. Can you collaborate with the code for doing that? All my code is Open Source and is hosted on github. If you have some links to your work I will take a look on that.

      You can read more about Rolo The Robot in my other post:

      Rolo is a Drools controlled robot, right now is working on battery and uses a Raspberry Pi and an Arduino Uno



  2. Hello Salaboy.

    Your work is incredible. I am new to the world of Java. I am sorry, but I do not understand enough. I work with Windows 7 and do not know how you should configure the source code to run on Windows. If is possible I would like you could help me.
    Thanks in advance.


    1. Hi Luis,
      Well you need to get your environment set up with Java, Maven and git to clone the project. This was a very technical project, intended for developers so you need to get used to the tools.
      Let me know if you have more doubts.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.