–
IoT LEGO Millennium Falcon
a Raspberry Pi and JavaScript inside a LEGO Falcon, controlled from a phone
- hardware,
- IoT

I turned an ordinary LEGO Millennium Falcon into a remote-controlled ship that lights up and makes noise – using front-end technology. There’s a Raspberry Pi Zero W inside, and JavaScript runs everything, from the GPIO pins to the app on my phone. It was never meant to be perfect; it was for fun, and a guilt-free way to try technologies that were new to me.
How it works
The hyperdrive is a blue LED strip on a 12 V battery. The Raspberry Pi only puts out 5 V, so the strip is switched through a transistor – a friend doing a PhD at the Military University of Technology helped me work out the circuit. White LEDs light the cockpit, with Chewbacca and Han Solo inside, and the front of the ship. I drive the pins from Node.js with the onoff package. After three days of fighting with Bluetooth audio I gave up; the sound finally comes out of an HDMI-to-VGA adapter with a headphone jack, left over from my lecturing days.
Code goes on board through balena.io: a plain git push builds a container and updates the Falcon on its own. The ship talks to the outside world over Syncano WebSockets – calling an endpoint sends a message, and a script on the Pi switches the right lights on. The hyperdrive turns itself off after 10 seconds so it doesn’t drain the battery. The remote is a simple PWA: a Falcon blueprint in the background with invisible buttons on top, no frameworks, installed to the phone’s home screen.

Finally I added a GitHub App with a webhook: every new star on my account fires up the hyperdrive and plays an R2-D2 sound.
History
The first version only worked locally – a simple HTTP server with a PHP backend. In my “Lego ❤️ Syncano” slides from April 2018 it had already moved to Syncano and Node.js. I published the full build story, “Z JavaScriptem w nadprzestrzeń!” (Into hyperspace with JavaScript!), on devstyle.pl in May 2019, together with the code on GitHub.

Sources
- Z JavaScriptem w nadprzestrzeń!, devstyle.pl, 23 May 2019 (in Polish)
- millenniumfalcon.js, GitHub
- Lego ❤️ Syncano, slides, April 2018
- JavaScript powered Lego Millennium Falcon, YouTube
- JavaScript Millennium Falcon – GitHub notifications, YouTube