Skip to the content
PCBKitNew board
2 layers25 × 100 mmLightsaber, the printed circuit board in 3D

A lightsaber prop built around an Arduino Nano on a custom PCB. It has a 144-LED blade, sound from a DFPlayer Mini, swing detection with an MPU-6050, a small OLED and two buttons. I built it for a Halloween costume.

Size
25 × 100 mm
Copper layers
2
Thickness
1.6 mm
Parts
15
Nets
45
Pads
79
Tracks, vias
60, 0
Pours
2
Routed
Yes
KiCad
KiCad 8.0 (file 20240108)
Created
25 Oct 2025
Updated
5 Oct 2026

Overview

Lightsaber is an open-source printed circuit board by BamdadKh, from the BamdadKh/ArduinoLightsaber repository on GitHub, published under the MIT licence. It is a 2-layer board of 25 × 100 mm with 15 parts on 45 nets, routed with 60 tracks and 0 vias.

It is built around the DFR0299. Its parts include 8 connectors and 2 ICs. It belongs with the AVR (ATmega, ATtiny) boards of this library.

Main components

1

README

README.md

Arduino Lightsaber

A lightsaber prop built around an Arduino Nano on a custom PCB. It has a 144-LED blade, sound from a DFPlayer Mini, swing detection with an MPU-6050, a small OLED and two buttons. I built it for a Halloween costume.

OLED screens

The OLED screens, rendered by the firmware's own UI code in a PC simulator.

Hardware

MicrocontrollerArduino Nano (ATmega328P)
MotionGY-521 (MPU-6050) on I²C
SoundDFPlayer Mini, external amplifier and speaker
BladeWS2812B strip, 144 LEDs, data on D6
Buttonsmain on D2, aux on D3
Display0.91" SSD1306 128×32 OLED, software I²C on D8 (SDA) and D9 (SCL)
Powerone 18650 cell wired to the Nano's 5V pin, no boost converter

The pin map, bill of materials and the known problems with the V3 board are in docs/hardware.md. The schematic is in hardware/exports. The schematic has mistakes the board inherited; the firmware works around them, so trust the board and docs/hardware.md over the schematic.

The hilt is modelled in Fusion 360 (lightsaber-hilt.f3z), and the printable tube is hilt-tube.stl, which GitHub shows in a 3D viewer.

Hilt assembly

Building

You need arduino-cli with the arduino:avr core. The sketch has no third-party libraries.

bash
arduino-cli compile -b arduino:avr:nano firmware/lightsaber
arduino-cli upload -b arduino:avr:nano -p COM3 firmware/lightsaber

Nano clones with the old bootloader need arduino:avr:nano:cpu=atmega328old. The build uses about 18 KB of the 30 KB of flash and 42% of RAM. Pins, LED count, current limit and the battery and motion thresholds are in config.h.

Building with -DDEBUG_SERIAL=1 prints swing speed and battery voltage over USB at 115200 baud:

bash
arduino-cli compile -b arduino:avr:nano --build-property "compiler.cpp.extra_flags=-DDEBUG_SERIAL=1" firmware/lightsaber

SD card

bash
pip install numpy
python firmware/tools/build_sd_card.py

This fills firmware/sd-card/ and writes sound_lengths.h. Copy the MP3 and ADVERT folders to the root of a FAT32 micro-SD card. Details and the track list are in firmware/sd-card/README.md.

First run

  1. If the screen is upside down, flip it in the menu.
  2. Lay the saber still and run CALIBRATE in the menu. This zeroes the gyro. It also happens at power-up if the saber is lying still.
  3. Compare the BATTERY page with a multimeter on the cell. If it's off, scale BANDGAP_MV in config.h; the Nano's voltage reference is only accurate to about 10%.

Controls

Blade off
MAIN clickIgnite
AUX click, double clickNext colour, previous colour
AUX holdOpen the menu
Blade on
MAIN clickRetract
AUX clickBlaster block
AUX holdLockup, until released
SwingSwing sound (automatic)
Menu
AUX click, double clickNext page, previous page
MAIN clickChange the value or run the action
AUX holdSave and exit

The menu pages are sound, light, colour, sensitivity, flip, calibrate, battery and exit. Light and colour preview on the blade. The saber retracts by itself after five minutes without movement.

How it works

The blade is rendered per pixel into the LED array, which is the only frame buffer in the sketch. The OLED has none either. The panel is mounted on its side and driven in vertical addressing mode, so one physical column is one 32-pixel row of the portrait screen. Each screen is a function that returns a row as a uint32_t, and the UI streams a few rows per loop() pass.

The LED strip needs interrupts off for about 4 ms per frame, which rules out serial receive. The DFPlayer is therefore driven blind. The hum loops on the main channel, effects play as DFPlayer adverts that pause and then resume it, and the one-shot lengths are compiled in so the firmware can stop them when they end.

The cell feeds the Nano's supply directly, so the supply voltage is the cell voltage. The firmware measures it against the internal 1.1 V reference. Charge level and warnings use the voltage with the blade off, because the strip pulls it down by several tenths of a volt when lit.

ModuleJob
saber.cppmodes and controls
imu.cppMPU-6050 reading and swing detection
blade.cppblade colours, ignition and effects
color.cppWS2812B driver, current limit
ui.cpp, gfx.h, oled.cppOLED screens and display driver
audio.cppDFPlayer protocol and sound playback
buttons.cppdebouncing, clicks, holds
power.cppbattery voltage
settings.cppEEPROM settings, colour table

Repository

text
firmware/lightsaber/   the sketch
firmware/sd-card/      sounds for the DFPlayer
firmware/tools/        asset and SD card builders, PC simulator
hardware/kicad/        KiCad 8 project
hardware/fabrication/  gerbers exactly as ordered (V3)
hardware/exports/      schematic PDF, PCB renders
hardware/3d/           hilt model, tube STL, PCB STEP
docs/                  hardware notes, images

The simulator runs the real ui.cpp and blade.cpp on a PC (it needs MSYS2 g++ or MSVC):

bash
python firmware/tools/sim/run_sim.py
python firmware/tools/make_readme_images.py

Blade simulation

Blade timelines from the simulator. Time runs left to right and the hilt is at the bottom.

Credits

The blade sounds come from the TeensySF font in the ProffieOS default SD card, by Fredrik Hubinette (CC BY-SA 4.0). The menu and boot sounds are synthesized by the repository's tools.

License

MIT. The sound files are under their own licence, see above.

Parts

15
QtyValueFootprintReferences
15vGConnector_PinHeader_1.00mm:PinHeader_1x02_P1.00mm_VerticalJ6
1Arduino_Nano_v3.xModule:Arduino_NanoA1
1DFR0299DFR0299:MODULE_DFR0299U2
1GY-521mpu6050:GY-521U1
1batConnector_PinHeader_1.00mm:PinHeader_1x01_P1.00mm_VerticalJ8
1btConnector_PinHeader_1.27mm:PinHeader_1x04_P1.27mm_VerticalJ3
1oledConnector_PinHeader_1.27mm:PinHeader_1x04_P1.27mm_VerticalJ5
1pushConnector_PinHeader_1.00mm:PinHeader_1x02_P1.00mm_VerticalJ2
1push2Connector_PinHeader_1.00mm:PinHeader_1x02_P1.00mm_VerticalJ4
1spkConnector_PinHeader_1.00mm:PinHeader_1x03_P1.00mm_VerticalJ7
1ws1218bConnector_PinHeader_1.00mm:PinHeader_1x03_P1.00mm_VerticalJ1

The 11 most common of 15 parts.

Questions

How big is the Lightsaber PCB?

It measures 25 × 100 mm and has 2 copper layers, 1.6 mm thick.

What parts does the Lightsaber use?

15 parts, built around the DFR0299. The full list of its parts is on this page, with links to each part's symbol and footprint where PCBKit's library has them.

Where can I download the Lightsaber KiCad files?

From the BamdadKh/ArduinoLightsaber repository on GitHub, at the commit this page was made from: the board is hardware/kicad/lightsaber.kicad_pcb and its schematic hardware/kicad/lightsaber.kicad_sch. PCBKit opens the board in the browser, with nothing to install.

Can I use the Lightsaber design in my own project?

Its repository publishes it under the MIT licence: you may reuse it on that licence's terms (keep the author's notice, and for a copyleft licence share your changes alike).

Similar boards

  • 2 layers104.7 × 135.6 mmDiscAdventure, the printed circuit board in 3D

    DiscAdventure

    Trikkitt/polygen

    PolyGen game repository

    61 parts13
  • 2 layers145.4 × 70 mmLab64 vday musicbox, the printed circuit board in 3D

    Lab64 vday musicbox

    angelinakrinos/lab64_vday

    🚀 Enjoy your Valentine's Day Music Box! 🎶❤️

    16 parts4
  • 2 layers48.2 × 28.3 mmLoop, the printed circuit board in 3D

    Loop

    ayaangrover/loop

    a low-cost mp3 player

    11 parts3MIT
  • 2 layers210 × 140 mmGifu creation koubou, the printed circuit board in 3D

    Gifu creation koubou

    kinoshita-lab/gifu-creation-koubou-teaching-material

    109 parts3MIT
  • 2 layers9 × 25 mmModularPowerSupply, the printed circuit board in 3D

    ModularPowerSupply

    Animal-Crate/Animal-Crate

    This is a public repository for the Animal Crate project. Please review the README for more information.

    35 parts2AGPL-3.0
  • 2 layers99.1 × 99.1 mmBs base, the printed circuit board in 3D

    Bs base

    MelexinVN/bs_kombo_bs

    Электронная беспроводная система для проведения интеллектуальных игр на микроконтроллерах stm32 и радиомодулях nrf24l01+.

    30 parts2GPL-3.0
  • 2 layers127 × 83.5 mmAudiostation, the printed circuit board in 3D

    Audiostation

    janikkaden/self-sufficient-audio-station

    A solar-powered, self-sufficient audio station for outdoor exhibitions — ESP32 + DFPlayer, wakes from deep sleep on a button press and plays info tracks in three languages plus music.

    28 parts1GPL-3.0
  • 2 layers91 × 55 mmTiny sound card, the printed circuit board in 3D

    Tiny sound card

    kamiyaowl/tiny_sound_card

    Arduino Pro Mini同等のボードで、mp3を再生したりできるモジュール

    49 parts1MIT