TicTacToe Playing LEGO Mindstorms Robot Using Computer Vision

Posted by on Jul 17, 2017 in Documentation, Featured, LEGO, Project | 14 comments

TicTacToe Playing LEGO Mindstorms Robot Using Computer Vision

You can play TicTacToe with this LEGO Mindstorms EV3 robot. It uses three motors to drop the balls into the right field. It uses a NXTCam to view the board and then calculates the best move using a MiniMax Algorithm. All future moves are explored an rated according to their winning chances. The work is based on the TicTacToe code of Thomas Kaffka. An IR sensor detects your hand when you drop your ball. The robot is using red balls and the human player uses blue balls. The Java code is available over at Github. The building instructions are available for LEGO Digital Designer. I used the MinuteBot baseplate, which is useful for building static Technic/Mindstorms models.


LDD does not have all the required pars in its database. You will have to replace 22961 with 27940. You will also need to add a worm wheel 27938. In addition you should use a lamp to provide consistent lighting. I used a USB powered LED circular lamp the can be powered through the USB port of the EV3. I only had to take out the lens in the middle so that the camera fits through the hole. A rubber band holds the light in place. To calibrate the robot I added a little arm at the end of the base plate against which the robot arm rotates. The position of the camera can be centered on the board using the wrench and through sliding along the axles.

You can also find information about the robot over at Rebrickable. The inventory there is correct and complete. Except for the base plate of course.



  1. Hi there,

    is it possible that you can come out with a parts list? It would be greatly appreciated.


  2. Hi Dev,
    You can download the LDD file from the link in the text. This will give you a parts list. You can also follow the link to Rebrickable, which lists all the parts.

  3. Thanks!

  4. Hi Christoph,

    I am collecting the parts to do this project. I found most of the things. I just wanted to ask whether it is ok to use the Pixy LEGO Camera rather than the NXT Camera you have used.


  5. I have no experience wit the Pixy camera. The camera hardware is probably the lesser issue. Make sure that the software works. The NXT Camera software did all the recognition and simply communicated back the coordinates of the balls. This was very convenient.

  6. Hey! This is a great project! Thank you for sharing it.
    I have one question: which program did you use to transfer the code onto the EV3? Did you use Eclipse?

  7. Which program did you use to transfer the code to the robot? Was it Eclipse?

  8. Did you use the Home edition or the Education school edition?

  9. It does not make a difference. The hardware is identical.

  10. can lego pixie cam be used instead of nxtcam?

  11. I have not tried it myself, but in principle it could work.

  12. What is that red housing looking part under the main marble dropper?

  13. Those are two parts. Have a look at the building instructions to figure out exactly what parts go where: http://www.bartneck.de/projects/design/lego/ticTacToe/ticTacToe.lxf

Leave a Reply

Your email address will not be published. Required fields are marked *