Got Pike?
Open-source lightsaber software

What you will need:

Download version 1.291 here

ChangeLog (since 1.286)
  • SD card can now be accessed from PC if you select "Serial + Mass Storage" in Arduino->Tools->USB Type
  • Fixed bug with multiple sub-blades using clash
  • Clash and blast effects can now be used interchangeably, and can also be triggered on force effects.
  • Swing sound should not continue if you turn the saber off while swinging anymore.
  • Minor math optimizations.


  • 100% open-source, you may add any feature you like. (GPLv3)
  • Support for remote control via bluetooth (with external addon)
  • Speedy 32-bit processor makes advanced features like sound filters, synthesizing and mp3 playback possible.
  • 16-bit digital output (12-bit for TeensySaber V1 and V2)
  • Default sample rate is 44kHz
  • 22kHz and 11kHz samples are supported and upsampled to 44kHz automatically.
  • Gapless playback, with 2.5ms cross-fade when you interrupt one sample to go to another.
  • Polyphonic playback, currently configured for up to 5 simultaneous samples.
  • Support for PL9823 or neopixel strings.
  • Support for arbitrary 1/2/3/4/5/6-color stars/strings.
  • Supports segmented string blades. (with flash string)
  • Multi-blade support for dual and crossguard setups.
  • Crystal chamber support.
  • Power-level indicator with neopixel blade.
  • OLED PLI display
  • MTP support (drag-n-drop files from windows through USB connection)
  • POV (persistance of vision) mode.
  • Multiple blades. (at the same time)
  • Accent LEDs. (also implemented as additional "blades".)
  • Spoken error messages.
  • Easy software updates.

If you want any other features, contact me on The Rebel Armory or the fx-sabers forum and I'll see what I can do.

Preparations for Proffieboard

  1. Install latest arduino software.
  2. Install the Proffieboard Arduino Plugin
  3. Select Tools->Boards->Proffieboard-STM32L433
  4. Select Tools->DOSFS->SD(SPI)

Preparations for TeensySaber

  1. Install latest arduino software.
  2. Install latest teensyduino software (in same directory)
  3. Go to the Tools menu, select Board: Teensy 3.1/3.2
  4. (optional) Also in the Tools menu, select: USB Type: "MTP Disk (Experimental)"

Note that it's totally ok to install support for both Proffieboard and TeensySabers.

Installing ProffieOS on your board

  1. Download and unzip the teensysaber software from above.
  2. Open up the arduino software, go to file->open and select lightsaber.ino (Note, that on Windows, lightsaber.ino might just be called "lightsaber", as windows will hide the ".ino" part by default.)
  3. Make a config file. Usually, this will be tweaked and re-uploaded many times, but the best way to get started is to go to the V4 or V3 page and use the configuration generator. Go to the config/ directory, make a copy of one of the .h files, then rename the copy to "mysaber_config.h" (or whatever you like), then open up the file in an editor (like notepad) and remove all the lines, then cut-n-paste the stuff from the config generator instead and save it.
  4. In lightsaber.ino, go to line ~24, and change it to: #define CONFIG_FILE "config/mysaber_config.h" (make sure the other config files are commented out, there should only be one CONFIG_FILE without //)
  5. Hook up the board to your computer with an USB cable
  6. If you have a teensysaber, Power the board with a battery. (You did cut the VIN/VUSB, right?)
  7. Press the arrow button near the top left in the arduino interface, and it will compile and upload the program.
  8. Done, now tweak your config file and re-upload as many times as you like.
If you have a problem, you can contact me on The Rebel Armory or the fx-sabers forum, but there is also lots of online informtation about arduinos and teensys, so some googling probably won't hurt.

How to use it
See the Wiki page.

While you can obviously change *anything* in the source, the parts you may need to change depending on how you wired your electronics should all be in the config file. Here is some explanation for what you may need to do:

The blades[] array
One of the first things you'll need to configure is the blades[] array. If your build only has one blade, you should remove all entries but one. If you have a blade connector, and use a resistor in the blade to identify each blade, you'll need to update the blades[] array to match the blades you have. Each entry, in the blades[] array looks something like this:

  {   2600, WS2811BladePtr<97, WS2811_580kHz>(), CONFIGARRAY(presets) },
The first value is the value of the resistor used to identify the blade, in homes. (2.7kOhm in this case) The second value is a pointer to the blade driver. In this case, it is a neopixel blade with 97 LEDs. The third entry is a list of presets, which will be used with this blade.

Currently there are four different blade drivers:

  • WS2811BladePtr - for WS2811/neopixel style blades
  • FASTLEDBladePtr - for APA102/dotstar style blades
  • SimpleBladePtr - for RGB/RGBW stars and strings (strings with no segments)
  • StringBladePtr - for segmented string blades.
Each driver needs some arguments that specifies how they behave, but drivers do not have any influence over when the LEDs should be on, and what color to use. That is handled by a blade style, which is part of the list of presets.

The presets[] array
Like the blades[] array, the preset array(s) have three entries per line. You can have as many preset arrays as you like, but it doesn't make much sense to have more than one per blade.

  { "font01", "tracks/title.wav", StyleNormalPtr<CYAN, WHITE, 300, 800>() },
In this case, the first entry is a directory containing a sound font. (More about that below.) The second entry is a sound track that can be played in the background, and the third entry is a BladeStyle pointer, which specifies what the blade will actually look like.

There is a bunch of different ways to setup blade styles, including write new ones. Here are a list of already implemented ones:

  • StyleNormalPtr<COLOR, FLASH_COLOR, OUT_MILLIS, IN_MILLIS> - Normal solid-color lightsaber blade.
  • StyleFirePtr<COLOR1, COLOR2> - Fire-style lightsaber blade.
  • StyleRainBowPtr<OUT_MILLIS, IN_MILLIS> - Rainbow blade
  • StyleStrobePtr<FLASH_COLOR, CLASH_COLOR, OUT_MILLIS, IN_MILLIS> - stroboscope style blade
  • &style_pov - POV writer (shows the STAR WARS logo if you have a WS2811 or FASTLED blade.)
  • &style_charging - battery level monitor
There is also a template-based system which can build up a bladestyle from a bunch of simpler effects. For instance, StyleNormalPtr is actually implemented as:
StylePtr<InOutHelper<SimpleClash<COLOR, CLASH_COLOR>, OUT_MILLIS, IN_MILLIS>()
Here is a list of individual components that can be used to build a blade style:
  • Rgb<R, G, B> - Solid 8-bit color. (Rgb<255,255,255> is white)
  • Rgb16<R, G, B> - Solid 16-bit color. (Rgb<65536,65536,65536> is white)
  • Gradient<BASE_COLOR, TIP_COLOR> - smooth fade from base to tip
  • Rainbow - scrolling RGB rainbow
  • Pulsing<COLOR1, COLOR2, pulse_millis> - smoothly translate between COLOR1 and COLOR2 every pulse_millis.
  • RandomFlicker<COLOR1, COLOR2> - Randomly mixes between COLOR1 and COLOR2, mix is even over entire blade.
  • RandomPerLEDFlicker<COLOR1, COLOR2> - Randomly mixes between COLOR1 and COLOR2, mix is different for each LED.
  • AudioFlicker<COLOR1, COLOR2> - Like RandomFlicker, but chooses based on audio, quiet audio means more COLOR1, loud audio means more COLOR2. The choice is made based on a single sample to make it flickery.
  • OnSpark<COLOR, SPARK_COLOR, MILLIS< - Normally defaults to "COLOR", but right as you turn on the saber, it uses SPARK_COLOR, then fads back to COLOR.
  • SimpleClash<COLOR, CLASH_COLOR, CLASH_MILLIS< - Normally defaults to "COLOR", but when when you whack the saber, it will use CLASH_COLOR for CLASH_MILLIS millseconds.
  • Lockup<COLOR, LOCKUP_COLOR> - Normally uses "COLOR", but during lockup, use "LOCKUP_COLOR" instead.
  • Strobe<COLOR, STROBE_COLOR, FREQUENCY, STROBE_MILLIS< - Similar to SimpleClash, but flickers at a fixed frequency.
  • InOutHelper<COLOR, OUT_MILLIS, IN_MILLIS> - Makes part of the blade black to make in/out/on/off work the way you expect.
  • InOutSparkTip<COLOR, OUT_MILLIS, IN_MILLIS, SPARK_COLOR> - Similar to InOutHelper, but as the blade is extended, the part closest to the tip will be SPARK_COLOR. (usually white)
  • StylePtr<COLOR> - Converts one of the templates from above to a BladeStylePtr so you can use it in a preset array.
Now here's the really cool part: Anywhere where you can specify a color above, you can also specify a component, making a LOT of combinations possible. To experiment with this properly, try the Style Editor.

LED configuration
The teensysaber already contains definitions for some popular Cree LEDs, so most of the time, all you need to do is to use the right template and specify the right number of milliohms in the < > after the template. If you use a led that doesn't exist in leds.h different LED, copy one of the led structs into your config file ane modify it.

struct MyRedLED {
  static constexpr float MaxAmps = 1.0;
  static constexpr float MaxVolts = 3.15;
  static constexpr float P2Amps = 0.7;
  static constexpr float P2Volts = 3.05;
  static constexpr float R = 0.55;

  // LED color
  static const int Red = 255;
  static const int Green = 0;
  static const int Blue = 0;
MaxAmps & MaxVolts is the amps and volts when the LED is fully on. It's best to get these values from the data sheet if possible. If not, you'll have to guess the MaxAmps, and measure at what voltage you get that. The P2Amps and P2Volts are similar, but at some other point, for instance when the LED is half-on. If the data sheet doesn't provide this, it is fine to just measure it. R is the value of the resistor you used, zero if there is no resistor.

LED Color configuration
Most of the time, TeensySaber simply uses RGB colors to run everything, however, if you're using an LED star, things can get a bit more complicated. For instance if you have a Blue-Blue-White LED star, you have two choices for how to configure the driver class. The first choice is something like: SimpleBladePtr<CreeXPE2Blue, CreeXPE2Blue, CreeXPE2White, NoLED>(). This means that when the Style classes tells the blade to be blue, the channel one and two turns on, and when the style class say to make it white, all three channels turn on. This is usually what you want to make the blade flash on impact. With this setup, the style setup becomes simple as well, you just do something like: StyleNormalPtr<BLUE, WHITE, 300, 800>(). However, there is one drawback; if you want to actually use the white LED by itself, there no way to do it. The only way to activate the white LED is for the Style to specify a white color, and that will also activate the blue LEDs.

Sound Fonts
Once you have the firmware installed, you'll need at least one sound font. Sound fonts are stored on the SD card, just create a subdirectory and put the files from the font in there, and it should work. Most fonts are monophonic, meaning that only one sound is played at a time, but some are polyphonic, meaning that sound effects are played over the basic humm sound of the saber. The teensy saber os supports both types and should be able to figure out what kind it is based on the file names. Here are a few places where you can obtain sound fonts:

Button configuration
By default, TeensySaber is configured to use a touch button for power, while the other buttons use regular momentary switches. There is currently no support for latching switches. If you want to use a momentary switch for the power button, you'll need to change two things.

  1. Find the line that says TouchButton power_; and replace it with Button power_;.
  2. Find the line that says power_(powerButtonPin, 1700, "pow"); and replace it with power_(powerButtonPin, "pow");. (The 1700 is the sensetivity of the touch button, at some point I might calculate the sensetivity automatically, and then this step won't be required anymore.)
Note that you can do the opposite of these two steps to the other buttons if you want to make them into touch buttons.

Sound Effect File Names
A sound font is made up of many sound files, the filename of these files should look something like this:

The file name is made up of four parts:
  1. The directory - This can be anything you like. All the files belonging to the same font should be in the same directory though. You can put fonts in sub-directories if you like, so it could be something like: fonts/dark/1/hum.wav if you like. The first entry in the preset[] array specifies the directory.
  2. The name - One of a set of pre-defined names specified below.
  3. The number - When playing a sound, TeensySaber will generally pick one of them randomly. The numbers can either be on the form 1,2,3,4,5,6,7,8,9,10,11, etc. or 01, 02, 03, etc. or 001, 002, 003, etc. The number sequence must be consistent and without any gaps. It's also possible to omit the number completely. For looping sounds, TeensySaber will randomly pick one of the numbered files each time it starts over, so it's possible to create a more interesting hum by having "hum.wav", "hum1.waw", "hum2.wav" etc. Note that since we're using an ancient file system, the length of the name and number must not total more than 8 characters. (So you can only have 11 poweron sounds: poweron.wav, poweron0.wav, poweron1.wav....poweron9.wav)
  4. The extension - I recommend using .wav files, 11, 22 and 44khz mono/stero wav files are supported. .raw and .usl files are also supported, but must be 44khz mono.

Sound Effect Names
The name part of the filename needs to be one that TeensySaber can recognize. Sound fonts can either be monophonic (Plecter) or polyphonic (Naigon Electronics) style. In monophonic mode, the following names are recognized:

  • boot - Played when TeensySaber boots up.
  • swing - Played when you move the saber around.
  • hum - Played when you don't move the saber around. (looped)
  • poweron - Played when you turn the saber on.
  • poweroff / pwroff - Played when you turn the saber off.
  • clash - Played when you hit something with the saber.
  • force - Force use sound.
  • stab - Played when you make a stabbing motion. (Not yet implemented)
  • blaster - Played when you press the AUX button.
  • lockup - Lockup, activate by hoding power then trigger a clash.
  • poweronf - Force power on (not yet implemented)
  • font - Played when you switch to this font / preset.
Note that in monophinic mode, the end of all sounds (except poweroff) smoothly join up with the beginning of the "hum" sound(s).

In polyphonic mode, the following names are recognized:

  • boot - Played when TeensySaber boots up.
  • swng - Played when you move the saber around.
  • hum - Played when you don't move the saber around. (looped)
  • out - Played when you turn the saber on.
  • in - Played when you turn the saber off.
  • clsh - Played when you hit something with the saber.
  • force - Force use sound.
  • stab - Played when you make a stabbing motion. (Not yet implemented)
  • blst - Played when you press the AUX button.
  • lock - Lockup, activate by hoding power then trigger a clash.
  • font - Played when you switch to this font / preset.
TeensySaber will automatically decide if a directory contains a monophonic or polyphonic font based on the filenames.

In addition, if the sounds "swingl" and "swingh" are present, the SmoothSwing algorithm will be used to generate swing sounds from these files instead of using "swing" or "swng" files. See below for more details on SmoothSwing algorithms.

Also, if the "drag" sounds are present, they will replace the "lock" / "lockup" sound if you drag the saber tip across the ground.

SmoothSwing V1/V2 configuration
When one or more set of swingl/swingh files are present, TeensySaber will activate the SmoothSwing V1 or V2 algorithms. To decide which one to use, it will read a file called "smoothsw.ini", which can contain the following variables: (listed with their default values)

# SmoothSwing algorithm version, should be 1 or 2.
# Swing sensetivity, degrees of rotations per second required to reach full volume.
# How many percent the hum sound will decrease as swing increases.
# Non-linear swing response, higher values makes it more non-linear.
# Degrees / second needed to register as a swing.
# Length of first transition in degrees.
# Length of second transition in degrees.
# Swing volume multiplier defaults to 3x normal volume.

SmoothSwing V1 - Demo, Thexter's description
Demo, Algorithm explanation, details of how to use it below. Many thanks to Thexter for his excellent work on this algorithm. Smoothswing V1 doesn't actually use any of the variables from the configuration file. The swingl and swingh files are played in a loop. The software will then place a rotating plane through the blade of your saber, and if the saber swings in one direction across the plane, we'll play more of swingl and less of the background hum. If we swing in the other direction, we'll play more of swingh and less of the hum. The fade will never blend swingl and swingh directly, it will essentially cross-fade between the regular hum and one of swingl/swingh based on direction and strength of the swing.

SmoothSwing V2 - Demo, Thexter's description
Smoothswing V2 has some similarties to V1, but is much better at producing natural swing- and spin-like sounds, and also produces more variety than the V1 algorithm. To do this, the swinglNN.wav and swinghNN.wav files are paired up. Whenever a swing is not going on (swing speed < SwingStrengthThreshold) a new pair if selected randomly. As we start swinging, we keep track of how many degrees the saber has swung so far, and at a randomly selected threshold, we start a cross-fade to go from swingl to swingh. The transition lasts for Transition1Degrees, and if the swing continues, we will eventually cross-fade back from swingh to swingl 180 degrees after the first threshold. The second transition is generally wider and is controlled by Transition2Degrees. The combined swing sound is then cross-faded with the regular hum based on the swing strength.

Serial Monitor Commands
You can use the serial monitor to debug and control the software once uploaded, here is an incomplete list of commands:

  • help - prints a list of known commands
  • on - turns the saber on
  • off - turns the saber off
  • blade on - turns the blade on (but leaves the sound off)
  • blade off - turns the blade off
  • clash - trigger a clash effect
  • dir [directory] - list files on sd card
  • cd [directory] - change directory, and sound font
  • play [file] - play wav file
Note that there is a drop-down at the bottom of the serial monitor that defaults to "No Line Feed", you must change it to "Newline" to use the serial monitor with TeensySaber.

Download Older versions

  • 1.8 - pre-alpha version
  • 1.10 - alpha version
  • 1.11 - beta version
  • 1.14 - first recommended version
  • 1.18 - preliminary teensy 3.5/3.6 and TeensySaber V2 support
  • 1.19 - Fixed BUILTIN_SDCARD
  • 1.20 - Fixed hang when reading directories ending in /
  • 1.40 - new LED configuration system, PWM over volt protection, audio bugfixes, improved audio buffering, better help system, multiple touch buttons, code cleanup
  • 1.43 - looped swing sound support
  • 1.45 - MTP, power+clash=previous preset, RAW/USL support
  • 1.60 - POV, V2 motion, APA102/Dotstar (Experimental)
  • 1.86 - multi-blade support
  • 1.89 - blade template system
  • 1.93 - fixed short activation
  • 1.110 - louder, lockup, flicker
  • 1.119 - bugfixes
  • 1.144 - GPLv3, speech, separate configuration files, zero-button sabers, mtp support for serialflash
  • 1.153 - Display/PLI, crossguard
  • 1.157 - TeensySaber V3 support, latching button support
  • 1.164 - blast effect, pulsing blade, drag effect, 16-bit color
  • 1.167 - Support for bluetooth addon.
  • 1.175 - SubBlade, IgnitionDelay, ColorCycle, Makefile, more blades
  • 1.191 - Smoothswing V2, better wav reader, Cylon, reduces clash sensetivity when swinging
  • 1.224 - loop optimizations, split into many files, blade style functions, bugfixes
  • 1.246 - split out more classes, better spoken error messages, serialflash config files
  • 1.247 - bugfixes, INVERT_ORIENTATION
  • 1.264 - initial proffieboard support, StyleFire<>, any orientation, motion disable, WS2811 fixes
  • 1.264 - fixed proffieboard support, bugfixes
  • 1.269 - force command, neopixel fix for profffieboard
  • 1.284 - N-gradient, new Blast, LocalizedClash, Sparkle, BlastFadeout, InOutHelperX, OriginalBlast, separate color for drag, double-click to mute, bugfixes
  • 1.286 - Blinking style, faster motion code, lots of bugfixes

If you're having problems, check out the troubleshooting page.

Problems? Questions? Suggestions? Check out the The Rebel Armory or fx-sabers online forum.
This page has been accessed 6,780 times since July 29th, 2018.
Last modified: December 13th, 2018 - Design by Monica & Fredrik Hübinette