Summer ’22 Projects – Part 1

Well, today is the official last day of summer for me, as next week faculty return to school to prepare for the semester which starts the following week. The summer went by too quickly, but I was nonetheless able to get a few projects completed. Here’s one of them.

Use the Force – BoB

A couple years back, I started building my own lightsaber according to Adafruit’s instructions. As with many Ruiz Brothers builds, I found it fun yet a bit frustrating, as there always seems to be some part of the build that isn’t quite beta-tested. Of course, as makers, we should be able to handle such challenges, so maybe Ruiz intentionally includes small goofs in his designs – perhaps.

Anyway, here’s a video summarizing the build, including my modifications to the original design.

Watch, Like and Subscribe! (Please)

I had seen some criticism of the build based upon the big gaping hole that is left for the microcontroller. Presumably, Ruiz included this hole to showcase the Propmaker board, which this project advertises.

What the lightsaber is supposed to look like (photo curtesy of Adafruit)

I decided to take advantage of this feature to mod my lightsaber. As designed, if you want to change the color of the blade, you have to adjust the CircuitPython code. I wanted a user (uh, wielder) to be able to change from the Light side to the Dark side with a flip of a switch, so I added a protoboard consisting of a DIP switch and a resistor ladder to provide this functionality.

My lightsaber mod

I also wanted to do something really different, which is why you’ll notice a wireless transmitter above the DIP switch in that photo. The plan was to grab accelerometer data from the Propmaker and send it to my computer. That information would be used by a simple game to control a virtual lightsaber. Simple, hunh?

Turns out, not so much. These transmitter/receiver (XD-FST/ XD-RF-5V) pairs are cheap and ubiquitous (both on line and in my shack). The problem, though, is that CircuitPython doesn’t have drivers for the hardware, which meant I needed to design something on my own. Since the device transmits data using Amplitude Shift Keying (ASK), it is not impossible to come up with a homebrew solution in short order. Briefly, I change the frequency of a digital output pin in PWM mode to differentiate between a binary 1 and 0. Then, I create a packet of data containing the accelerometer data along with the color setting of the blade. It’s not a terribly robust solution, but works surprisingly well given its simplicity.

ASK signal transmitted from the lightsaber.

On the receive end, I have a spare (and ancient) ATMega32U4 board with no good home so I wired up the receiver and created some complimentary code to copy and translate the packet. The ATMega32U4 then makes that data available via a serial port connection.

ATMega32U4 used to receive the lightsaber data.

Things start to get a bit crazy now. During the pandemic, I started learning how to use the Unreal Engine to make games, including building in remote access functionality to interact with microcontrollers. In this project, I used a wonderful plugin from Ramiro Montes De Oca that allows an Unreal Engine game to interface with a serial device. So I started up a new project, imported the very same STLs used to 3D print the lightsaber into the game and programmed the orientation of the virtual lightsaber to mimic that of the one held in my hand.

Lightsaber (in Windu mode) transmitting data to Unreal Engine game to orient a virtual copy.

You’ll notice in the video above that there are some glitches – the signal strength is poor, so the correct orientation and power settings are not always read properly. That said, it works in principle, which is what I was going for. If I wanted to make a more robust light saber HID, I’d use a better communication platform. Still, for a project with many moving pieces (3D printing, electronics, Python/Arduino/UE5 programming) I’m pleasantly surprised that I was able to get prototype-level functionality out of the light saber.

Leave a Reply

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

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