Home
Herein lies guidance on creating your own lightsaber soundboard.
-Brandon Sidle, Creator
###Contents
Here is a link to the video demo: https://youtu.be/yI6-dfwmiuo
This prototype lightsaber soundboard includes high-quality and customizable sound and high quality sensor technology. Not to mention higher speaker quality, this project is a vast improvement over store-bought low quality lightsabers.
Hasbro makes their lightsabers with low-tech clash and swing sensors that cannot be adjusted for sensitivity, and do not have programmable soundboards. This is how they keep their prices low, as well as with high volume manufacturing and cheaper, plastic hilts and cheaper speakers. This project was intended to give a lightsaber solution that is completely customizable and higher quality than Walmart lightsabers and to bridge the gap between ultra-high quality lightsabers and economy lightsaber toys in terms of price.
- Arduino Pro Mini 3.3V 8MHz
- Adafruit FX Sound Board
- MPU6050 Accelerometer
- 100 Ohm Resistor
- 4.7kOhm Resistor
- LED
- Push Button
- Wires
- Speaker
To create this exact circuit, use the following pins:
Arduino MPU6050 Sound Board Other
VCC VCC Vin
GND GND Gnd
D3 0
D4 1
D5 2
D6 3
D7 4
D8 PushButton
D9 LED
A4 SDA
A5 SCL
With the Adafruit Sound Board I bought, you have to use a 3.5mm audio jack for your speaker, but there is an option for a Sound Board that uses an 8ohm speaker. For that, solder your speaker to the Line Out pins on the board.
You can connect the Adafruit Sound Board to your computer via micro-usb and upload your sound files to the chip. The chip only accepts .wav and .ogg files and has a special naming convention for the files. My files are named as follows: *T00.wav (startup sound) *T01HOLDL.wav (humming sound stays on as long as it receives a GND signal) *T02.wav (shutdown sound) *T03RAND0.wav (three different clash sounds are played randomly) *T03RAND1.wav *T03RAND2.wav *T04RAND0.wav (randomly played swing sounds) *T04RAND1.wav
I started with the MPU6050 demo sketch example, but added all the rest of the code other than reading the accelerometer raw data. There are two overarching states to the system: on and off. The off state doesnt necessarily mean the system is off, its just pretending that the lightsaber is off, so it doesnt make any noise. It keeps track of this in the "on" boolean. At this point, it listens for push button input:
//drive the on button
if(digitalRead(button) == LOW){
on = !on;
//turn on sound
digitalWrite(turnon, LOW);
delay(25);
digitalWrite(turnon, HIGH);
}
and sends a GND signal to pin 0 of the soundboard to trigger the start sound.
While the saber is on, it'll listen to the accelerometer and wait for the acceleration to reach the threshold for playing a swing or a clash sound:
//drive swing/clash sensor
if(abs(ax) > 30000 || abs(ay) > 30000 ||
abs(az) > 30000){
digitalWrite(hum, HIGH);
digitalWrite(clash, LOW);
delay(25);
digitalWrite(clash, HIGH);
}
if((abs(ax) > 25000 && abs(ax) < 30000) ||
(abs(ay) > 25000 && abs(ay) < 30000) ||
(abs(az) > 25000 && abs(az) < 30000)){
digitalWrite(hum, HIGH);
digitalWrite(swing, LOW);
delay(25);
digitalWrite(swing, HIGH);
}
Finally, it'll listen for another signal from the push button to start the shutdown sequence:
//drive the off button
if(digitalRead(button) == LOW){
on = !on;
digitalWrite(hum, HIGH);
//turn off sound
digitalWrite(turnoff, LOW);
delay(25);
digitalWrite(turnoff, HIGH);
}
} else {
//if not on, make sure it doesn't hum
digitalWrite(led, LOW);
digitalWrite(hum, HIGH);
}
and make sure the humming sound doesn't play when the saber is in the off state.
Those are the main segments of my added code. Reading from the MPU6050 was handled by the library attached, which was super helpful and easy to use.
Here is a link to the video demo: https://youtu.be/yI6-dfwmiuo
The Lightsaber works almost exactly the way it was intended. The only thing that I would fix would be the gap between the sounds, but that can easily be done by using a sound editing software and editing out the blank space in the .wav files stored in the Sound Board. The sensitivity is a bit finicky and sometimes it can play a clash sound when you swing it too hard or a swing sound when you clash it too weakly, but fine-tuning of the code and the means of mounting the accelerometer can make short work of this problem.
Overall, I am proud of this lightsaber and plan to use the system in a future lightsaber hilt since it is in fact a lot cheaper than a sound board you can get from Ultrasabers or the Custom Saber Shop.
Sound Board: https://learn.adafruit.com/adafruit-audio-fx-sound-board/triggering-audio
MPU6050: http://playground.arduino.cc/Main/MPU-6050#measurements
More MPU6050: http://diyhacking.com/arduino-mpu-6050-imu-sensor-tutorial/
Uploading sketches to Arduino Pro Mini using an Uno: http://www.instructables.com/id/Uploading-sketch-to-Arduino-Pro-Mini-using-Arduino/?ALLSTEPS