Arduino Based Lightsaber With Light and Sound Effects

46,884

497

139

Posted

Introduction: Arduino Based Lightsaber With Light and Sound Effects

Arduino Contest 2017

Runner Up in the
Arduino Contest 2017

Hello jedi! This instructable is about making a lightsaber, that looks, sounds and performs like one in the movie! The only difference - it can't cut metal :(

This device is based on Arduino platform, and I give it a lot of features and functions, it was a very big job and I used all of my programming skills, but it was worth it!

So, let's talk about features! Also you can watch a short review in my video, in which I show all effects and functions of GyverSaber system and also there are two professional jedi fighting with my lightsabers in the end of video!

Features:

  • Smooth turning on/off with lightsaber-like sound effect
  • Randomly pulsing color (you can turn it off)
  • Sounds:
  • MODE 1: generated hum. Frequency depends on angle velocity of blade
  • MODE 2: hum sound from SD card
  • Slow swing - long hum sound (randomly from 4 sounds)
  • Fast swing - short hum sound (randomly from 5 sounds)
  • Bright white flash when hitting
  • Play one of 16 hit sounds, when hit:
  • Weak hit - short sound
  • Hard hit - long "bzzzghghhdh" sound
  • After power on blade shows current battery level from 0 to 100 percent

Battery safe mode

  • Battery is drain BEFORE TURNING ON: GyverSaber will not turn on, button LED will PULSE a couple of times
  • Battery is drain AFTER TURNING ON: GyverSaber will be turned off automatically

Control button:

  • HOLD - turn on / turn off GyverSaber
  • TRIPLE CLICK - change color (red - green - blue - yellow - pink - ice blue)
  • QUINARY CLICK - change sound mode (hum generation - hum playing)
  • Selected color and sound mode stored in EEPROM (non-volatile memory)

Step 1: Materials and Components

I always buy electronic staff on Aliexpress, but you can find same modules on Amazon, eBay, etc.

Electronic components:

Materials and instruments:

  • Polycarbonate tube (light diffusion, 32mm)
  • 2 stubs for this tube
  • Some tubes for hilt (I used PVC sewage pipe and tubings: 40mm for hilt, 32mm for PC tube mount)
  • Steel wire
  • Common instruments for soldering and cutting plastic

Step 2: Wiring

I decided to make this project on prototybe board, 3x7cm, you can see all schematics and some ugly-looking-wiring =)

IMPORTANT! Before wiring, connect DCDC step down converter to 12V DC power source and adjust output voltage to 4.5V!

Step 3: Hilt

I use sewage pipes for hilt, but these are russians sewage pipes, so I think you need to improvise.

Step 4: Batteries

I use 3 lithium batteries (ordinary 18650 from laptop battery). At first we need to put them inside 40mm tube (hilt), and we need to heat the tube for it. But at first we need fix batteries together by tape and thicken them with 2 layers of paper.

So heat the tube, put batteries inside and cool down the tube as fast as you can! Lithium batteries very don't like high temperature. Then pull them off and you will see perfect battery case.

Step 5: Soldering Batteries

As I said, lithium batteries don't like high temperature. So use flux and powerful soldering iron (100W) to solder batteries very quickly. So, connect them in serial.

Step 6: Blade and LED Strip

I have 75cm blade, so I cut 75+75=150cm piece of strip. LED strip will be folded twice around wire, so use double-side tape to fix all, and you will get double side LED strip with wire inside.

Strip needs some supports along the blade tube, I used 3 supports made of nail in thermal shrink tubes, and attach them to strip with thread and super glue.

Drill a holes in stubs for wire, wire will be strained between two stubs and fixed by 3mm screw, but not right now.

Step 7: MPU6050

I connected MPU6050 using old IDE flex wire, because it is good idea to place MPU as close to blade as possible. And I just glue it in low stub of PC tube :)

Step 8: Hilt Buttons

Make some holes for buttons and charging port, and a few holes in bottom for speaker. Also I painted hilt with black paint.

Step 9: Final Wiring

So, connect batteries, pull off wires for switch and charge, solder it all and fix in their holes. Also, solder speaker wires too.

Step 10: Speaker Fixing

I fixed speaker using a ring of 40mm tube and some nails =) It is brutal and very strongly.

Step 11: Programming

You can find Arduino sketch, libraries, SD sound files and a lot of instructions in project page on GitHub, but I attached sketch and archive with all project files here, in Instructables.

Simple guide:

  • Open GyverSaber.ino and tune:
  • Number of microcircuits WS2811 on LED strip (note: one WS2811 controls 3 LEDs!)
  • Turn on or turn off blade pulsation
  • Hardly recommend measure real resistance of voltage divider resistors
  • System can work without battery monitoring, just deactivate BATTERY_SAFE. BUT IT IS NOT RECOMMENDED
  • Flash arduino
  • Upload audio files to SD card
  • Enjoy!

MicroSD info:

  • Size < 4G
  • Format to FAT
  • Copy audiofiles in the root

If you want add your own sounds, convert them to .WAV:

  • 8 bit
  • 16-32 kHz
  • Mono
  • Use online converters or Total Audio Converter

WARNING! If you are flashing assembled scheme, you must power up it! Arduino will not work correct with connected DCDC converter!

Step 12: Tuning

I made GyverSaber fully customiseable so you can build your own saber with different blade length and other parameters, just take a look on sketch settings.

Step 13: Final Screw

So, lightsaber is almost done! Just one last screw, which fix blade to tube. I made some drawing with all saber body construction.

Step 14: Results

So, DIY lightsaber is ready to fight! You can watch some tests with spins, swings, object hits, chandelier crash (oops!) and also two real Jedi, fighting with GyverSabers (yes, I made 2 of them!!!) in my video review on this DIY lightsaber and it's functions and features.

Sincerely, MadGyver.

2 People Made This Project!

Recommendations

  • Science of Cooking

    Science of Cooking
  • Pocket-Sized Contest

    Pocket-Sized Contest
  • Trash to Treasure

    Trash to Treasure
user

We have a be nice policy.
Please be positive and constructive.

Tips

7 Questions

Greeting! I found this project right around the end of November. I'm in the states, and ali took... well a long time to get me parts... I just sat down to do this a few days ago, got it wired everything should work, but I'm getting "SD Fail" I tried changing ports, no luck. So I disconnected everything and just hooked up the SD Card reader. I ran a read/write test and the card reader works...

I really have no idea what I could be doing wrong.

This is the reader I have:

https://www.amazon.com/SenMod-Adapter-Reader-Modul...

I also went with LED strips that work off of 5v. They probably won't be as bright, but I'm ok with that. Will I still need the 100k and 51k resistor loop?

Thanks in advance!

~C~

hello i am trying to make this and i have the following thing when i got batteries they told me not to solder then together cause they may be damaged so i took normal batteries without protection in the photos you also use unprotected if i am not mistaken and i also took battery holders so i wont solder them is there a way to make sure the batteries dont go below the right voltage so they could be recharged? thanks

I made this, and I plugged it in with no battery and it works, it hums and turns on and off without LED strip, and when I add the LED strip, it doesn't work, led just flashes a few times and it only plays on sound.

Hi when you make the led strip bit do you cut it in half at 75cm and then join the two ends together to connect to the board- otherwise wouldn't it light up one side to the top and then go back down the other side? Sorry if this is a silly question

Hello Mr. Gyver,
Why do you define pin A0 as SD Ground (SD_GND) and pin A1 as IMU Ground (IMU_GND)?
If I use SD Card module and MPU 6050 module with Vcc 5V, then the A0 and A1 pins are not used?
I am very excited about creating a lightsaber with the help of your tutorial.
Thank you very much.

That's correct Apramudiya. My modules have built in 3V3 regulators.
Just a heads-up, the SD module I've used is the FJS-66 one from Aliexpress - it's bigger than the Nano board! http://bit.ly/2nTyRS9
I'm looking for a charger / 5V module which will protect the Li-ion cell - something like this: http://bit.ly/2nVtPVj
It's the mechanical parts that will be difficult for me.
May the Force be with us always.

Hi - Not Mr Gyver but I've just put exactly those parts on a breadboard with Ground proper used. It doesn't in fact work otherwise. I'm also going to use 5V LEDs at reduced voltage (and current) but found today up to 16 LEDs only with this software.
The sounds and responsiveness are impressive though. I'll probably use the Adafruit library rainbow for this as it's for my grandson. The Force is strong with him.

TQ for comment Darth Sock Puppet.. So your point is if we use 5 Volts to supply micro SD (5 Volts version), MPU6050 (5 Volts version) & WS2812B (5 Volts version) then the ground of each module can connected directly to whole circuit/ battery ground, and in sketch: pins A0 and A1 not defined as SD_GND and IMU_GND? May Force be with us..

Hello Mr. Gyver,
Why do you define pin A0 as SD Ground (SD_GND) and pin A1 as IMU Ground (IMU_GND)?
If I use SD Card module and MPU 6050 module with Vcc 5V, then the A0 and A1 pins are not used?
I am very excited about creating a lightsaber with the help of your tutorial.
Thank you very much.

Would a 1 inch polycarbonate tube work for the blade?

83 Comments

if i dont use 3 18650 and dcdc step down should i need to put 51k and 100k resistance still?

This is a great project - your code is very elegant. I have it working with a WS2812S strip on 5V.
I've tied A6 high as I'll have battery protection in hardware and I couldn't select more than 16 leds otherwise.
The BRIGHTNESS allows me to keep the current to a reasonable level for my single 18650 with a mod in the hit_flash for a brighter effect.
Again, fine code, great project. Thank you.

Hello MadGyver, very impressive work, specially when you try to build it, you realize it is really complicated :)

I succeeded to get the parts, and found out my Nano is a clone, had issues installing the win driver, but know connection with board is ok.

When trying to upload skecth is giving the following error:

/tmp/446632482/GyverSaber/GyverSaber.ino: In function 'void setup()':

/tmp/446632482/GyverSaber/GyverSaber.ino:157:17: error: 'setAll' was not declared in this scope

setAll(0, 0, 0); // and turn it off

^

/tmp/446632482/GyverSaber/GyverSaber.ino:203:20: error: 'setColor' was not declared in this scope

setColor(nowColor);

^

/tmp/446632482/GyverSaber/GyverSaber.ino:204:35: error: 'voltage_measure' was not declared in this scope

byte capacity = voltage_measure(); // get battery level

^

/tmp/446632482/GyverSaber/GyverSaber.ino:212:33: error: 'setPixel' was not declared in this scope

setPixel(i, red, green, blue);

^

/tmp/446632482/GyverSaber/GyverSaber.ino: In function 'void loop()':

/tmp/446632482/GyverSaber/GyverSaber.ino:224:15: error: 'randomPULSE' was not declared in this scope

randomPULSE();

^

/tmp/446632482/GyverSaber/GyverSaber.ino:225:11: error: 'getFreq' was not declared in this scope

getFreq();

^

/tmp/446632482/GyverSaber/GyverSaber.ino:226:16: error: 'on_off_sound' was not declared in this scope

on_off_sound();

^

/tmp/446632482/GyverSaber/GyverSaber.ino:227:11: error: 'btnTick' was not declared in this scope

btnTick();

^

/tmp/446632482/GyverSaber/GyverSaber.ino:228:14: error: 'strikeTick' was not declared in this scope

strikeTick();

^

/tmp/446632482/GyverSaber/GyverSaber.ino:229:13: error: 'swingTick' was not declared in this scope

swingTick();

^

/tmp/446632482/GyverSaber/GyverSaber.ino:230:15: error: 'batteryTick' was not declared in this scope

batteryTick();

^

/tmp/446632482/GyverSaber/GyverSaber.ino: In function 'void btnTick()':

/tmp/446632482/GyverSaber/GyverSaber.ino:258:26: error: 'setColor' was not declared in this scope

setColor(nowColor);

^

/tmp/446632482/GyverSaber/GyverSaber.ino:259:32: error: 'setAll' was not declared in this scope

setAll(red, green, blue);

^

/tmp/446632482/GyverSaber/GyverSaber.ino: In function 'void on_off_sound()':

/tmp/446632482/GyverSaber/GyverSaber.ino:281:27: error: 'voltage_measure' was not declared in this scope

if (voltage_measure() > 10 || !BATTERY_SAFE) {

^

/tmp/446632482/GyverSaber/GyverSaber.ino:285:18: error: 'light_up' was not declared in this scope

light_up();

^

/tmp/446632482/GyverSaber/GyverSaber.ino:310:18: error: 'light_down' was not declared in this scope

light_down();

^

/tmp/446632482/GyverSaber/GyverSaber.ino: In function 'void randomPULSE()':

/tmp/446632482/GyverSaber/GyverSaber.ino:349:46: error: 'setAll' was not declared in this scope

setAll(redOffset, greenOffset, blueOffset);

^

/tmp/446632482/GyverSaber/GyverSaber.ino: In function 'void strikeTick()':

/tmp/446632482/GyverSaber/GyverSaber.ino:360:15: error: 'hit_flash' was not declared in this scope

hit_flash();

^

/tmp/446632482/GyverSaber/GyverSaber.ino:373:15: error: 'hit_flash' was not declared in this scope

hit_flash();

^

/tmp/446632482/GyverSaber/GyverSaber.ino: In function 'void batteryTick()':

/tmp/446632482/GyverSaber/GyverSaber.ino:522:25: error: 'voltage_measure' was not declared in this scope

if (voltage_measure() < 15) {

^

exit status 1

PLEASE HELP !!!

thanks a lot

Robert

Where'd you get the polycarbonate tube?

Hi, what's the OUTER diameter/radius of the middle part of your hilt, and what is the length of the hilt? and is 32mm the outer or inner diameter of the polycarbonate tube?

So,

I am trying to plan this out, but the component links are all going to the site in Russian. I am not able to accurately find the items on the English site.. any suggestions other than re-searching the components?

user

In the url, just change ru.aliexpress to en.aliexpress or whatever language you prefer.

Add the product to the basket in Russian and close. Then open aliexpress in English and you have it in the basket

how much did you spent to build the lightsaber...Im new on this but im planning to build my first lightsaber but using 144 led /m with ws2812 or a luxeon tri-rebel

Looks awesome, but what do you think about using 3xAA battery holders? (https://ru.aliexpress.com/item/10pcs-AA-Battery-Holder-Storage-Container-4-5V-Plastic-Box-For-3xAA-Rechargeable-Batteries-Wholesale/32824586626.html?ws_ab_test=searchweb0_0%2Csearchweb201602_5_10152_10065_10151_10344_10068_10342_10343_10059_10340_10314_10341_10534_5790011_100031_10084_10604_10083_10103_10307_10142%2Csearchweb201603_25%2CppcSwitch_2&algo_expid=6cb9de62-b0fe-49c2-87d7-9b574606fff7-2&algo_pvid=6cb9de62-b0fe-49c2-87d7-9b574606fff7&rmStoreLevelAB=5)

&#52897;&#52376;.JPG