Arduino Lightsaber

You can throw a few pictures of the entire system with speaker and LED??? :smiley:

You have a very saleable winner there. Thats why you are being quizzed so thoroughly. Hang on to it man and send it to someone who can manufacture it for you . You will make a fortune

I am getting ready to start a similar build and had found the same swing sensor but the part I cant figure out is how to configure it to detect a swing and not a tilt as the data sheets show its primary a tilt sensor.

I had thought about mounting it vertical the hilt with ball contact down but then if you tilt the saber at the ground it would continually trigger a swing.

Do you just detect on change condition but then I would think a slow tilt would still trigger a swing event and the toy sabers don't seem to do that and I am sure the expensive sound boards don't.

b-james:
You have a very saleable winner there. Thats why you are being quizzed so thoroughly. Hang on to it man and send it to someone who can manufacture it for you . You will make a fortune

It's funny you should say that. I posted up a similar thread to this one in the forums at The Custom Saber shop and the moderator wasn't too keen on people asking me how was built since they sell lightsaber control boards.

While I really just built this for fun and not for sale, everyone tells me I should sell it. LOL

duvallwolfster:
I am getting ready to start a similar build and had found the same swing sensor but the part I cant figure out is how to configure it to detect a swing and not a tilt as the data sheets show its primary a tilt sensor.

I had thought about mounting it vertical the hilt with ball contact down but then if you tilt the saber at the ground it would continually trigger a swing.

Do you just detect on change condition but then I would think a slow tilt would still trigger a swing event and the toy sabers don't seem to do that and I am sure the expensive sound boards don't.

Let me summarize by saying "It ain't perfect".

I did write the code to detect a change in state; the sensor is basically just a switch with only 2 possible states. I mounted it vertically (and slightly tilted) in the hilt with the ball down. That way when I spin it, swings are detected. When I slash with it, it usually works too, but it's not perfect. I've worked with some of the toy sabers before and they seem to work the same way (a slow swing will still make a swing sound happen).

It is more sensative than you might expect, though. Just experiment and you'll see. If you want to be able to tell the difference between a slow swing and a fast swing you'll need a different kind of sensor. I know some of the high-priced lightsaber control boards use accelerometers to accomplish this, but expect your code to be more tricky if you go that route.

Jakesoft,

Where you able to ever get you wt588d-28p working? I am trying to get this thing to make noise using sugarbombs template code for the 16 pin model but cannot for the life of me get the 28p with attached usb programmer to make noise in 3 line mode. Any help would be greatly appreciated.

I ended up abandoning the whole 3 line mode with the wt588d-u-32 but using your project as a starting point I made my own saber using the one line serial mode and a buck convertor in place of your transistor. I'll post some vids of the saber in a bit here. Anyways, thanks for the idea, spent 12$ only for the parts and saved myself a grip of cash.

android42:
I ended up abandoning the whole 3 line mode with the wt588d-u-32 but using your project as a starting point I made my own saber using the one line serial mode and a buck convertor in place of your transistor. I'll post some vids of the saber in a bit here. Anyways, thanks for the idea, spent 12$ only for the parts and saved myself a grip of cash.

I'm so pleased to read that somebody has used the design to build a saber. Good for you! I really look forward to seeing what you've done.

How did you get the one-line serial mode to work? I sort of had the opposite experience to what you had: I tried 1-line mode first but then abandoned it when SugarBombs posted working 3-line code.

Man, this is great!
How hard would it be to use an accelerometer?

Isaac96:
Man, this is great!
How hard would it be to use an accelerometer?

Thanks! It's interesting you should ask that. I'm working on integrating an ADXL335 3-axis accelerometer right now. I plan to post a video on my YouTube channel when I have something worth showing.

Ok, I will watch for that. :slight_smile:

Thanks! It's interesting you should ask that. I'm working on integrating an ADXL335 3-axis accelerometer right now.

Jakesoft, your video is awesome. Just a couple of doubts.

Did you programmed the accelerometer to work as an interrupt?
If so, how did you managed to get the WT588D to work without the delay functions?

kingale:
Jakesoft, your video is awesome. Just a couple of doubts.

Did you programmed the accelerometer to work as an interrupt?
If so, how did you managed to get the WT588D to work without the delay functions?

I find your lack of faith disturbing. :wink:

Seriously, though, polling for acceleration data at a rate of ~10ms seems to be enough for accurate swing sensing in the experimentation I've done, so no interrupt needed for that. The mechanical clash sensor is still present in the design and is on an interrupt for crisp, immediate clash response.

For reference, here is a link to the latest breadboard video with the accelerometer added:

hello friend, very good your project, like some help because I am doing a similar, would like to contact? andrecruzchagas@gmail.com

thanks

-------Note: the boards contained in this post are now obsolete and links to them have been removed, though for continuity the remainder of the poast has been left largely unedited. New and improved versions are imminent and links to them will be posted once they have passed the field test phase-------

Great thread jakesoft, your a very cool dude for sharing your code with everyone.

As it happens, I've recently finished working on some circuit artwork for an almost identical setup (although it didn't start out that way). Funnily enough I've only been working on the hardware aspect and hoped to find some software for it later. It was my ever tightening word searches for relevant code which eventually brought me here.

I think I'm going to join in with your sharing spirit and leave links below to download the folders that contains all of the circuit artwork for anyone who wishes to etch their own.

I have amended the below information to reflect recent updates and additions I have made the layout.

I have updated the design to incorporate all elements onto one PCB so have adjusted the following system description (and a few other things in this post) to match the updates.

There are now two PCB variants which I'm releasing for public use, one for direct speaker driving via the PWM output and one for external amplification via the DAC output.

Note: Sorry, no code to go with them yet. I am attempting to tackle it but coding isn't my area of expertise so can't say when it will be included.

Here is the new brief description of the system.

  1. PSU section.

A 5v fixed LM1117 SOT-223 regulator has been placed on the input rail so any wall wart can be used with output voltages ranging from 5~12v.

Following that is an integrated Li-Po charging circuit using the MCP73833-AMN-UI IC which has been balanced to work with a 3.7v 2.3Ah RCR123A cell.

The positive rail from the charger IC has been made open circuit and solder pads added for an "isolator" switch to disconnect it from the battery when not charging to prevent any reverse voltage issues from occurring which may harm the charger IC.

The CR123A cell itself sits in a PCB mountable holder which is situated on the blank side of the PCB and has a direct rail via a power mosfet to a single 3v 1w LED and a footprint for a 2w resistor has been placed in series with it.

This system uses two 5v devices which are the pro mini and WT588D. As such I've included 5v .5A micro boost buck module footprints to both variants and routed them in parallel in order to provide them both with the correct Vf and current (links to the module can be found in the BOM contained in the folder).

Footprints for mounting both an arduino pro mini and WT588D-16p have been included on both variants for easy assembly using standared straight header pins.

Sitting under the pro mini is an LP2992 3v3 250mA fixed voltage regulator which provides the correct voltage to the MMA8452Q accelerometer sitting up front (the MMA8452Q has two level shift resistors on board so didn't need to add any on the circuit).

The devices on/off state control pin has been tied to the arduino in order to take advantge of this function. It could have been tied to the input pin but would have drawn current even when everything else was asleep which is inefficient so opted for this setup instead.

PWM variant sound:

This board breaks out the PWM + - pins of the WT588D for direct speaker driving and is a little shorter than the DAC variant overall.

DAC variant sound:

The WT588D's DAC output along with the voltage output from a second micro 5v boost buck (rated @1A) have been broken out to drive an external amplifier up to 3w. This does however mean that the PCB is a bit longer overall than the PWM variant.

Note: Although it looks like the SMD stuff is suited for a higher skill level, it's totally possible to solder them all on by hand.

The trick is to wet one of the the pads with a smidgen of solder first. Not enough to make a mound as it needs to be pretty flat but thicker than just tinning.

Slather on some flux or rosin once the pad has cooled (I like no clean liquid flux) and carfully put the component in place taking care to note it's orientation should it have one.

The iron should be set to a mid/high temp if you have that level of control and then using a pair of tweezers, hold the componant in position while you place the tip of the iron (with a little pressure) onto the IC leg resting on the pre soldered pad for two seconds and let cool.

In the case of 0805s, the tip wants to be partly on the pad and partly against the componamt terminal to allow the solder to flow underneath it a little. The solder should have a nice slope leading from the top of the chip to the edge of the pad rather like a quarter pipe. Don't panic if you over do it a little but just be sure to check for short circuits.

It will now be stuck firmly enough for you to finish the job without holding it.

Lastly, I've only gingerly started to look at learning c++ due to numerical dyslexia. Unlike it's more obvious cuosin, this one likes to occasionally do random things to numbers and letters (not often but reading also sufferes) which can sometimes go unnoticed.

For most areas of my life it's just an annoyance but it doesn't take a genius to realise that this is really bad news for coding. Just thinking about having to track down a dodgy digit in 100 lines of code brings the phrase "needle in a haystack" springing to mind but in my case, this time it really means it.

But, rather than put a request out there for free help to write code, I'd be up for trading a PSU board with all the SMD components pre-soldered if anyone would like to help me out (I have just enough parts to let one go), or even better, knock heads with someone in order to come up with a definitive "home brew" hilt fx package for everyone.

I nearly collapsed when I found out how much purpose made hilt fx boards were on their own (like the Biscotte) let alone having one fitted. I know some people will only see the object and not the money but that kind of pricing totally takes the pi**

Just in case anyone is interested I've attached a pic of the lightsaber I'm making too.

Whoa, hey that is pretty similar to my setup! I like the core logic board. I made almost exactly the same thing out of strip board on my last build! I wish I had the skills to make something more like your version.

You seem to have exactly the opposite strengths to my own. When it comes to the software, I'm literally a pro. The Arduino libraries are so well documented that I can usually figure out how to do what I want pretty easily in code, but I'm weak on the hardware side. I understand circuit theory, but I have to read up a lot on components and stuff when I do a project. The thought of etching circuit boards with exotic chemicals is daunting to me, but may not be for others.

Nice contribution to the thread. Thanks for sharing!

JakeSoft:
Whoa, hey that is pretty similar to my setup! I like the core logic board. I made almost exactly the same thing out of strip board on my last build! I wish I had the skills to make something more like your version.

You seem to have exactly the opposite strengths to my own. When it comes to the software, I'm literally a pro. The Arduino libraries are so well documented that I can usually figure out how to do what I want pretty easily in code, but I'm weak on the hardware side. I understand circuit theory, but I have to read up a lot on components and stuff when I do a project. The thought of etching circuit boards with exotic chemicals is daunting to me, but may not be for others.

Nice contribution to the thread. Thanks for sharing!

Hey, no problem :slight_smile:

Actually, do you fancy a trade?

Board layout and fabrication is fun for me and I'd happily make you some boards up at my expense in return for some of your coding.

Talking of board layout. An unexpected update for the design app I use has allowed me to consolidate all the elements together on one board :slight_smile:

I'm designing a couple more as this one isn't generic enough to let loose on the public. One will be for direct PWM speaker driving via the WT588D, the other will have an output port for external amplification and include the 5v 1A boost buck module.

making a few more small modifications.......

Great project, JakeSoft! I've actually started my own saber project, but am struggling with the accelerometer code. Do you have your sketch published anywhere, or would you be willing to share some snippets of yours that detail the accelerometer readings?

JakeSoft:
How did you get the one-line serial mode to work? I sort of had the opposite experience to what you had: I tried 1-line mode first but then abandoned it when SugarBombs posted working 3-line code.

Here is the code for the One-line serial mode.
Just remember to change de config in the WT588D programmer.

void WT588D_Send1(byte addr) {
    digitalWrite(wt_scl, LOW);
    delay(5);

    for(int i = 0; i < 8; i++)  {
        digitalWrite(wt_scl, HIGH);
        if(bitRead(addr, i)) {
            delayMicroseconds(600);
            digitalWrite(wt_scl, LOW);
            delayMicroseconds(200);
        } else {
            delayMicroseconds(200);
            digitalWrite(wt_scl, LOW);
            delayMicroseconds(600);
        }
    }

    digitalWrite(wt_scl, HIGH);
    delay(100);
}

llluis:
Here is the code for the One-line serial mode.
Just remember to change de config in the WT588D programmer.

void WT588D_Send1(byte addr) {

digitalWrite(wt_scl, LOW);
    delay(5);

for(int i = 0; i < 8; i++)  {
        digitalWrite(wt_scl, HIGH);
        if(bitRead(addr, i)) {
            delayMicroseconds(600);
            digitalWrite(wt_scl, LOW);
            delayMicroseconds(200);
        } else {
            delayMicroseconds(200);
            digitalWrite(wt_scl, LOW);
            delayMicroseconds(600);
        }
    }

digitalWrite(wt_scl, HIGH);
    delay(100);
}

Hey, that's helfpul! I can't wait to try this out. Two less wires to connect up. If I'm not mistaken, this may actually even be faster than 3-line mode because the delays are much shorter. So, potentially less time with the Arduino locked up on sending the commands. Well, assuming that last 100ms delay isn't really necessary. Is it?