The X-Wing MS5 Robot

In celebration of 2023’s May the 4th, I have created an X-Wing Starfighter using the MINDSTORMS 51515 set, or X-Wing MS5 in short. Not only is this one of the most iconic Star Wars ships, but it also aligns nicely with this year’s release of the X-Wing UCS set. The robot was built using the MINDSTORMS Robot Inventor set 51515 and programmed using Python.

Please note that this isn’t an original concept. The first version concept that I saw of it was that by LEGORobotics Mr. Hino using the EV3 kit. In this case, Mr. Hino used a motor as a joystick to control the angle. However, I haven’t seen an implementation using the Robot Inventor (51515) set or using an accelerometer to control the ship.



I generated the instructions using Bricklink Studio. You can find them here:

The instructions also include a bill of materials, in case you decide to build the AT-AT MS5 yourself. You can also find the inventory on its corresponding Rebrickable page.


The robot functionality is quite simple. The ship will angle along the z-axis depending on the hub’s orientation (using information from the accelerometer). It also allows switching between cruise and attack mode. While in the latter, the X-Wing can fire its laser cannons.

For a complete, detailed description of how this approach works, I strongly recommend checking the X-Wing MS5’s Jupyter notebook (if nbviewer is giving you trouble, you can also check the notebook directly in GitHub). If you just want to get the robot up and running, you can find the script here. To use it, just copy and paste the content of the script in a new MINDSTORMS Python project and you will be good to go.


The best part: seeing the whole thing in action!

(I’m still editing a video showcasing the functionality. On the meantime, I think that these GIFs should give you a good idea of how the robot works.)

If you build this model, please share some pictures! I’d love to add them here.


A bit of backstory. Originally, I wanted to just create the core mechanism and append the S-foil and cockpit of 75301’s Luke Skywalker’s X-Wing Fighter. However, this resulted in the X-Wing being too heavy, making it very hard for the motors to work. As a small bonus, here is a render of how that looks like.

If you have any questions, comments, or feedback, please open a discussion. If there is a problem with the code (e.g., mistake), please open an issue. Moreover, you can always drop me a line on Twitter (@amoncadatorres). Lastly, if you found this useful, fun, or just want to show your appreciation, you can always buy me a cookie. Cheers!