DIY Neopixel Lightsaber Blade

by hotcup_97 in Circuits > LEDs

730 Views, 11 Favorites, 0 Comments

DIY Neopixel Lightsaber Blade

394852273_711959974166384_3588741831733023286_n.jpg
394507415_733830425223734_5457776725666326815_n.jpg
387512532_1493879121372435_5658243588880942030_n.jpg

I designed this lightsaber in Blender, and I sell the files on my Etsy. I got requests from a number of Instagram followers for a tutorial on how to make the lightsaber blade for a Lightsaber lamp. This Instructable will discuss the building of the blade itself.

Supplies

Remove Cap and Drill Hole Through the Tip

Unfortunately, I didn't think of taking good photos as I was making this... Thankfully, it is a fairly straightforward process. Pull off the white cap on the base of the lightsaber blade. This will give you access to the inside of the tube. You should see a reflective material lining the inside walls.

Take your drill and 5/8" drill bit, and drill a hole straight through the center of the blade's tip. The 5/8" bit leaves a hole just wide enough for the LED strip to pass through.

At this point, you should have holes on both ends of the saber blade.



Insert the LED Strip Into the Blade

Fold the 3.2' LED strip in half and insert it into the blade from the tip down (we want the Pi to be on the tip side of the blade). Print the DiffuserTube.stl that is included here. This tube is the full 15" tall. Depending on your printer, you may need to cut this in half and print the cuts twice. This tube diffuses the light of each individual LED pixel and makes it look more uniform. This gives a much more realistic effect that looks insane (especially on camera!)

A short mp4 video is included to show what the end result looks like. I apologize for the not-great quality of it. I didn't think to document my steps with good photos along the way.

Wire Up the Hardware

Saber.png

Take notice of the arrows on the WS2812 LED strip. Be sure to wire the leading end to your pi! Wire up your hardware exactly as pictured. The Pi Pico's GPIO1 pin is used as an output to command the LED color, and GPIO 17 and 18 are used as inputs to toggle between 4 desired color combinations. Conveniently enough, the Pi pico can adequately power the whole led strip solely from its VBUS (+5V) port.

Program the Pico

Plug in your USB-A to USB-micro data cable into your Pico and your computer. Open Arduino IDE and configure it for a Pi Pico on its auto-assigned COM port. Program your Pi Pico with the included Neopixel_Lightsaber.ino file. You will see 4 different color combinations that can be selected via the push button switches (red, green, blue, green crackle). These can be easily modified if you'd like a different color. The code is included here as well as the file itself below.

// This was written and compiled in Arduino IDE 2.2.1 for a Raspberry Pi Pico
// You will need to install the Adafruit_NeoPixel library
// Swaps among 4 different color options via 2 on/off switches.


#include <Adafruit_NeoPixel.h>


#define PIN_NEO_PIXEL 1  // Arduino pin that connects to NeoPixel
#define NUM_PIXELS 144    // The number of LEDs (pixels) on NeoPixel
#define PIN_SW1 16
#define PIN_SW2 17
#define CRACKLE_DELAY 50  // 50ms crackle flash


// 2 Switches were insterted to switch between 4 color options
int SW1 = 0;
int SW2 = 0;


Adafruit_NeoPixel NeoPixel(NUM_PIXELS, PIN_NEO_PIXEL, NEO_GRB + NEO_KHZ800);


void setup() {
  NeoPixel.begin();  // INITIALIZE NeoPixel strip object (REQUIRED)
  pinMode(PIN_SW1, INPUT_PULLUP);  
  pinMode(PIN_SW2, INPUT_PULLUP);  
}


void loop() {
  NeoPixel.clear();  // set all pixel colors to 'off'. It only takes effect if pixels.show() is called
  int SW1 = digitalRead(PIN_SW1);
  int SW2 = digitalRead(PIN_SW2);


//GREEN
  if (SW1 == 0 && SW2 == 0){
    for (int pixel = 0; pixel < NUM_PIXELS; pixel++) {           // for each pixel
      NeoPixel.setPixelColor(pixel, NeoPixel.Color(0, 255, 0));  // it only takes effect if pixels.show() is called   }
    NeoPixel.show();  // send the updated pixel colors to the NeoPixel hardware.
  }

//RED
  else if (SW1 == 1 && SW2 == 0){
    for (int pixel = 0; pixel < NUM_PIXELS; pixel++) {           // for each pixel
      NeoPixel.setPixelColor(pixel, NeoPixel.Color(255, 0, 0));  // it only takes effect if pixels.show() is called      
    }
    NeoPixel.show();  
  }

//BLUE
  else if (SW1 == 0 && SW2 == 1){
    for (int pixel = 0; pixel < NUM_PIXELS; pixel++) {          
      NeoPixel.setPixelColor(pixel, NeoPixel.Color(0, 0, 255));        
    }
    NeoPixel.show();
  }

//GREEN CRACKLE - Generates a randomized white flash
  else if (SW1 == 1 && SW2 == 1){
    for (int pixel = 0; pixel < NUM_PIXELS; pixel++) {          
      NeoPixel.setPixelColor(pixel, NeoPixel.Color(0, 255, 0));        
    }
    int crack = random(3,140);
    NeoPixel.setPixelColor(crack, NeoPixel.Color(255,255,255));
    NeoPixel.setPixelColor(crack + 1, NeoPixel.Color(255,255,255));
    NeoPixel.show();  
    delay(CRACKLE_DELAY);
    NeoPixel.setPixelColor(crack, NeoPixel.Color(0, 255, 0));
    NeoPixel.setPixelColor(crack + 1, NeoPixel.Color(0, 255, 0));
    NeoPixel.show();
    delay(random(500,5000));
  }
}

Package It All Up!

At this point, your blade is ready to be assembled. Insert the tip of your blade into the base and the butt of your blade into the 3D printed lightsaber emitter. There should be some LEDs sticking out that go up inside the emitter. These are what gives the Kyber crystal its glow.

Hide the electronic components inside the 3D printed base (All 3D printed files are included with the purchase of the Etsy link above).

It doesn't have to look pretty because no one will ever see it. I used hot glue to secure my Pi pico and switches inside the base and that works great. Plug in your Pi Pico to a power source to confirm functionality. If done properly, you should be able to cycle among your decided colors.

Figure Out How You Want Power

You have a couple options that you could potentially use for power. I dedicated my USB cable to this project to power everything via USB. I drilled a hole in the side of the base just big enough for the USB cable to pass through. I ran it through that and hot glued the USB cable in for a permanent connection.

You could potentially also use a rechargeable battery to power your Pi Pico as well. If you do decide to go this route, please take great care that you understand what you're working with. External battery packs such as LiPo or LiFe batteries can be extremely dangerous if used improperly and can be a great fire hazard.


In the end, you want a 5V power supply. USB is perfect for this and relatively safe, so I'd suggest going the USB cable power route, but other options do exist. Power supply options are to be chosen with experience level and desired usage in mind.

ENJOY!

That is it! Enjoy your incredibly realistic lightsaber blade!