neskweek / LightSaberOS

Operating System for Arduino based LightSaber
Creative Commons Zero v1.0 Universal
80 stars 25 forks source link

LightSaberOS by neskweek and Protonerd based on Protonerd's DIYino saber boards


VIDEOS

![DIYino demo of Neopixel lightsaber blade with LSOS] (http://img.youtube.com/vi/PjXLKvWpA8A/0.jpg)
This is a modified version of the neopixel code. LSOS doesn't come with this fire effect out of the box ;)
![DIYino prototype demo with LSOS by neskweek - Swings] (http://img.youtube.com/vi/tU3GZzV9I6E/0.jpg)![Motion Detection Demo (made under v1.0 RC5)] (http://img.youtube.com/vi/wY8BSSEyYLY/0.jpg)![Quick tour (made under v1.0 RC4)] (http://img.youtube.com/vi/mc8scn_qyFM/0.jpg)


FEATURES :


WHAT YOU WILL NEED :


DEVICE CURRENTLY SUPPORTED :

Designed to be used on DIYino boards (recommended) Designed to be used on Arduino Nano, Arduino Pro mini (ATmega328 processors)


SET UP FOR ARDUINO IDE:

These instructions should work for IDE version 1.6.0 and greater and may work with 1.5.x also. If compiling hangs with 1.6.4, try again with File > Preferences > Compiler warnings: None.

  1. Download and install Arduino IDE (recommended version 1.6.11 or newer)
  2. Download https://github.com/neskweek/LightSaberOS/archive/master.zip.
  3. Unzip the downloaded file LightSaberOS-master.zip.
  4. Rename the unzipped folder from LightSaberOS-master to LightSaberOS.
  5. Move all folders inside LightSaberOS/Libraries to {sketchbook folder}/libraries. You can find the location of your sketchbook folder at File > Preferences > Sketchbook location.
  6. Open the file LightSaberOS/LightSaberOS.ino.
  7. Connect the USB cable to your Arduino.
  8. Set up your board manager in Tools/Boards/Boards Manager, select Arduino AVR Boards by Arduino and in the lower left side of the box the version 1.6.17 (recommended) and press install
  9. Select the correct board in Tools > Board (Arduino Nano for DIYino Prime v1 or Arduino/Genuino Uno for DIYino Prime v1.5 or greater and for Stardust)
  10. Select the correct port in Tools > Port.
  11. Follow the Project Setup instructions at https://github.com/neskweek/LightSaberOS.
  12. Once all configuration changes have been made to LightSaberOS.ino, do Sketch > Upload.

PROJECT SETUP

0. General Warnings

You are decided to build your lightsaber. Cool !
Don't think I want to deceive you from your goal but you 'll have to keep those things in mind :

1. IMU calibration

First, you'll need (if not already done) to calibrate your MPU6050. DIYino boards come pre-calibrated with calibration values stored starting from EEPROM address 96 or 200 (see comments for branch LSOS 1.5) I recommend you use the AutoCalibration script you can find here

2. Determine IMU orientation

The way you physically installed the MPU6050 in your hilt will influence how swing detection works.
You'll have to determine which IMU's axis is parallel to blade axis and change it accordingly in Config.h :

//#define BLADE_X
#define BLADE_Y
//#define BLADE_Z

3. Prepare your SDCard

Then, put the content of SDCard.7z on your SDCard:

  1. Format your SDCard. I insist ! (go read HOW TO MANAGE YOUR SDRCARD section for further explanation)
  2. Unzip SDCard.7z to a folder
  3. Select all the files from this folder and "Drag and Drop" them to your SDCard. NO COPY AND PASTE !!! : We need to have this file copied in the same order as their filename order. On Microsoft Windows, Copy/paste produce an anarchic copy order, but Drag and Drop produce an ordered copy as long as you select the first file to init the drag...

4. Check Wirings

If you use DIYino board, don't mind that paragraph.Go there instead and read user manual
If you use DIYino board v1, and want flicker effect wire SPK+ to A6 and SPK- to A7. Starting with v1.5 and Stardust this connections is included on-board.

Using Protonerd's wirings.
Don't forget to wire those ones which were added :

5. Select your blade type

A.LEDSTRINGS

In Config.h be sure this line is uncommented :

#define LEDSTRINGS 
B. RGB LEDs or Single LED

In Config.h comment this line :

#define STAR_LED 
C. Neopixel stripes
#define PIXELBLADE 

6. Compile and Upload the sketch to your Arduino device

7. Enjoy


Finite State Machine or How to interact with your saber :

In Standby Mode (idle) :
In PowerSaving Mode (idle) :
In Action Mode :
In Config Mode :

HOW TO MANAGE YOUR SDCRAD

1. For DFPlayer Mini

While there are several ways to make the DIYino board play your sound files from your SDard, only one can provide full gapless sound "enqueuing" : we need to call each sound file by their copy order number.

Let's say you have a fresh formatted SDcard.
You copy one file on it : its copy order is 1.
You copy another one: its copy order is 2. You copy another one: its copy order is 3.

Now the main "problem" to be aware of is : you remove file 2 (because you maybe want to replace it) : file 3 keep is order number. You copy another one: its copy order is 4.

In that case the only proper way to manage your SDCard I found is he following :

  1. You create a folder called sdcard on your computer
  2. Using a batch renamer utility (I personnaly use Bulk Rename Utility) you rename and copy your sound files to that folder in the order you planned
  3. You format your SDCard
  4. You select all your files from sdcard directory and DRAG AND DROP them to your SDCard.

Drag and drop on windows genereate a ordered copy following file name sorting.
Copy and paste (Crtl+C/Ctrl+V) generate an anarchic ordered copy. Don't use it !

Each time you will want to modify one file you'll have to do it that way. Adding files on he other hand can be done without formatting.

Files MUST be named that way :
XXXX[-myfileName].wav
where :

You can put files in different folders if you like. You don't necessarily need to let them on SDCard root.
BUT STILL BEWARE OF THOSE NUMBERS !!!!
Here are different examples of organisation you can use :


HOW TO PERSONNALIZE CONFIG MENU SOUNDS

Let's say you want to change the lady voice or ladies users may want their saber with a male voice or you may want her to talk in Dutch or French or Italian or Spanish (name your langage here).

I used this online free Text-To-Speech generator to produce those sounds.
You can produce your own sentences with it or use any other Text-To-Speech program.
For example :
"Hello Master! You just entered into Config Mode !"
Then rename the file it produces : 0001-CONFIG-ConfigMode.mp3. Remove old 0001-CONFIG-ConfigMode.wav file.

N.B.:

  1. Only in Config Mode case, mp3 are OK to use. We don't care in this mode if there's sound gap.
  2. Every changes in sounds file will force you to format your SDCard and copy the whole lot again.

HOW TO MAKE YOUR OWN SOUNDFONT

In this video, you'll learn how to create the differents lightsabers sounds-effects.

You can experiment with different device to produce some unique sounds.

Then use Audacity to mix them.

Final sounds MUST BE in WAV format (NO MP3 ! NO WMA!)!
When encoding a sound to those format (MP3 or WMA) the encoder will automaticly put a silence at start.


License:

This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/4.0/]http://creativecommons.org/licenses/by-nc-sa/4.0/ .


THANK YOU !!!

Thanks to Andras Kun (Protonerd from Arduino Forum) for initiating this project, providing DIYino Boards and his big contributions to LSOS Code
Thanks to Jakesoft from Arduino Forum for :

Thanks to Joe Barlow for his excellent opensource soundfont that I did remix for our needs.
Thanks to YOU for using it ;)


WITH YOUR HELP...

... a real life lightsaber which cut through stuffs, like a pizza, could be made...
But first things first : I need the pizza !
paypal
;)


FINAL THOUGHTS

I hope you'll like it.

Don't hesitate to reports bugs (I've made a lot of test but... hey !), or suggest new functionallity.
If you want to contribute to this project, please contact me via mail or on the [thread of this project] (http://forum.arduino.cc/index.php?topic=361566.0)