Arduino Based Lightsaber With Light and Sound Effects

67,599

553

113

About: I like to create things, handmade weapon, arduino projects, science and some crazy staff! Also I like to capturing videos about my projects and I have YouTube channel - MadGyver!

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)

Supplies:

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.

Arduino Contest 2017

Runner Up in the
Arduino Contest 2017

3 People Made This Project!

Recommendations

  • IoT Challenge

    IoT Challenge
  • Colors of the Rainbow Contest

    Colors of the Rainbow Contest
  • Fandom Contest

    Fandom Contest

113 Discussions

0
None
CarlosF207

Question 3 months ago

Hi why not connect The amplifier to the 5v output of the Arduino instead of the step down 5v

1 answer
0
None
inigoheCarlosF207

Answer 8 weeks ago

I think steep down gives 4.5 or less to the ampli board and gives those to a voltage divider who supplies voltage to a digital input in the arduino board.

0
None
inigohe

Question 8 weeks ago

Best regards mate...a great job yours. One question...I have as power source three 18650 batteries to have 12 v, but my stepdown board only gives just 4 v. I think this is not enough to supply ampli board and digital input pin in the arduino nano,....then I have to recalculate the voltage divider?? some idea about, mate!!!;)

0
None
Sock Puppet

1 year ago

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.

1 reply
0
None
muratm7

1 year ago

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

1 reply
0
None
CarlosF207muratm7

Reply 3 months ago

You resolve the problem how convert to 5v

0
None
anv3D

Question 6 months ago

Error in code! Please help!

Error message:
[Arduino: 1.8.7 (Windows Store 1.8.15.0) (Windows 10), Board: "Arduino Nano, ATmega328P (Old Bootloader)"
Build options changed, rebuilding all
In file included from C:\Users\Brendan\Documents\GyverSaber\GyverSaber\GyverSaber.ino:106:0:
C:\Users\Brendan\Documents\Arduino\libraries\FastLED/FastLED.h:17:21: note: #pragma message: FastLED version 3.001.005
# pragma message "FastLED version 3.001.005"
^
C:\Users\Brendan\Documents\GyverSaber\GyverSaber\GyverSaber.ino: In function 'void setup()':
GyverSaber:194:17: error: 'setAll' was not declared in this scope
tmrpcm.setVolume(5);
^
GyverSaber:245:20: error: 'setColor' was not declared in this scope
GyverSaber:246:35: error: 'voltage_measure' was not declared in this scope
GyverSaber:254:33: error: 'setPixel' was not declared in this scope
C:\Users\Brendan\Documents\GyverSaber\GyverSaber\GyverSaber.ino: In function 'void loop()':
GyverSaber:269:15: error: 'randomPULSE' was not declared in this scope
if (nowColor >= 6) nowColor = 0;
^
GyverSaber:270:11: error: 'getFreq' was not declared in this scope
setColor(nowColor);
^
GyverSaber:271:16: error: 'on_off_sound' was not declared in this scope
setAll(red, green, blue);
^
GyverSaber:272:11: error: 'btnTick' was not declared in this scope
eeprom_flag = 1;
^
GyverSaber:273:14: error: 'strikeTick' was not declared in this scope
GyverSaber:274:13: error: 'swingTick' was not declared in this scope
if (btn_counter == 5) { // 5 press count
^
C:\Users\Brendan\Documents\GyverSaber\GyverSaber\GyverSaber.ino: In function 'void btnTick()':
GyverSaber:303:26: error: 'setColor' was not declared in this scope
tmrpcm.play("HUM.wav");
^
GyverSaber:304:32: error: 'setAll' was not declared in this scope
C:\Users\Brendan\Documents\GyverSaber\GyverSaber\GyverSaber.ino:311:32: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
digitalWrite(BTN_LED, 0);
^
C:\Users\Brendan\Documents\GyverSaber\GyverSaber\GyverSaber.ino: In function 'void on_off_sound()':
GyverSaber:326:27: error: 'voltage_measure' was not declared in this scope
C:\Users\Brendan\Documents\GyverSaber\GyverSaber\GyverSaber.ino:328:29: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
GyverSaber:330:18: error: 'light_up' was not declared in this scope
EEPROM.write(1, HUMmode); // write mode in EEPROM
^
C:\Users\Brendan\Documents\GyverSaber\GyverSaber\GyverSaber.ino:336:32: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
if (((millis() - humTimer) > 9000) && bzzz_flag && HUMmode) {
^
C:\Users\Brendan\Documents\GyverSaber\GyverSaber\GyverSaber.ino:353:28: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
GyverSaber:355:18: error: 'light_down' was not declared in this scope
PULSE_timer = millis();
^
C:\Users\Brendan\Documents\GyverSaber\GyverSaber\GyverSaber.ino:370:26: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
strcpy_P(BUFFER, (char*)pgm_read_word(&(strikes_short[nowNumber])));
^
C:\Users\Brendan\Documents\GyverSaber\GyverSaber\GyverSaber.ino: In function 'void randomPULSE()':
GyverSaber:394:46: error: 'setAll' was not declared in this scope
C:\Users\Brendan\Documents\GyverSaber\GyverSaber\GyverSaber.ino: In function 'void strikeTick()':
GyverSaber:405:15: error: 'hit_flash' was not declared in this scope
swing_timer = millis();
^
GyverSaber:418:15: error: 'hit_flash' was not declared in this scope
C:\Users\Brendan\Documents\GyverSaber\GyverSaber\GyverSaber.ino: In function 'void batteryTick()':
GyverSaber:572:25: error: 'voltage_measure' was not declared in this scope
C:\Users\Brendan\Documents\GyverSaber\GyverSaber\clear.ino: In function 'void setup()':
clear:2:6: error: redefinition of 'void setup()'
void setup() {}
^
C:\Users\Brendan\Documents\GyverSaber\GyverSaber\GyverSaber.ino:191:6: note: 'void setup()' previously defined here
C:\Users\Brendan\Documents\GyverSaber\GyverSaber\clear.ino: In function 'void loop()':
clear:3:6: error: redefinition of 'void loop()'
void loop() {}
^
C:\Users\Brendan\Documents\GyverSaber\GyverSaber\GyverSaber.ino:268:6: note: 'void loop()' previously defined here
nowColor++; // change color
^
exit status 1
'setAll' was not declared in this scope
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.]

gyversaber-error.png
1 answer
0
None
CarlosF207anv3D

Answer 3 months ago

It's compiles with no error
Check if you put the lybraries folder in the Arduino installation folder

0
None
anv3D

Question 3 months ago

PLEASE RESPOND!

How would I change the code to work with 1 or 2 18650 batteries or AAA/AA batteries, and
5V WS2812B LED strip? This would really help. Thanks!

1 answer
0
None
CarlosF207anv3D

Answer 3 months ago

Hi i Made this proyect and works ok
I made some trys to convert to 5v with a step up to 5v with one batery 3.7 v
Connected to vcc Arduino and amplifier too, and kill the amplifier board, Even i try to conect the amplifier board direct to 5v output Arduino eliminating the step up, and dont work, i give up

0
None
ZNACKI.R

4 months ago

О, какие люди, здарова, Алекс))

0
None
fett7703

7 months ago

i have the second choice of The module SD 5 volts and has sck instead of CLK like the guide that use the mini module sd of 3v3

debug code in ide arduino and show sd fail i put vcc to 5v in ardunio an gnd to main ground any idea whats tje problem is?

0
None
anv3D

Question 8 months ago

Is there a way to make the first 3 LEDs to not flash? still change colour but not flash? I'm planning to seperate the first few and put it in a kyber crystal

0
None
bb151bb

Question 8 months ago on Step 8

- Can I use 4 AAA rather than 18650 batteries?

- Is it's OK to use arduino pro mini 3.3 to save more space?

0
None
ca_rodriguez

Question 1 year ago

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~

2 answers
0
None
AmrasElensarca_rodriguez

Answer 10 months ago

Hi, did you ever find the problem? I have the same thing and also with the gyro. Haven’t tried rewiring yet.

0
None
muratm7AmrasElensar

Reply 10 months ago

If you use another sd card module use 5v and GND instead of 3v3 and a4 pin. I got the same thing I guess months ago I figured it out.