Arduino Forum

Community => Exhibition / Gallery => Topic started by: JakeSoft on Aug 20, 2014, 03:39 am

Title: Arduino Lightsaber
Post by: JakeSoft on Aug 20, 2014, 03:39 am
Hi, all. I used an Arduino Pro Mini 3.3V and a WT588d to create a custom sound board and LED controller for my lightsaber. I love this little board. Special thanks to SugarBombs for sharing his working code for the WT588d module! http://forum.arduino.cc/index.php?topic=227435.0 (http://forum.arduino.cc/index.php?topic=227435.0) That really saved me some trouble.

Here are video and pics.

(http://i58.tinypic.com/ws36zq.jpg)
Core IC components: Arduino Pro Mini 3.3V, WT588d sound module, some small MOSFETs, and a 5V regulator.

(http://i57.tinypic.com/1zpp9wh.jpg)
Components mounted on some perf-board and inside the hilt.

And here is a video of it working:
http://youtu.be/3PacAFmnF_8

Update 1-29-2016:
If you are interested in building your own, please read this thread in its entirety before posting questions. You will find that it is a trove of useful information. Most common questions have already been answered.

Update 8-18-2016:
For help in creating your own Arduino saber sketch I have created the Universal Saber Library which supports various hardware. The most recent version is available on GitHub here:
https://github.com/JakeS0ft/USaber (https://github.com/JakeS0ft/USaber)
Title: Re: Arduino Lightsaber
Post by: Pedro147 on Aug 20, 2014, 06:03 am
Good job.  The Force is strong with this one   8)   8)
Title: Re: Arduino Lightsaber
Post by: flyingangel on Aug 20, 2014, 09:44 am
Hi!

Wow, your lightsaber is realy cool! I'd like to update my one too! Do you have any shematics of your version? Which LEDs did you use?

Thanks for sharing,
Robert
Title: Re: Arduino Lightsaber
Post by: raschemmel on Aug 20, 2014, 06:57 pm
Totally cool !
Title: Re: Arduino Lightsaber
Post by: JakeSoft on Aug 21, 2014, 01:16 am

Hi!

Wow, your lightsaber is realy cool! I'd like to update my one too! Do you have any shematics of your version? Which LEDs did you use?

Thanks for sharing,
Robert


Thanks! I am willing to share the design, but I don't have anything that is easy to share digitally; only hand-done drawings in a paper notebook. Give me some time to put something together.
Title: Re: Arduino Lightsaber
Post by: raschemmel on Aug 21, 2014, 01:51 am
Usually we don't have schematic capture software and most of us hate Fritzing because it is not a schematic so what we do is just take photos of the hand drawn stuff and post the photos. My cell phone camera is 8 Mega pixels so it is more than clear enough. I mean let's be realistic here. The guy just cares about how to build it, not how pretty the schematics are. If all the information is there I would say just put it out there as photos, and leave at that.
Title: Re: Arduino Lightsaber
Post by: JakeSoft on Aug 21, 2014, 04:33 am
I made an attempt to transfer the most useful drawing from my notebook. I don't have a good program at home for drawing schematics, so please excuse the crudeness of it.

(http://i60.tinypic.com/hx80h1.jpg)

Not shown are the bits where the N-channel MOSFETs are used to switch the main LEDs. That part is pretty straight forward, though. I hope this helps. If you build it, post up here; I'd love to see what somebody else does with it.
Title: Re: Arduino Lightsaber
Post by: raschemmel on Aug 21, 2014, 06:58 am
Perfect. Thanks !  What kind of leds ?  What current rating will the Mosfets need. ?
Title: Re: Arduino Lightsaber
Post by: JakeSoft on Aug 21, 2014, 01:51 pm
I used a Luxeon Tri-Rebel star LED array like this one:
http://www.ledsupply.com/leds/luxeon-rebel-endor-star-rgb-high-power-led

The Cree version would also work:
http://www.ledsupply.com/leds/cree-xpe-indus-star-rgb-high-power-led

The Custom Saber Shop sometimes has a version in stock with a deeper blue LED. I haven't tried it, but some claim that it makes a better purple when the colors are mixed with red.
http://www.thecustomsabershop.com/Luxeon-Tri-Rebel-Star-P777.aspx

Depending on the color, max current on these kinds of LEDs can range from 700mA to 1500mA. You shouldn't have a problem finding FETs to handle that. Mine are rated for something like 18 amps!

Also, I am noticing I made an error on the diagram. The negative for the WT588d should be on the far left pin at the top, not the right. I'll try to get a fix up for that tonight when I get some time.
Title: Re: Arduino Lightsaber
Post by: raschemmel on Aug 21, 2014, 04:04 pm
Is there more than one led ?
FYI, if anyone is interested, the attached datasheet is for this mosfet from sparkfun (30A)
  https://www.sparkfun.com/products/10213   (https://www.sparkfun.com/products/10213)
Title: Re: Arduino Lightsaber
Post by: JakeSoft on Aug 21, 2014, 05:20 pm
Yes, there is more than one LED (there are three) used to light up the blade in my project example. The way I accomplished changing colors was to use varying levels of Red, Green, and Blue light that mixed together in the blade. At a very basic level, this same method is used by TVs and such to create different colors for each pixel. That's why you'll notice I have the blue lines to the MOSFET gates all connected to PWM-capable pins on the Arduino.

You don't have to do it that way. To simplify the project and operate with a single LED for the main blade, you could drop say pins 5 and 6 and drive a single MOSFET and single LED for the main blade on pin 9. That way you could still have the ramp-up/ramp-down effect during power on/off. You would loose color change and flash-on-clash functionality (at least, you'd have to come up with another implementation, maybe pulse the output or something instead of changing colors), but it would be easier to code and use fewer components (also cheaper, more room in your hilt, etc).

An example of this type of LED would be this:
http://www.thecustomsabershop.com/Luxeon-Rebel-Star-P523.aspx

Also available here:
http://www.ledsupply.com/color-high-power-leds

Title: Re: Arduino Lightsaber
Post by: raschemmel on Aug 21, 2014, 06:52 pm
For the sake of others who are interested and don't know how to write the code to drive the leds, are you going to release your lighting code ? I saw the link for the sound code.
Title: Re: Arduino Lightsaber
Post by: JakeSoft on Aug 21, 2014, 10:39 pm
This will get you started:
http://arduino.cc/en/Tutorial/Fade

Programming-wise, fading these high-powered LEDs is no more complicated than that.
Title: Re: Arduino Lightsaber
Post by: JakeSoft on Aug 22, 2014, 02:44 am
I corrected the schematic in a previous post.
Title: Re: Arduino Lightsaber
Post by: raschemmel on Aug 22, 2014, 02:48 am
Roger that.
Schematic in Reply#6 corrected.
Title: Re: Arduino Lightsaber
Post by: alangarcia on Sep 05, 2014, 05:41 am
Nice!  The Force is strong with this one  8)
Title: Re: Arduino Lightsaber
Post by: wildjack6 on Sep 23, 2014, 05:25 am
Just curious what you used for clash and swing sensor
Title: Re: Arduino Lightsaber
Post by: JakeSoft on Sep 24, 2014, 12:47 am
Swing Sensor:
http://www.thecustomsabershop.com/Swing-Sensor-SW-200D-P486.aspx

Clash Sensor:
http://www.thecustomsabershop.com/Clash-Sensor-SW-18020P-P485.aspx
Title: Re: Arduino Lightsaber
Post by: purgedsoul on Oct 08, 2014, 08:24 pm
So this module can actually do gapless play back? Excellent!
Title: Re: Arduino Lightsaber
Post by: privateRob on Oct 08, 2014, 09:48 pm
Awesome²  8)

What speakers did you use? (8ohm 0.5watt?)
How many db did you get? (It seems as loud as a smartphone on full volume)
On your schematic you didn't use any amplifier, right?

Since you nearly answered all component related questions, you should add the whole list to the first post if possible!
Title: Re: Arduino Lightsaber
Post by: JakeSoft on Oct 09, 2014, 12:20 am

So this module can actually do gapless play back? Excellent!


Yes! Two ways to do it, even:

1. There is a "repeat" serial command that you can send. It will repeat whatever sound is played with no gaps. As long as there are no dead spots at the start or end of your sound files then it works great.

2. You can program the WT588d to play a list of up to something like 200 sounds when commanded. Sounds are played back-to-back with no gaps.

Title: Re: Arduino Lightsaber
Post by: wildjack6 on Oct 09, 2014, 03:03 am
Would you be willing to share some of your code for the soundboard I started playing with it but can't figure out how to get it to repeat any suggestions would help
Title: Re: Arduino Lightsaber
Post by: JakeSoft on Oct 09, 2014, 03:29 am

Would you be willing to share some of your code for the soundboard I started playing with it but can't figure out how to get it to repeat any suggestions would help


Sure. Here is the most important part of the code from SugarBombs:
(See full code here: http://forum.arduino.cc/index.php?topic=227435.0)

Code: [Select]

void WT588D_Send_Command(unsigned char addr) {

 unsigned char i;

 digitalWrite(WT588D_CS, LOW);

 delay(5); //delay per device specifications

 for( i = 0; i < 8; i++)  {    
   digitalWrite(WT588D_SCL, LOW);    
   if(bitRead(addr, i))digitalWrite(WT588D_SDA, HIGH);
   else digitalWrite(WT588D_SDA, LOW);          
   delay(2);  //delay per device specifications  
   digitalWrite(WT588D_SCL, HIGH);    
   delay(2);  //delay per device specifications
 } //end for

 digitalWrite(WT588D_CS, HIGH);

} //end WT588D_Send_Command


Try putting this somewhere in your code:

Code: [Select]


//Turn on repeat mode
WT588D_Send_Command(0xF2);

//Begin playlist 0
WT588D_Send_Command(0x00);



Of course, make sure the WT588d is configured for 3 line serial mode.
Title: Re: Arduino Lightsaber
Post by: JakeSoft on Oct 09, 2014, 03:40 am

Awesome²  8)

What speakers did you use? (8ohm 0.5watt?)
How many db did you get? (It seems as loud as a smartphone on full volume)
On your schematic you didn't use any amplifier, right?

Since you nearly answered all component related questions, you should add the whole list to the first post if possible!


Thanks!

Right, no amplifier needed (although you could certainly add one if you wanted it louder and could find room for it). I don't have any equipment that would allow me to measure it in db, but it's loud enough for me. Smartphone on full volume is probably a pretty good comparison.

I used this speaker in the finished product (8 ohm, 2W):
http://www.thecustomsabershop.com/2W-28mm-Bass-Speaker-P662.aspx

During my breadboarding, I used a very cheap 8 ohm 0.5W speaker that I harvested from a toy. It worked fine, but the sound quality was pretty terrible. Really you should be able to use any 8 ohm speaker with at least a 0.5W power rating. It all depends on your budget and what kind of sound you're looking for. I'll leave that discussion to the audiophiles.
Title: Re: Arduino Lightsaber
Post by: wildjack6 on Oct 09, 2014, 03:55 am
Thanks for the help I will try it out and see what I can get working totally new to programming so any help is appreciated
Title: Re: Arduino Lightsaber
Post by: JakeSoft on Oct 09, 2014, 04:28 am

Thanks for the help I will try it out and see what I can get working totally new to programming so any help is appreciated


Glad I could help. Just be sure call the WT588D_Send_Command() function from somewhere outside your main loop, like when a button is pressed or something, otherwise you may get odd behavior.
Title: Re: Arduino Lightsaber
Post by: wildjack6 on Oct 09, 2014, 04:41 am
Playing with it hopefully can figure it out lol
Title: Re: Arduino Lightsaber
Post by: privateRob on Oct 10, 2014, 10:30 pm
Thank you!
You Sir earned your first karma for all the questions you answered in this thread!
Title: Re: Arduino Lightsaber
Post by: JakeSoft on Oct 11, 2014, 03:57 am

Thank you!
You Sir earned your first karma for all the questions you answered in this thread!


Yay!  8)
Title: Re: Arduino Lightsaber
Post by: egoic on Feb 03, 2015, 02:54 am
You can throw a few pictures of the entire system with speaker and LED??? :D
Title: Re: Arduino Lightsaber
Post by: b-james on Feb 03, 2015, 11:06 pm
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
Title: Re: Arduino Lightsaber
Post by: duvallwolfster on Feb 16, 2015, 11:40 pm
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.
Title: Re: Arduino Lightsaber
Post by: JakeSoft on Feb 19, 2015, 08:59 pm
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
Title: Re: Arduino Lightsaber
Post by: JakeSoft on Feb 19, 2015, 09:09 pm
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.
Title: Re: Arduino Lightsaber
Post by: android42 on May 19, 2015, 08:11 pm
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.
Title: Re: Arduino Lightsaber
Post by: android42 on May 27, 2015, 12:42 am
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.
Title: Re: Arduino Lightsaber
Post by: JakeSoft on Jun 09, 2015, 01:19 am
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.
Title: Re: Arduino Lightsaber
Post by: Isaac96 on Jun 12, 2015, 02:27 am
Man, this is great!
How hard would it be to use an accelerometer?
Title: Re: Arduino Lightsaber
Post by: JakeSoft on Jun 13, 2015, 04:57 am
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.
Title: Re: Arduino Lightsaber
Post by: Isaac96 on Jun 13, 2015, 05:39 am
Ok, I will watch for that.  :)
Title: Re: Arduino Lightsaber
Post by: kingale on Jun 27, 2015, 09:55 pm
Quote
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?
Title: Re: Arduino Lightsaber
Post by: JakeSoft on Jun 28, 2015, 06:29 pm
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. ;-)

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:
https://youtu.be/hQnuEHAfUMk
Title: Re: Arduino Lightsaber
Post by: ANDRECHAGAS on Aug 08, 2015, 04:19 am
hello friend, very good your project, like some help because I am doing a similar, would like to contact? andrecruzchagas@gmail.com

thanks
Title: Re: Arduino Lightsaber
Post by: Canobi on Sep 11, 2015, 09:05 pm
-------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.

(http://i1225.photobucket.com/albums/ee395/Can-obi/IMG_20151011_142608.jpg) (http://s1225.photobucket.com/user/Can-obi/media/IMG_20151011_142608.jpg.html)

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.

<edit> 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.


<end>



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.
Title: Re: Arduino Lightsaber
Post by: JakeSoft on Sep 15, 2015, 05:21 am
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!
Title: Re: Arduino Lightsaber
Post by: Canobi on Sep 20, 2015, 10:33 pm
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 :)


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 :)

(http://i1225.photobucket.com/albums/ee395/Can-obi/IMG_20150921_051620.jpg) (http://s1225.photobucket.com/user/Can-obi/media/IMG_20150921_051620.jpg.html)


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.


<edit> making a few more small modifications.......
Title: Re: Arduino Lightsaber
Post by: nphillips on Sep 24, 2015, 04:53 am
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?
Title: Re: Arduino Lightsaber
Post by: llluis on Sep 24, 2015, 06:12 am
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.

Code: [Select]

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);
}
Title: Re: Arduino Lightsaber
Post by: JakeSoft on Oct 03, 2015, 04:43 pm
Here is the code for the One-line serial mode.
Just remember to change de config in the WT588D programmer.

Code: [Select]

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?
Title: Re: Arduino Lightsaber
Post by: JakeSoft on Oct 09, 2015, 02:52 am
Here is the code for the One-line serial mode.
Just remember to change de config in the WT588D programmer.

Code: [Select]

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);
}


I can confirm that this code has the awesome sauce. I tried it out and it worked right away. To improve performance, the last 100ms delay can be reduced to 2ms and it still seems to work just fine.
Title: Re: Arduino Lightsaber
Post by: billpealer on Oct 13, 2015, 03:37 pm
Jake,  your diagram shows the Vcc pins from the sound board and the arduino connected.  yet you have both units receiving raw power as well.  The Ardunio pro mini has an integrated regulator to take up to 12v of unregulated power.  And they recomend to use the Vcc pin only if you have regulated power.  and you do have a v regulator in your specs,  not on the diagram tho.  So,..  What gives?  why connect the Vcc AND the raw inputs?    And also  why short the Vcc's tween the 2 units?  What model N MOSFETs di you use to drive your LEDs?  please and thanks!
Title: Re: Arduino Lightsaber
Post by: purgedsoul on Oct 13, 2015, 05:21 pm
Hi billpealer, the 5V on the RAW pin is powering the Arduino Pro Mini. This then get regulated to 3.3V by the on board regulator. Because of this, VCC acts as an output sourcing 3.3V, which supplies 3.3V to the VCC on the WT588D. VCC on the WT588D powers the flash chip (3.3V) the VDD powers the WT588 chip itself.

(Of course someone can correct me on this.)
Title: Re: Arduino Lightsaber
Post by: JakeSoft on Oct 15, 2015, 12:31 am
Hi billpealer, the 5V on the RAW pin is powering the Arduino Pro Mini. This then get regulated to 3.3V by the on board regulator. Because of this, VCC acts as an output sourcing 3.3V, which supplies 3.3V to the VCC on the WT588D. VCC on the WT588D powers the flash chip (3.3V) the VDD powers the WT588 chip itself.
That's about right. There are many ways to wire this so it'll work, but I did notice that higher voltages on the VDD pin make it louder, so that probably is powering the WT588D chip.
Title: Re: Arduino Lightsaber
Post by: Canobi on Oct 16, 2015, 02:05 pm
It's a bit clunky, but as it's my first schematic, it'll do for now.

I'm also going to make another version and swop out the accelerometer for the one mentioned earlier.
Title: Re: Arduino Lightsaber
Post by: raphax on Oct 16, 2015, 09:44 pm
Hello! Mosfet its only to turn on the Saber LED (Luxeon, cree..) right? Because the arduino output is 500mah and we need more ?

The sensor SW 18020p and SW 200D can be read with arduino right? and sensing to the WT588D chip play a sound ?

Thankyou! Waiting to my order on ebay! :P
Title: Re: Arduino Lightsaber
Post by: Canobi on Oct 17, 2015, 02:52 pm
Hi raphax

I can answer a couple of those.

Yes, the arduino only controls the mosfet gate, the LED is powered directly from the battery.


Clash sensors function in the same way as any pushbutton but have different activation parameters.

Here is some interesting info I found regarding the SW18020p and how it works:

http://www.fx-sabers.com/forum/index.php?topic=27166.0
Title: Re: Arduino Lightsaber
Post by: kingale on Oct 19, 2015, 01:36 am
Have you tried using the accelerometer's  "tap" function with a high threshold instead of the clash sensor?
Title: Re: Arduino Lightsaber
Post by: JakeSoft on Oct 19, 2015, 02:25 am
Have you tried using the accelerator's  "tap" function with a high threshold instead of the clash sensor?
Yeah, I did try something like that. It even worked in so far as it would detect clash events correctly. However, the response time was way too slow. There was noticeable lag between the impact and when the LED would flash and the clash sound would play. Putting a clash sensor on an interrupt is still the easiest way that I've found to get good performance without having to overthink the code too much.

I am running a Pro Mini at 8MHz, though, so maybe the 16 MHz version would close the gap so it wasn't too noticeable. It's also possible that someone may able to come up with code that's better at managing the accelerometer data at a higher rate than mine does; I only poll for data approximately every 10 ms.
You may have better luck, so by all means, go ahead and try it. Let us know how it works out.
Title: Re: Arduino Lightsaber
Post by: kingale on Oct 19, 2015, 02:45 am
Quote
I am running a Pro Mini at 8MHz, though, so maybe the 16 MHz version would close the gap so it wasn't too noticeable. It's also possible that someone may able to come up with code that's better at managing the accelerometer data at a higher rate than mine does; I only poll for data approximately every 10 ms.
You may have better luck, so by all means, go ahead and try it. Let us know how it works out.
I tried using the tap function with the mma845x and a 16Mhz arduino nano. I didn't experience any lag, so you were right. The problem was when i combined the code and tried to use the WT588D in three line mode with the set up. I used an interrupt as an on/off switch but when i turned it on, the accelerometer went crazy and started sending multiple "tap" signals... I also tried to isolate the button and the problem continued. So maybe it's a code issue.

Jakesoft, just another question. I'm having issues getting a background hum to work. I used the repeat mode you shared before in the time loop but still no hum.

Quote
Turn on repeat mode
WT588D_Send_Command(0xF2);

//Begin playlist 0
WT588D_Send_Command(0x00);
Title: Re: Arduino Lightsaber
Post by: JakeSoft on Oct 19, 2015, 03:50 am
I tried using the tap function with the mma845x and a 16Mhz arduino nano. I didn't experience any lag, so you were right. The problem was when i combined the code and tried to use the WT588D in three line mode with the set up. I used an interrupt as an on/off switch but when i turned it on, the accelerometer went crazy and started sending multiple "tap" signals... I also tried to isolate the button and the problem continued. So maybe it's a code issue.

Jakesoft, just another question. I'm having issues getting a background hum to work. I used the repeat mode you shared before in the time loop but still no hum.

Does the hum sound not play at all, or does it just not loop for you?
Title: Re: Arduino Lightsaber
Post by: billpealer on Oct 22, 2015, 04:47 pm
Sure. Here is the most important part of the code from SugarBombs:
(See full code here: http://forum.arduino.cc/index.php?topic=227435.0)


Try putting this somewhere in your code:

Code: [Select]


//Turn on repeat mode
WT588D_Send_Command(0xF2);

//Begin playlist 0
WT588D_Send_Command(0x00);



Of course, make sure the WT588d is configured for 3 line serial mode.
Thanks for the replies on the VCC tie in tween the 2 boards.

I do not understand what pin the above code is referring to ( what pin from the arduino is sending that command to the module?).  I get the F2 command as per the audio modules loop function spec. and the 0x00, must be more or less a reset. Null command. right?  but just putting it into the arduino code is not gonna send it to the audio module?

And unsigned char "i"  is that a playlist from the audio module? this is my first arduino project. thanks for all the photos, code examples, and item names and numbers.  I was over joyed when i had the same button, turn on the led when pressed, then play the blade on sound, and then press the button again, to turn off the led.    I am stuck there, no looping hum, no blade off sound.  But i am waiting for my  swing sensors. and i only have one button.  I was stuck for days with NO action. I realized i had no resistor on the button. I went all the way back and did the simple button tute, then moved on to the debounce button tute. I still don't understand why a switch needs a resistor. must be a proprietary thing for arduino.
Title: Re: Arduino Lightsaber
Post by: JakeSoft on Oct 22, 2015, 07:30 pm
I do not understand what pin the above code is referring to ( what pin from the arduino is sending that command to the module?).  I get the F2 command as per the audio modules loop function spec. and the 0x00, must be more or less a reset. Null command. right?  but just putting it into the arduino code is not gonna send it to the audio module?

And unsigned char "i"  is that a playlist from the audio module? this is my first arduino project. thanks for all the photos, code examples, and item names and numbers.  I was over joyed when i had the same button, turn on the led when pressed, then play the blade on sound, and then press the button again, to turn off the led.    I am stuck there, no looping hum, no blade off sound.  But i am waiting for my  swing sensors. and i only have one button.  I was stuck for days with NO action. I realized i had no resistor on the button. I went all the way back and did the simple button tute, then moved on to the debounce button tute. I still don't understand why a switch needs a resistor. must be a proprietary thing for arduino.
WT588D_Send_Command(0x00) should play a sound. In computer science we often start counting with zero instead of 1. ;-)

You won't need a resistor on your switch if you set the Arduino's internal pull-up resistor in your code.

Code: [Select]

int switchPin = 5;
setup()
{
   pinMode(switchPin, INPUT);
   digitalWrite(switchPin, HIGH);
}

loop()
{
   if(LOW == digitalRead(switchPin))
   {
      //Button is pressed!
   }
   else
   {
      //Button is not pressed.
   }
}


Make sure to wire your switch like this:
[Arduino Pin] ------ [ Switch ] ------- [ Ground ]

I'm glad you are enjoying your project. Keep having fun!
Title: Re: Arduino Lightsaber
Post by: billpealer on Oct 22, 2015, 08:29 pm
wait,.. the "send_command"? it goes out via the data pin? 
Title: Re: Arduino Lightsaber
Post by: billpealer on Oct 22, 2015, 10:41 pm
process of elimination.

#define WT588D_RST 7 //Module pin "REST" or pin # 1
#define WT588D_CS 6 //Module pin "P02" or pin # 11
#define WT588D_SCL 9 //Module pin "P03" or pin # 10
#define WT588D_SDA 8 //Module pin "P01" or pin # 9
#define WT588D_BUSY 10 //Module pin "LED/BUSY" or pin # 15




WT588D_Send_Command(0x00)  .... etc..  MUST be using the Data Pin.

It is the ONLY pin undefined.   it  the H in the F2H must mean "Hex." ...  0xF2

i can't find a single tute that  goes over the "Send_Command" function.. 

wait,..  i's not is it?

there is missing code.

#define WT588D_Send_Command 13 //Data connection tween the cpu and audio mod
Title: Re: Arduino Lightsaber
Post by: kingale on Oct 23, 2015, 01:54 am
 
Quote
Does the hum sound not play at all, or does it just not loop for you?
I hear like multiple taps, so i guess the play function in getting run each loop
Title: Re: Arduino Lightsaber
Post by: JakeSoft on Oct 23, 2015, 02:53 am
process of elimination.

#define WT588D_RST 7 //Module pin "REST" or pin # 1
#define WT588D_CS 6 //Module pin "P02" or pin # 11
#define WT588D_SCL 9 //Module pin "P03" or pin # 10
#define WT588D_SDA 8 //Module pin "P01" or pin # 9
#define WT588D_BUSY 10 //Module pin "LED/BUSY" or pin # 15




WT588D_Send_Command(0x00)  .... etc..  MUST be using the Data Pin.

It is the ONLY pin undefined.   it  the H in the F2H must mean "Hex." ...  0xF2

i can't find a single tute that  goes over the "Send_Command" function..  

wait,..  i's not is it?

there is missing code.

#define WT588D_Send_Command 13 //Data connection tween the cpu and audio mod

Well, I'm not sure what you're getting at. You managed to confuse me. The data pin is defined, It's pin 8. It's WT588D_SDA.

 I think the code you are looking for was linked in the OP, but I'll put it here again. http://forum.arduino.cc/index.php?topic=227435.0 (http://forum.arduino.cc/index.php?topic=227435.0)
Title: Re: Arduino Lightsaber
Post by: billpealer on Oct 23, 2015, 05:43 am
Well, I'm not sure what you're getting at. You managed to confuse me. The data pin is defined, It's pin 8. It's WT588D_SDA.

 I think the code you are looking for was linked in the OP, but I'll put it here again. http://forum.arduino.cc/index.php?topic=227435.0 (http://forum.arduino.cc/index.php?topic=227435.0)

your image on page 1 has data as pin 13,. and pin 9 is.....  Red MOSFET.

just sayin.

had a guy at work tell me any C programming with "_"  in it is a defined name of a proxy.  so WT588D_Send_Command()  is a pin, that would have been defined with all the others. Or,.. it's a statement called up in the Loop function. 

your photo is out of date?

or  what pin do you have the "WT588D_Send_Command()" pushing out of?


my biggest issue with SB's code is...
 void loop()
{

  WT588D_Send_Command(file_count);

  file_count++;  .. etc etc....


"WT588D_Send_Command"  is not mentioned in the WT588D's sample C code for any mode, 1line,3line, or key.    and the name "WT588D_Send_Command"  is not defined anywhere.  Where the heck is this function coming from?.  it is NOT Anywhere  on the internet PERIOD except this very thread and SBs.
Title: Re: Arduino Lightsaber
Post by: billpealer on Oct 23, 2015, 05:59 am
wait,.. 
Arduino is like Chinese.  Backwards. the below code IS the program of "WT588D_Send_Command()"

the void loop calls up "WT588D_Send_Command"  but that function isn't defined till below the function that calls it up.  forgive my logical brain for not realizing computer code is nonlinear and or counter intuitive.

thank god it isn't like cake.  or people would be baking the box of cake at 350 degrees and "enjoying it"  when the last instruction is take the contents out of the bag, and mix with water and oil in large bowl"

is all arduino code bottom up?


From SB
"


void WT588D_Send_Command(unsigned char addr) {

  unsigned char i;

  digitalWrite(WT588D_CS, LOW);

  delay(5); //delay per device specifications

  for( i = 0; i < 8; i++)  {   
    digitalWrite(WT588D_SCL, LOW);   
    if(bitRead(addr, i))digitalWrite(WT588D_SDA, HIGH);
    else digitalWrite(WT588D_SDA, LOW);         
    delay(2);  //delay per device specifications   
    digitalWrite(WT588D_SCL, HIGH);   
    delay(2);  //delay per device specifications
  } //end for

  digitalWrite(WT588D_CS, HIGH);

} //end WT588D_Send_Command
Title: Re: Arduino Lightsaber
Post by: Roibal on Oct 23, 2015, 06:24 am
Awesome, keep up the good work!
Title: Re: Arduino Lightsaber
Post by: grond on Oct 23, 2015, 07:49 pm
perfect work jakeSoft, your my inspiration.i'm new about arduino and these things so is there any chance keep hum sound up while clash or swing sounds playing? i wanna try to do your work with wt588d-u, pro mini 3.3 and gy-521 with single 3.7 18650. i hope its possible to make it.
Title: Re: Arduino Lightsaber
Post by: JakeSoft on Oct 23, 2015, 09:02 pm
perfect work jakeSoft, your my inspiration.i'm new about arduino and these things so is there any chance keep hum sound up while clash or swing sounds playing? i wanna try to do your work with wt588d-u, pro mini 3.3 and gy-521 with single 3.7 18650. i hope its possible to make it.
I don't see why not. I've actually been meaning to try out running with an 18650. You obviously won't have a 5V rail anywhere in your project, but you don't really need one if you use the 3.3V pro mini. I'm not familiar with the gy-521, but if it's a 3.3V device then you'll be fine. The schematic will work out differently, but it should be possible to make something that works with a 3.7V power source. Good luck!
Title: Re: Arduino Lightsaber
Post by: Canobi on Oct 26, 2015, 01:50 pm
I've edited my post (#43) on page 3 to include download links to folders containing the new versions of the PCBs.

I've also amended the system description in the post to reflect the changes I made to the layout designs.
Title: Re: Arduino Lightsaber
Post by: purgedsoul on Oct 27, 2015, 10:20 am
I've edited my post (#43) on page 3 to include download links to folders containing the new versions of the PCBs.

I've also amended the system description in the post to reflect the changes I made to the layout designs.
Thank you for sharing! :)
Title: Re: Arduino Lightsaber
Post by: RTPfan on Oct 28, 2015, 10:14 am
Hi coders and circuit makers,

I am someone else getting a project together.  Everything seems to be progressing well except I am having difficulty with the WT588D chip.

Firstly, in 3 line mode, I do not get the same as the timing diagram in the documentation.

My sound plays fine (and have tested the right ones are being selected using about 140 test sounds).

The documentation ( http://e-radionica.com/productdata/WT588D%20CHIP&MODULE%20DETAILED%20INFORMATION.pdf ) shows the sound (and busy signal) starting after 2 ms and states it happens 2 ms after successful data transmission.  The 2 ms in the diagram is referenced to the data becoming stable and not the rising edge of the last clock.  I would expect it to be referenced the last clock rising edge so this diagram at least seems inaccurate in one respect.

What I get is that sound and busy do not start until 24mS after the rising edge of chip select.  This is reliable and if I delay the CS further it still always happens 24ms after the rising CS!

The documentation may be wrong or this may indicate I am not doing things correctly.

Does anybody else have experience with this or has timed the time until the busy signal?


Secondly with reference to the repeat function.  An example is given where the repeat command is sent before the sound command is started.

The documentation states on page 18 that the repeat command repeats the sound that is currently playing so this example would not be expected to work if the documentation is right.

If I do it as teh documentation suggests then it seems to work; however if I follow the example then it does not work ever.  The only way I could see the example working is if the code was in a loop so that the repeat command was sent again before the sound ended.

Does anyone have any definitive experience of making the repeat command work reliably?

Your experiences/ comments on the above would be appreciated.



Title: Re: Arduino Lightsaber
Post by: Canobi on Oct 28, 2015, 02:20 pm
No problem @purgedsoul, in fact, I have another little goody to share...

I started looking for a simple way to make my blades flicker without having to write code to do it. After stopping to see if 555s running at different frequencies could work, I decided to move on as I wasn't happy with the extra amount of space/routing/complexity they would add to the layout design.

I then hit on an idea and started to look a bit deeper into candle effect flicker LEDs. Turns out you can use em to control the blade LED(s).

To make it work, all you'd have to do is stick a flicker LED in series with the uC's output pin going to the mosfet gate:

(http://i1225.photobucket.com/albums/ee395/Can-obi/IMG_20151028_113533.jpg) (http://s1225.photobucket.com/user/Can-obi/media/IMG_20151028_113533.jpg.html)

The best place to find them is on eBay as most outlets have a min order requirement in the 1000s and I've even found 3mm versions which are ideal for this purpose.

Handily, this youtube vid showes the idea in practice (minus the MCU):

http://youtu.be/753-lkao8l0
Title: Re: Arduino Lightsaber
Post by: billpealer on Oct 28, 2015, 08:32 pm
lil help,. and or who wants to make a weekend's worth of drinkin money?
I have combined Sugar's code with Illuis's Code, (and made the naming consistencies jive)  and as per Jakes's recommendation : "put this SOMEWHERE in your code... " for the sending the HEX code to the WT5xxx..
Created this below.

Code: [Select]

#define WT588D_RST 7 //Module pin "REST" or pin # 1
#define WT588D_CS 6 //Module pin "P02" or pin # 11
#define WT588D_SCL 9 //Module pin "P03" or pin # 10
#define WT588D_SDA 8 //Module pin "P01" or pin # 9
#define WT588D_BUSY 10 //Module pin "LED/BUSY" or pin # 15

byte file_count = 1;

void setup() {

 pinMode(WT588D_RST, OUTPUT);  
 pinMode(WT588D_CS, OUTPUT);
 pinMode(WT588D_SCL, OUTPUT);
 pinMode(WT588D_SDA, OUTPUT);
 pinMode(WT588D_BUSY, INPUT);  

 digitalWrite(WT588D_CS, HIGH);
 digitalWrite(WT588D_RST, HIGH);
 digitalWrite(WT588D_SCL, HIGH);

}


void loop()
{

 //Turn on repeat mode
 WT588D_Send_Command(0xF2);

             //Begin playlist 0
 WT588D_Send_Command(0x00);
 
 WT588D_Send_Command(file_count);

 file_count++;

 if(file_count == 8) file_count = 0;

 delay(50); //give the module time to start playing

 while(digitalRead(WT588D_BUSY) == 0) { }

 delay(200);

}


void WT588D_Send_Command(byte addr) {
   digitalWrite(WT588D_SCL, LOW);
   delay(5);

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

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


It does,. absolutely nothing.  my arduino button press (thanks for the internal resistor code Jake)  turns on my LEDS,..  turns them off too.
plays no sound.  i still do not know how the one button will trigger DATA to go out the SCL pipe,.  nor can i deduce how this code DOES anything.  is there a .H library in play that NO ONE is talkin about?
After reading every post 7 times, spent over 25 hours,..  ergo,.. $1000.00 of man hours..
I am going offer a fire sale for anyone who'd like to buy my sound modules, and 3 arduino boards.
I have 25 hours into this project for the coding alone.  and that's real money and time for naught.

My wt588D works fine in button (key) mode,.  plays all my sounds..     i can not get the arduino to control it.

Who would like to make $100 and send me their working code for 1 line serial mode,..  not the crumbs posted here.  real operational code.  paypal at the ready.
Title: Re: Arduino Lightsaber
Post by: JakeSoft on Oct 29, 2015, 12:56 am
lil help,. and or who wants to make a weekend's worth of drinkin money?

I think I see a few problems with your code, but it's pretty close.

First, if you are using 1 line mode, you don't need WT588D_CS or WT588D_SCL. Get rid of those and the pin assignments. All you need is WT588D_SDA.

You also don't need WT588D_RST. Get rid of it. Don't wire the reset pin on the WT588D to anything either, just make sure that WT588D is programmed with the "pull high resistor" set. Also, of course make sure it's programmed for one-line mode.

Code: [Select]

#define WT588D_SDA 8 //Module pin "P01" or pin # 9
#define WT588D_BUSY 10 //Module pin "LED/BUSY" or pin # 15


Now fix your WT588D_Send_Command() function to use WT588D_SDA instead of WT588D_SCL.

Next, simplify, simplify, simplify. Don't worry about looping and playing multiple files. Just get one file to play and work from there.
Code: [Select]

void loop()
{

  //Begin playlist 0
  WT588D_Send_Command(0x00);

  delay(2000);

}



If I have time I'll try to work up a simple demo and post working code in it's entirety.
Title: Re: Arduino Lightsaber
Post by: JakeSoft on Oct 30, 2015, 01:00 am
Here you go. I took your code and simplified it. The program will play playlist zero every 5 seconds.

Code: [Select]

/***********************************
WT588D One Line Serial Demo

Plays playlist 0 every 5 seconds.

JakeSoft 2015
***********************************/

#define WT588D_SDA 4 //Connect to WT588D Pin #10
#define WT588D_BUSY 7 //Connect to WT588D Pin #15

void WT588D_Send_Command(byte addr) {
    digitalWrite(WT588D_SDA, LOW);
    delay(5);

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

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

void setup() {
  pinMode(WT588D_SDA, OUTPUT);
  pinMode(WT588D_BUSY, INPUT);

  digitalWrite(WT588D_SDA, HIGH);
}

void loop()
{

  //Begin playlist 0
  WT588D_Send_Command(0);
 
  delay(5000);
}


I  used arduino pins 4 and 7, but you can use whatever you want.

One other thing to check for is to make sure that you have the right processor selected in your Arduino IDE. I'm using the 8 Mhz version but it defaults to the 16Mhz version of you just select "Pro or ProMini" from the board menu. If you have the wrong processor selected then your timings will all be off and it won't work.

Title: Re: Arduino Lightsaber
Post by: JakeSoft on Oct 30, 2015, 02:37 am
Firstly, in 3 line mode, I do not get the same as the timing diagram in the documentation.

My sound plays fine (and have tested the right ones are being selected using about 140 test sounds).

The documentation ( http://e-radionica.com/productdata/WT588D%20CHIP&MODULE%20DETAILED%20INFORMATION.pdf ) shows the sound (and busy signal) starting after 2 ms and states it happens 2 ms after successful data transmission.  The 2 ms in the diagram is referenced to the data becoming stable and not the rising edge of the last clock.  I would expect it to be referenced the last clock rising edge so this diagram at least seems inaccurate in one respect.

What I get is that sound and busy do not start until 24mS after the rising edge of chip select.  This is reliable and if I delay the CS further it still always happens 24ms after the rising CS!

The documentation may be wrong or this may indicate I am not doing things correctly.

Does anybody else have experience with this or has timed the time until the busy signal?
Yeah, the documentation is overly optomistic about the response times on the busy signal. I see this also; you are probably not doing anything wrong. Sometimes I'll see delays of up to 50 ms before the busy signal registers! 2ms? I have never observed it being that fast. The sound might actually start playing within that time, but the busy pin won't rise or fall that fast.


Secondly with reference to the repeat function.  An example is given where the repeat command is sent before the sound command is started.

The documentation states on page 18 that the repeat command repeats the sound that is currently playing so this example would not be expected to work if the documentation is right.

If I do it as teh documentation suggests then it seems to work; however if I follow the example then it does not work ever.  The only way I could see the example working is if the code was in a loop so that the repeat command was sent again before the sound ended.


Does anyone have any definitive experience of making the repeat command work reliably?

Your experiences/ comments on the above would be appreciated.
The documentation is right in this case. The code I posted before would only work for the reason you stated; if it's in a loop. To get repeat to work, you do have to send the repeat command immediately after you send the command to start playing a sound. I'm sorry I messed this up earlier, but I played with it tonight and it seems to work pretty well if you code it like this:

Code: [Select]

WT588D_Send_Command(0); //Play sound 0
WT588D_Send_Command(0xF2); //Repeat sound


However, the next time you send a command to play a sound, it'll play normally one time through unless you again send the 0xF2 command to make it loop. I mistakenly thought this was a toggle type function to turn looping on and off, but it's not apparently. It only applies to whatever is playing at the time you sent the loop command. I hope that helps.
Title: Re: Arduino Lightsaber
Post by: Canobi on Oct 30, 2015, 11:51 am
Thanks for all the tips and help your giving us @JakeSoft :)


One thing I need some clarification on is pin output voltages.

If an arduino is running at 5v, does it output 5v to its pins (assuming they're set to output).

I'd like to run the flicker LED from pin 5 so will need to add a resistor for it if it does.
Title: Re: Arduino Lightsaber
Post by: RTPfan on Oct 30, 2015, 04:01 pm
Hi Jakesoft,

Thanks for the reply about the delay.  I suspected the timing diagram was wrong.  Interestingly I only get 24mS and haven't seen longer delays but I will look out for that.

Thanks for clarifying about the repeat function.

Have you found it to be reliable?  The reason I ask is that I have two parts of my code that repeat the idle hum sound.  One when it goes from powerup to idle.  The second when it goes to clash and then drops back to idle.

The first one works fine.  The second one does not repeat yet the code is identical!  I started to wonder if it was a toggle (so first turned it on and second was turning off) hence the reason for my question. But you confirming that I need to issue the repeat command during playback of the sound I want repeated means no toggle.

Now I am wondering if I have a longer delay sometimes so the repeat is issued before the sound has started playing so the repeat command is not enabled.



Hi Canobi,

With respect to your flickering circuit.  Looking at it you may have trouble with the MOSFET.  The VGSon may not be satisfied and it may not turn on properly or at all.  That may be helped by having the resistor and the LED both on the drain side. You still could have a voltage drop across the flicker LED that might make still cause grief.

In any case, while the flickering LED is an ingenious idea, I would suggest it is better to do it in the software.  It gives you more flexibility as having it done in hardware locks you in to it always flickering the way the chip wants.

Related to that, has anyone tried these to drive the LEDs? ( http://www.ebay.com/itm/161807194247 )
You can parallel them (two for 700mA) and they are more efficient than a resistor MOSFET combination.  They are specifically designed for driving LEDs from an 18650 working efficiently to hold brightness as the voltage drops from a fully charged 4.2V.  Nice and small space saving solution.  I understand that you just need to PWM the power pin directly from a port pin.  Mine have just arrived and I am yet to try them.





Title: Re: Arduino Lightsaber
Post by: JakeSoft on Oct 31, 2015, 01:26 am
Thanks for all the tips and help your giving us @JakeSoft :)


One thing I need some clarification on is pin output voltages.

If an arduino is running at 5v, does it output 5v to its pins (assuming they're set to output).

I'd like to run the flicker LED from pin 5 so will need to add a resistor for it if it does.

No problem. I just hope I get to see some YouTube videos of all of your creations. I'll consider that a fine reward. :-)

I'm not sure how you're planning to run it, but if you're doing the standard Luxeon/Cree high-powered LED route, you won't power that directly from an Arduino pin anyway. Not enough current will be available to drive the LED. You'll need a MOSFET or a PEX from TCSS.
Title: Re: Arduino Lightsaber
Post by: Canobi on Oct 31, 2015, 01:43 am
Ah well, PWM it is then. Thanks for the info RTPfan.


@JakeSoft

Was inquiring about voltages for the flicker LED, the blade LED is powered directly from the battery.
Title: Re: Arduino Lightsaber
Post by: billpealer on Oct 31, 2015, 04:52 am
finally. i had like 2 a ha moment.  one is,. that i HATE coding,..  i thought Flash Action script and MEL was bad,..  I get an F- i C++
But, alas,..  my parents said i can do anything,. and my 5 year old pat me on the back last night and siad,. "But Dad, you told me Pealer's never give up."
i cracked it.

i dont know how i did it,.  but i turned the sound module 180 degrees when moving it from one bread board to another.  looked good on the board,.  100%  broken. Do'h!

Illuis's code used a different SCL naming convention, that i did not catch,..  arduino did tho.

this works,..    anyone can use it,..  make sure you configure the sound uploading module to  edge trigger.

videos to come...  if you don't know how to make buttons trigger functions,..   billpealer at yahoo dont com.  either way i will upload the final,.the updated button code,.. the line diagram, and full video in 2-3 weeks.     i also want to add, that a $15 sound module in a star wars walmart light saber is dang near the same thing as this...  just add the mosfet/2w LED and better 2w speaker to that and the Custom Saber Shop Sabers are good to go.

Code: [Select]
#define WT588D_SCL 9 //Module pin "P03" or pin # 10
#define WT588D_BUSY 10 //Module pin "LED/BUSY" or pin # 15

byte file_count = 1;

void setup() {

 
 pinMode(WT588D_SCL, OUTPUT);  
 pinMode(WT588D_BUSY, INPUT);  
 

}


void loop()
{
 WT588D_Send_Command(0x02);  //blade on with looped hum for 80 seconds. if you dont swing for 80 seconds, why is it on?
 delay(1500); //delay for testing  waiting for buttons from china.

 WT588D_Send_Command(0x01); //swing sound with 80 seconds of hum
 delay(1000);
 WT588D_Send_Command(0x01); //one more swing sound 'cause it sounds cool
 delay(1000);
 WT588D_Send_Command(0x00); //powerdown sound, no hum loop. der.. its off.
 delay(4500);

 delay(200);

}


void WT588D_Send_Command(byte addr) {
   digitalWrite(WT588D_SCL, LOW);
   delay(5);

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

   digitalWrite(WT588D_SCL, HIGH);
   delay(100);
} //END
Title: Re: Arduino Lightsaber
Post by: billpealer on Oct 31, 2015, 05:11 am
I still don't know how Sugarbombs and Illuis got what they got,.. when the documentation of the Wt588Du has this to say about one/three line serial C code.

Code: [Select]
Send_oneline(unsigned char addr)
{      unsigned char i;      SDA=0;      
delay1ms(5);         /* delay 5ms */      
for(i=0;i<8;i++)          {SDA=1;          
if(addr & 1)             {delay100us(6);      
/* 600us */              SDA=0;            
delay100us(2);       /* 200us */        }              
else {              delay100us(2);     /* 200us */            
SDA=0;              delay100us(6);       /* 600us */  }    
addr>>=1;

}           SDA=1; }



they took the above and translated it into,..

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);
}


WHAT THE @#$%^

is the an online gibberish translator you guys are holding out on here?
Title: Re: Arduino Lightsaber
Post by: RTPfan on Oct 31, 2015, 08:49 am
@Canobi

An arduino output should be able to drive a flicker LED.  I would imagine it would be < 20ma but you should look on the LED data sheet.

A problem may be that the MOSFET gate is a voltage driven element and there may be insufficient current to operate.  You make be relying on leakage currents.

I would guess you would might need a (1K??) resistor between the gate and the source (ie to Vbat) of the (P channel??) MOSFET.  Then reverse the flicker LED and drive it active low.

Whether this might work depends upon a couple of things like the voltage drop of the flicker LED, value of VBat and VGSon for the MOSFET.  You haven't given that information so it is hard to say .......

Still if it works well as you have it drawn then the answer is that, subject to the flicker LED data sheet that the current is <20ma an arduino pin should be fine.


Title: Re: Arduino Lightsaber
Post by: Canobi on Oct 31, 2015, 12:59 pm
Ah yes, sorry about the lack of info, it's a slight failing of mine so I'll shed some light on things.

The mosfet is an FDN327N which is rated for 2A. The gate threshold is .4v ~ 1.5v (max saturation is 8v) and according to the datasheet it only draws 250uA. This last bit might be a misunderstanding on my part, but that was all I could find regarding how much current the gate sources.

The flicker LEDs I went for are the red ones which have a Vf of 2.2v @25mA. I chose them as they had the closest working Vf to the gate threshold.

My thoery is that since the arduino is 5v and the pins sink 20mA it should work as I'd only need to drop a few Vs for the LED and it would pass enough current through to the gate for it to operate.

I have a bunch of those fets so I can use one as a guinea pig to test the theory out when the flicker LEDs arrive.

I can also use the experiment to help nail the pad design for the LED as I need to turn it into an SMT component. It'll sit right under the arduino so it can't go through hole like it was meant to and necessity is the mother of invention as they say.....
Title: Re: Arduino Lightsaber
Post by: Canobi on Oct 31, 2015, 02:55 pm
It has occured to me that the flickering will effect the fade in/out function, which just wouldn't look right.

My first thought on how to get round this problem is to use a second pin that bypasses the flicker LED:

(http://i1225.photobucket.com/albums/ee395/Can-obi/IMG_20151029_123836.jpg) (http://s1225.photobucket.com/user/Can-obi/media/IMG_20151029_123836.jpg.html)

All well and good, but how does one name a second led pin when declaring its function?

For the flicker LED I have:

int ledPin = 5;     // flicker led to mosfet gate


Is it as simple as naming another pin as a led pin (eg.  int ledPin = 6; )and then just call that number when it's wanted?
Title: Re: Arduino Lightsaber
Post by: billpealer on Nov 02, 2015, 09:36 pm
I just read the comments.  And did my best to digest them.  Thanks JakeSoft. I don't think in code. as it probably is clear.
I am having replay stutter.  I think it is because the button playback is in void loop and it is cycling like mad.

I do have 2.2 questions?

I do not have this in my code "digitalWrite(WT588D_SCL, HIGH);"

1a. does it matter what pin number i use on the arduino for the SDA / SCL pin? and the comment that the "WT588D_SCL" need be changed to "...SDA" in my code?  I don't have SCL set to HIGH in the setup. As is your SDA. and Illuis's code uses SCL as a name, you use SDA,..  would a rose by any other name, not smell as sweet?  So it is not a critical change, just for standard naming right? i like to use the word button, i see a lot of "switchPin" in code or outPin, where as i use "LED".

If i need pinMode(WT588D_SCL, HIGH); in set up,..
1b. Why?

Code: [Select]


//my code
#define LED 13
#define LED2 12
#define WT588D_SCL 9 //Module pin "P03" or pin # 10
#define WT588D_BUSY 10 //Module pin "LED/BUSY" or pin # 15
#define button 7             //the on-off button
byte file_count = 1;

void setup() {

 
pinMode(WT588D_SCL, OUTPUT);  
pinMode(WT588D_BUSY, INPUT);
pinMode (button, INPUT_PULLUP);


}
// end my code


when i run a void loop with the WT588d's function

example: all the above plus this below.

void loop()
{
WT588D_Send_Command(0x02);
delay (1234);
}

it plays, and delays. and repeats.



also,
when i use a standard button command.
void loop()
{
if(button == HIGH)
{WT588D_Send_Command(0x02);  //blade on

}  //end


It works when i press the button, but just plays rapidly. it is akin to me rapid tapping the button if it was in key mode.   But i only hit the toggle button once. I know it is cycling thru the void loop.  If i use the switch Boolean code,. it wouldn't let me treat the send_command as it does an LED state.
Code: [Select]
// Boolean
void loop()
{
reading = digitalRead(button);

// if the input just went from LOW and HIGH and we've waited long enough
// to ignore any noise on the circuit, toggle the output pin and remember
// the time
if (reading == HIGH && previous == LOW && millis() - time > debounce) {
  if (state == HIGH)
    state = LOW;
  else
    state = HIGH;

  time = millis();    
}

digitalWrite(LED, state); // turns off LED2, and on LED pin 13 and signal to mosfet

digitalWrite(LED2, !state);  // turns off LED and on LED pin 12 just to show the toggle works

previous = reading;

if (state)
WT588D_Send_Command(0x02); // on sound
else (!state)
WT588D_Send_Command(0x00); // off sound
}
}  //end


i can make buttons trigger LED pins using the Boolean and debounce, but i can't seem to ge tit to jive with making a button trigger the statement or function of what ever the thing is that "WT588D_Send_Command(0x02);" is.   i was under the impression that it was a function, but after hours of reading and now dreaming in gibberish arduino code,  i am now leaning toward that it is a statement.

googling "buttons run functions or statements arduino"

has born no fruit.  gets me to the same 3 tutes  that do not apply to this.
Title: Re: Arduino Lightsaber
Post by: JakeSoft on Nov 03, 2015, 03:32 am
I do not have this in my code "digitalWrite(WT588D_SCL, HIGH);"

1a. does it matter what pin number i use on the arduino for the SDA / SCL pin? and the comment that the "WT588D_SCL" need be changed to "...SDA" in my code?  I don't have SCL set to HIGH in the setup. As is your SDA. and Illuis's code uses SCL as a name, you use SDA,..  would a rose by any other name, not smell as sweet?  So it is not a critical change, just for standard naming right? i like to use the word button, i see a lot of "switchPin" in code or outPin, where as i use "LED".
The name change is not critical, it's just that it's generally a good idea to name variables something meaningful that reflects what the really are. As your projects start to grow in complexity this becomes important otherwise it's hard to understand what is going on when you read your code and especially difficult for anyone else to understand. That makes it hard for anyone to help you. For example, if I had a motor wired to open a door on pin 5, what makes more sense "DoorMotorPin" or "WindowArmPit"?

SCL means "serial clock" in 3-line serial mode however it has no meaning in one-line serial mode for the WT588D. The SDA is "serial data", which is what the pin is really doing.

It doesn't matter what Arduino pin you use for SDA so long as the other end is plugged into the right pin on the WT588D module.

If i need pinMode(WT588D_SCL, HIGH); in set up,..
1b. Why?
This guarantees that the pin is an a known state when the loop starts. 
Title: Re: Arduino Lightsaber
Post by: billpealer on Nov 03, 2015, 06:56 am
youtube video on its way.  i am in better shape than yesterday.  i know i am still doing it wrong.
https://www.youtube.com/watch?v=A6grN9m3EJ4 (https://www.youtube.com/watch?v=A6grN9m3EJ4)

anyone have some insight on how to make the sounds trigger with buttons and not sound like max headrom, or act wonky?

Also, there needs to be a way that after the main and only button is pressed the second time, it locks up the sound module, so the swing and clash buttons don't trigger their noises.  I am not there yet in my code.

maybe have the arduino get a feedback loop from the LED pin,  if the LED pin is LOW, send the Stop Command(0xFE)

if (digitalRead(LED == LOW) {
WT588D_Send_Command(0xFE)
}
{
else
}

that's wrong im sure.,

tonight's flavor

Code: [Select]
#define WT588D_SDA 9 //Module pin "P03" or pin # 10
#define WT588D_BUSY 10 //Module pin "LED/BUSY" or pin # 15
int LED = 13;
int LEDa = 12;
int button = 2;         // the button
int state = LOW;      // the current state of the output pin
int reading;           // the current reading from the input pin
int previous = HIGH;    // the previous reading from the input pin
byte file_count = 1;
long time = 0;         // the last time the output pin was toggled
long debounce = 100;   // the debounce time, increase if the output flickers


void setup() {

  
  pinMode(WT588D_SDA, OUTPUT);  
  pinMode(WT588D_BUSY, INPUT);  
  pinMode(button, INPUT_PULLUP);
  pinMode(LED, OUTPUT);
  pinMode(LEDa, OUTPUT);
  digitalWrite(button, HIGH);
  
  digitalWrite(WT588D_SDA, HIGH);

 
}

void loop()
{
    reading = digitalRead(button);
    digitalWrite(WT588D_SDA, HIGH);
    

  // if the input just went from LOW and HIGH and we've waited long enough
  // to ignore any noise on the circuit, toggle the output pin and remember
  // the time
  if (reading == HIGH && previous == LOW && millis() - time > debounce) {
    if (state == HIGH)
      state = LOW;
  else
      state = HIGH;
      WT588D_Send_Command(0x02); //on sound
      delay(5);
      digitalWrite(WT588D_SDA, LOW);
    
      time = millis();    
  }
 digitalWrite(LED, state);
 digitalWrite(LEDa, !state);

if (reading == LOW && previous == HIGH && millis() - time > debounce) {
    if (state == HIGH)
    
      state = LOW;
  else
      state = HIGH;
     WT588D_Send_Command(0x00);
      time = millis();    
}
previous = reading;
}
void WT588D_Send_Command(byte addr) {
    digitalWrite(WT588D_SDA, LOW);
    delay(5);

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

    digitalWrite(WT588D_SDA, HIGH);
    delay(100);
} //end WT588D_Send_Command
Title: Re: Arduino Lightsaber
Post by: JakeSoft on Nov 04, 2015, 04:36 am
youtube video on its way.  i am in better shape than yesterday.  i know i am still doing it wrong.
https://www.youtube.com/watch?v=A6grN9m3EJ4 (https://www.youtube.com/watch?v=A6grN9m3EJ4)

anyone have some insight on how to make the sounds trigger with buttons and not sound like max headrom, or act wonky?

Also, there needs to be a way that after the main and only button is pressed the second time, it locks up the sound module, so the swing and clash buttons don't trigger their noises.  I am not there yet in my code.

maybe have the arduino get a feedback loop from the LED pin,  if the LED pin is LOW, send the Stop Command(0xFE)

if (digitalRead(LED == LOW) {
WT588D_Send_Command(0xFE)
}
{
else
}

that's wrong im sure.,

tonight's flavor

Code: [Select]
#define WT588D_SDA 9 //Module pin "P03" or pin # 10
#define WT588D_BUSY 10 //Module pin "LED/BUSY" or pin # 15
int LED = 13;
int LEDa = 12;
int button = 2;         // the button
int state = LOW;      // the current state of the output pin
int reading;           // the current reading from the input pin
int previous = HIGH;    // the previous reading from the input pin
byte file_count = 1;
long time = 0;         // the last time the output pin was toggled
long debounce = 100;   // the debounce time, increase if the output flickers


void setup() {

   
  pinMode(WT588D_SDA, OUTPUT); 
  pinMode(WT588D_BUSY, INPUT); 
  pinMode(button, INPUT_PULLUP);
  pinMode(LED, OUTPUT);
  pinMode(LEDa, OUTPUT);
  digitalWrite(button, HIGH);
 
  digitalWrite(WT588D_SDA, HIGH);

 
}

void loop()
{
    reading = digitalRead(button);
    digitalWrite(WT588D_SDA, HIGH);
   

  // if the input just went from LOW and HIGH and we've waited long enough
  // to ignore any noise on the circuit, toggle the output pin and remember
  // the time
  if (reading == HIGH && previous == LOW && millis() - time > debounce) {
    if (state == HIGH)
      state = LOW;
  else
      state = HIGH;
      WT588D_Send_Command(0x02); //on sound
      delay(5);
      digitalWrite(WT588D_SDA, LOW);
     
      time = millis();   
  }
 digitalWrite(LED, state);
 digitalWrite(LEDa, !state);

if (reading == LOW && previous == HIGH && millis() - time > debounce) {
    if (state == HIGH)
   
      state = LOW;
  else
      state = HIGH;
     WT588D_Send_Command(0x00);
      time = millis();   
}
previous = reading;
}
void WT588D_Send_Command(byte addr) {
    digitalWrite(WT588D_SDA, LOW);
    delay(5);

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

    digitalWrite(WT588D_SDA, HIGH);
    delay(100);
} //end WT588D_Send_Command

Finally, somebody posts a video! Thank you, Bill!

I took a look at your code. You aren't terribly far off. Believe it or not, I think you have too much code.

1. All of that stuff you are doing with millis() to try and debounce the button signal is not necessary. The cheap and dirty way to avoid all of that is to simply add 20 or 30 ms delay in your loop() function. That way, the button is only read every 20 milliseconds or so and jittery signal should be mitigated.

2. Add a global bool variable to keep track of your lightsaber state.
Code: [Select]

bool saber_is_on;
...
setup()
{
...
saber_is_on = false;
...
}


3. Then make your loop() function look something like this:
Code: [Select]

loop()
{
   if(digitalRead(button) == LOW) //button is pressed
   {
      if(saber_is_on) //Saber is on, so turn it off
      {
         //ADD CODE HERE TO TURN OFF THE LED AND PLAY OFF SOUND
         saber_is_on = false;
      }
      else //Saber is off, so turn it on
      {
         //ADD CODE HERE TO TURN ON LED AND PLAY ON SOUND
         saber_is_on = true;
      }
   }
}


4. Take out those digitalWrite(WT588D_SDA...) lines in your loop() function. You don't need those there; they aren't doing anything useful.
Title: Re: Arduino Lightsaber
Post by: billpealer on Nov 04, 2015, 06:02 am
i'll give it a try.  can i rinse and repeat and do that for the swing sensor too?  a different bool?

bool saber_is_on;  ?

er...

does that go in the

int bool saber_is_on;     portion above setup?


and why the 3 closed curly brackets?  i see that from time to time, not quite sure wtf that is all about.
     }
  }
}
Title: Re: Arduino Lightsaber
Post by: JakeSoft on Nov 04, 2015, 01:53 pm
i'll give it a try.  can i rinse and repeat and do that for the swing sensor too?  a different bool?

bool saber_is_on;  ?

er...

does that go in the

int bool saber_is_on;     portion above setup?
The "bool" key word declares a variable that can only have two values: "true" and "false". It's just like when you are declaring "int" variables that can hold integer values. In this case, you just want to know if the saber is on or not, so that can be used to keep track of it.

If that's too confusing, you can use "int" instead and just use the values 0 and 1 to mean false and true and do checks on that.

and why the 3 closed curly brackets?  i see that from time to time, not quite sure wtf that is all about.
     }
  }
}
That has to do with defining blocks of code. For each "{", there must be a corresponding "}". This pattern is used all over the place in C and C++. For example, your if blocks will look like this:

if(saber_is_on)
{
   //DO SOMETHING HERE
   //DO SOMETHING ELSE HERE
   //CODE, CODE, AND MORE CODE, etc.
}

But what if you want to check something else before you worry about if the saber is on? Well, then you'd create another if block around your first block. This is called "nesting", meaning one block is contained within another.

if(button_is_pressed)
{
   if(saber_is_on)
   {
      //DO SOMETHING HERE
      //DO SOMETHING ELSE HERE
      //CODE, CODE, AND MORE CODE, etc.
   } //This ends the saber_is_on list of actions
} //This ends the button_is_pressed list of actions

The "{" brackets allow you to define a list of actions to be performed without having to do the check again. The language lets you get away with not using them in the case that you only have one action to perform, but I always use the brackets even then because it makes the code more readable.
Title: Re: Arduino Lightsaber
Post by: Niarue on Nov 04, 2015, 04:56 pm
Hi,

First of all thank you so much for share this project with us.

I want to do this projet and replace the speaker by a bluetooth shield (HM-10)

I used 1x Arduino pro mini 3.3V-8mHz // 1x WT588D // 3x N-Channel MOSFET 60V 30A // 1x Voltage Regulator - 5V // 1x SW18020P // 1x SW200D // 1x 9W high power LED RGB // 1 Module bluetooth Hm-10

I have a problem with the sound module, I use PL2303HX Convertisseur USB à TTL for programming the WT588D. He doesn't work and i don't know why ( i'm a begginer but i learn quickly ^^ )

https://drive.google.com/file/d/0B4G7p1vQyogjQWtiUk5RS21vcTg/view?usp=sharing
( that is the downloader and the wt588d )

I you can help me that will be great and after I'll share my code. I think the sound would be better with an home cinema or something like that.

 
Title: Re: Arduino Lightsaber
Post by: Canobi on Nov 04, 2015, 06:20 pm
Hi Niarue

There are actually three types of WT module:

WT588D-16p (16 pin with a basic set of trigger pins)

WT588D-28p (28 pin with expanded trigger pin set and matrix capability)

WT588D-U (28 pin with same specs as above but includes an on board programmer circuit and USB port).

The first two need a separate programmer board to install the sounds and change the internal settings.

The prices can vary a bit depending on which site/distributer your looking at so have a look around.

I got mine on ebay, though I've seen them other places too.
Title: Re: Arduino Lightsaber
Post by: billpealer on Nov 04, 2015, 07:30 pm
the WT588D setterupper thing you should be using is this guy.  all the youtube posts and stuff use this model.

http://www.ebay.com/itm/1PC-WT588D-USB-Sound-Module-Programmer-Downloader-Testing-Board-Tester-/261748549043?hash=item3cf16de5b3:g:rnYAAOSwm8VUxf33

i would just go with the USB version of the chip. I am a complete noob and i figured it out.  it is 2cm longer, but only $2 more than the non usb version.  Save a ton of time, you can leave the module in the bread board and wired the whole time instead of taking it out of the programmer everytime (just make sure to disconnect the power of the arduino before you replug in the USB for the sound doo-dad. and unless you plan to be making a dozen of these things,.  the $12 cost of the programmer just aint worth it.
Title: Re: Arduino Lightsaber
Post by: JakeSoft on Nov 04, 2015, 08:44 pm
I'll echo what the others have said. If you can make an extra inch of room in your saber then the WT588D-U is much easier to work with. Otherwise, the only way I know to program them is to buy the $15 programmer from Ebay or an electronics supply site.

In my YouTube videos I showcase the 16-pin version, but when I'm doing development work on my bread I often use a WT588D-U with USB built in just because it's so much easier. When you are operating in serial mode, the 16 and 28 pin versions should all work exactly the same.
Title: Re: Arduino Lightsaber
Post by: billpealer on Nov 05, 2015, 06:54 am
Changes made
made some real ground tonight.
i'm tired.

https://youtu.be/c2b59vya0LI (https://youtu.be/c2b59vya0LI)
Title: Re: Arduino Lightsaber
Post by: Niarue on Nov 05, 2015, 09:53 am
Ok Thank you for your time everyone.

I already buy the programmer on your video jakesoft, I leave in france and the time of shipment is verrrry

looong ahah. So I try to use this usb converter.

I think I'll try to work on the program for the LED wile the programmer come.
Title: Re: Arduino Lightsaber
Post by: JakeSoft on Nov 06, 2015, 04:49 am
Changes made
made some real ground tonight.
i'm tired.

https://youtu.be/c2b59vya0LI (https://youtu.be/c2b59vya0LI)
It's looking pretty good!

I chuckled a little bit at the on-the-fly code updates during your demo. Sometimes stuff like that happens to me when I'm filming my videos, but I usually just take a cut and start over. If it works right the first time, you didn't learn anything, right? lol

Anyway, I think the issue with your swing sounds repeating is fixable. When I wrote my Mk. II code I had to write it such that the swing sound would only trigger if the state changed. You had some code that was kind of doing something like that before. Each cycle you just keep track of what the last state was and if it's not the same, then do the swing sound. Otherwise, do nothing.

Code: [Select]

int last_swing_state;

loop()
{
   
   int current_swing_state = digitalRead(swingSensorPin);

   if(current_swing_state != last_swing_state)
   {
      //PLAY A SWING SOUND HERE
   }

   //Save the current swing state for comparison in the next cycle
   last_swing_state = current_swing_state;
   
}


That should do it.

I'm liking your MHS hilts, BTW. I'm looking forward to seeing them all lit up.

Title: Re: Arduino Lightsaber
Post by: purgedsoul on Nov 06, 2015, 08:58 am
For those who have no WT588D programmer I finally got to upload audio to the board using only the Arduino and processing. This is based on AdaFruit's audio transfer code for the Trinket. Link to the code can be found on this thread:

http://forum.arduino.cc/index.php?topic=227435.msg2466463#msg2466463 (http://forum.arduino.cc/index.php?topic=227435.msg2466463#msg2466463)

USE AT YOUR OWN RISK

For JakeSoft here's a youtube vid for you :-)

https://youtu.be/EKgHZP4UJjs (https://youtu.be/EKgHZP4UJjs)

With lightsaber sounds loaded. Still needs to work on my button/sensor codes.

https://youtu.be/S7qEvnJbOLg (https://youtu.be/S7qEvnJbOLg)
Title: Re: Arduino Lightsaber
Post by: purgedsoul on Nov 06, 2015, 01:35 pm
Question: Do we need to issue a stop command (0xFE) before we play another audio group?
Title: Re: Arduino Lightsaber
Post by: billpealer on Nov 06, 2015, 05:19 pm
Question: Do we need to issue a stop command (0xFE) before we play another audio group?
No. Just make sure the WT is set to edge retrigger.  i suggest a delay(100);  after every WT_send_command(0x..)


Update:
I disconnected the Busy pin from the arduino to the WT and everything still works.
Frees up an arduino pin too.

and

Jake, I'll give that a try.

I over came the swing repeat with the standard debounce code.

Code: [Select]


int SW_sensor = 9  //sensor button pin
long time = 0  //time of nothing
long debounce = 200 //200ms is the margin of error to determine a press, hold, or rapid press
bool swing_sound

setup
digitalWtite(SW_sensor,HIGH);
swing_sound = false;

void loop()
{

  // if the swing sensor was toggled and not just held at a state for less than 200ms
 
 if (digitalRead(SW_sensor) == HIGH && digitalRead(SW_sensor) == LOW && millis() - time > debounce) {
   
if (swing_sound)

  // do nothing.  get coffee but be back in 100 ms
     delay(100);
   
 else
      WT_send_command(1); // swing sound
      delay(100);

    time = millis();   
  }
}

Title: Re: Arduino Lightsaber
Post by: JakeSoft on Nov 06, 2015, 11:14 pm
No. Just make sure the WT is set to edge retrigger.  i suggest a delay(100);  after every WT_send_command(0x..)


Update:
I disconnected the Busy pin from the arduino to the WT and everything still works.
Frees up an arduino pin too.

and

Jake, I'll give that a try.

I over came the swing repeat with the standard debounce code.

Code: [Select]


int SW_sensor = 9  //sensor button pin
long time = 0  //time of nothing
long debounce = 200 //200ms is the margin of error to determine a press, hold, or rapid press
bool swing_sound

setup
digitalWtite(SW_sensor,HIGH);
swing_sound = false;

void loop()
{

  // if the swing sensor was toggled and not just held at a state for less than 200ms
 
 if (digitalRead(SW_sensor) == HIGH && digitalRead(SW_sensor) == LOW && millis() - time > debounce) {
   
if (swing_sound)

  // do nothing.  get coffee but be back in 100 ms
     delay(100);
   
 else
      WT_send_command(1); // swing sound
      delay(100);

    time = millis();   
  }
}


Look at you, Bill: Answering questions complete with sample code!

"Indeed, you are powerful" --Darth Vader

Good for you!
"Pass on what you have learned" --Yoda

...I should stop now, huh? :-)
Title: Re: Arduino Lightsaber
Post by: Balaclava on Nov 08, 2015, 03:28 am
did anybody acomplished a more "stable" or "simple" solution?

IF so

any hope for a collection of information for the NOOBs (aka ME, i dont code nor have eletronics knowledge?)


i ask cause this is the closest Open source solution for the sound card component of lightsabers.

i REALLY do not have the money for proprietary cards, but i do have the passion to work the kinks of assembling the eletronic components of an open source solution.


im new to the scene (you could tell huh?)





Title: Re: Arduino Lightsaber
Post by: iamearlgrey on Nov 08, 2015, 05:13 am
Ok, so I was originally just going to make a stunt saber from pvc. Who needs all that fancy audio? Then I saw that the new hasbro toy sabers have a similar board to the 2010 models. Ok, maybe for $15 that might be worth a play. But now, seeing what you have done with the arduino, I really wanna a make that. I am pretty overwhelmed by what is involved though. My only experience with arduino is buying pre-built boards to run multiwii for multi rotors, which I first decided on because of the open source/community behind it. I've uploaded sketches and messed with parameters, but nothing like what you've done here. I plan to get a pro mini and sound board and mess with it, but what you have in your Mk II seems perfect to me. I can figure out the led fade easily enough and probably triggering the audio, but how you scroll through options and change colors is beyond me at the moment. For the moment, I am better at dremelling pvc to make a hilt than writing arduino code.
Title: Re: Arduino Lightsaber
Post by: Ibrene on Nov 09, 2015, 02:44 am
I'm in the same boat. I'm fascinated by what the Arduino is capable of, but can't code. However, I'm pretty handy with a recipe, so once somebody posts a step by step guide... I'm all in.
Title: Re: Arduino Lightsaber
Post by: iamearlgrey on Nov 09, 2015, 04:09 am
I've come to a new hurdle in my saber smithing adventure. While researching components, I realized that to upload the audio files to the wt588 you need pc software while I am on a mac. Yes, I could use some virtualization, but I was hoping for a more native or cross platform solution and I don't want to buy software for a one time use. Are there any mac compatible sound modules out there that would work like the wt588?
Title: Re: Arduino Lightsaber
Post by: nom_smile on Nov 09, 2015, 07:38 pm
Maybe this will help?

https://www.arduino.cc/en/Main/Software


Title: Re: Arduino Lightsaber
Post by: billpealer on Nov 09, 2015, 07:54 pm
Look at you, Bill: Answering questions complete with sample code!

"Indeed, you are powerful" --Darth Vader

Good for you!
"Pass on what you have learned" --Yoda

...I should stop now, huh? :-)

thanks.
i have a code mechanics question...
Why do i need the saber_is_on (or any bool statement)  to be set to false in the setup,..  when i am declaring it false after the if statement?

example:
bool saber_on
void setup
saber_on =  false;
void loop
{
  if(digitalRead(button) == LOW) //button is pressed
  {
     if(saber_on) //Saber is on, so turn it off
     {
        //ADD CODE HERE TO TURN OFF THE LED AND PLAY OFF SOUND
        saber_is_on = false;
     }
     else //Saber is off, so turn it on
     {
        //ADD CODE HERE TO TURN ON LED AND PLAY ON SOUND
        saber_is_on = true;
     }
  }
}

so,..  it has been declared false in the set up AND after the if statement?  Double false? isn't that a true?   why cant i just have this and ditch the bool altogether?

void loop
{
  if(digitalRead(button) == LOW) {//button is pressed
   
        send_command(0);  // off sound
        delay(100);
     }
     else //Saber is off, so turn it on
     {
        send_command(1);  //on sound
        delay(100);
     }
}
//end
i am pretty sure i started with that type of code, and when the button was toggled, it repeated like crazy....   "ma-ma-ma-ma-ma-ma" mamasita que es pasando!"

i am going to re-test,.. and i like your != simple debounce variant. simple.  i'll try it.   
Title: Re: Arduino Lightsaber
Post by: iamearlgrey on Nov 09, 2015, 11:59 pm
Maybe this will help?

https://www.arduino.cc/en/Main/Software
@nom_smile, I think you were talking to me. That only refers to the arduino itself. I have that working already as I've used it to upload sketches for my multiwii multi rotors. What I am referring to is the wt855 sound module which is not an arduino piece of hardware.
This is from the post that jakesoft referenced about the arduino code to work with the module:
"There is a shared Google drive with the control software to upload wav files to the devices, the user manuals, and schematics , they are well written for this type product: https://docs.google.com/open?id=0B2_rhDNAxM4sbmRtM2dXM2ZxWUE"
The software is only pc compatible.
Title: Re: Arduino Lightsaber
Post by: JakeSoft on Nov 10, 2015, 02:36 am
@nom_smile, I think you were talking to me. That only refers to the arduino itself. I have that working already as I've used it to upload sketches for my multiwii multi rotors. What I am referring to is the wt855 sound module which is not an arduino piece of hardware.
This is from the post that jakesoft referenced about the arduino code to work with the module:
"There is a shared Google drive with the control software to upload wav files to the devices, the user manuals, and schematics , they are well written for this type product: https://docs.google.com/open?id=0B2_rhDNAxM4sbmRtM2dXM2ZxWUE"
The software is only pc compatible.
This question comes up once in a while. As far as I know there is no way to make it work on a Mac without a virtual machine.

I know, I'm just as shocked as you; I thought everything "just worked" on a Mac. (I couldn't resist).
Title: Re: Arduino Lightsaber
Post by: JakeSoft on Nov 10, 2015, 02:59 am
thanks.
i have a code mechanics question...
Why do i need the saber_is_on (or any bool statement)  to be set to false in the setup,..  when i am declaring it false after the if statement?

example:
bool saber_on
void setup
saber_on =  false;
void loop
{
  if(digitalRead(button) == LOW) //button is pressed
  {
     if(saber_on) //Saber is on, so turn it off
     {
        //ADD CODE HERE TO TURN OFF THE LED AND PLAY OFF SOUND
        saber_is_on = false;
     }
     else //Saber is off, so turn it on
     {
        //ADD CODE HERE TO TURN ON LED AND PLAY ON SOUND
        saber_is_on = true;
     }
  }
}

so,..  it has been declared false in the set up AND after the if statement?  Double false? isn't that a true?   why cant i just have this and ditch the bool altogether?

void loop
{
  if(digitalRead(button) == LOW) {//button is pressed
   
        send_command(0);  // off sound
        delay(100);
     }
     else //Saber is off, so turn it on
     {
        send_command(1);  //on sound
        delay(100);
     }
}
//end
i am pretty sure i started with that type of code, and when the button was toggled, it repeated like crazy....   "ma-ma-ma-ma-ma-ma" mamasita que es pasando!"

i am going to re-test,.. and i like your != simple debounce variant. simple.  i'll try it.   
Well, the code I posted was just supposed to give you an idea. Actually, it won't work unless you also wait for them to let off the button, otherwise it'll rapidly toggle between off and on as long as the button is pressed.

Your code won't work either and will have a similar problem.

Code: [Select]

void loop
{
 if(digitalRead(button) == LOW) {//button is pressed
   
        send_command(0);  // off sound
        delay(100);
     }
     else //Saber is off, so turn it on
     {
        send_command(1);  //on sound
        delay(100);
     }
}


Here is what will happen (go ahead, try it):
Action: Press the button and hold it
Result: The off sound is played over and over and over every 100 ms until the button is released.

Action: Button is pressed and released
Result: The off sound is played for 100 ms and then the on sound is played every 100 ms.

Your solution provides no way to turn off the saber.

My solution was flawed as well; not intended to be complete. For it to work, you have to wait for the user to let off the button before you look for it again.

Code: [Select]


loop()
{
   if(digitalRead(button) == LOW) //button is pressed
   {
      if(saber_is_on) //Saber is on, so turn it off
      {
         //ADD CODE HERE TO TURN OFF THE LED AND PLAY OFF SOUND
         saber_is_on = false;
      }
      else //Saber is off, so turn it on
      {
         //ADD CODE HERE TO TURN ON LED AND PLAY ON SOUND
         saber_is_on = true;
      }

      delay(20); //de-bounce it a little
      while(digitalRead(button) == LOW) {} //Wait for them to let off the button   
   }
}


Something like that will set up the logic to allow for toggling states and prevent rapid-fire activation event triggering.
Title: Re: Arduino Lightsaber
Post by: iamearlgrey on Nov 10, 2015, 06:48 am
Thanks, I figured that was the case. I'm not all that shocked. Anything development wise is usually left out of the mac realm unless you really know what you're doing and I do not. And it's just to add the audio files. I re-read the post about the working code for the wt588d and saw the discussion about programming with the external usb programmer and purged soul's success on programming without a programmer. It all looks to be done in arduino and processing which should be achievable on a mac. I also noticed that the instructable that the concept came from, the user was using a mac as well. Hmmm. Still a little over my head. Feasible but not simple. I did, however, find a free legal way to put windows on a virtual machine.
http://www.cultofmac.com/307503/run-windows-10-mac-free/
though taking the "easy" way out may be pushing me over to the dark side.
thanks again jakesoft for inspiring this whole adventure and anyone else who puts up helpful hints.
Title: Re: Arduino Lightsaber
Post by: billpealer on Nov 11, 2015, 09:28 pm
https://youtu.be/qoQUYWZs6pI (https://youtu.be/qoQUYWZs6pI)

Ok.  time to move it to the hilt.

(https://forum.arduino.cc/index.php?action=dlattach;topic=261980.0;attach=143399)

anyone have a novel way to make a button trigger 2 sounds?

meaning  

if  button pressed and released
 play_sound(1);
 delay(100);

if pressed and released again less than 700mm since the last press and release
  play_sound (2);
  delay(100);

if pressed and held down
  // do not play sound 1 over and over again every 100ms

i have the first and last parts figured out,..  it's the middle i have yet to figure out.

give me a week before you guys go nuts with examples... maybe i can figure it out.
Title: Re: Arduino Lightsaber
Post by: JakeSoft on Nov 12, 2015, 04:05 am
https://youtu.be/qoQUYWZs6pI (https://youtu.be/qoQUYWZs6pI)

Ok.  time to move it to the hilt.

Hey, nice job. It looks like you've got a viable solution there.
Title: Re: Arduino Lightsaber
Post by: Canobi on Nov 15, 2015, 12:57 pm
I misinterpreted the flicker schematic so here is how it should be wired for uC control:

(http://i1225.photobucket.com/albums/ee395/Can-obi/IMG_20151116_154145.jpg) (http://s1225.photobucket.com/user/Can-obi/media/IMG_20151116_154145.jpg.html)

It only half worked the way I had it configured, 1w LEDcame on but the flicker LED didn't.

Configured as it's supposed to be, it's a bit harder to bypass for a constant LED channel on my PCB as there's not much room left for routing.
Title: Re: Arduino Lightsaber
Post by: darkside on Nov 20, 2015, 06:07 am
hey just joined read most of the post on this topic even generated a list of parts from it. so once i get the boards i need the cable as well right. and the coding of the sound and such fairly simple yes? one thing not known to me is batterie holder can i use a 4aaa  or what? dont want to over power or under power the system. yes i am a true noob to arduino just herd about it as of late. so any tips and so forth would helpful. and if anyone need a saber design i can do it. even to scale if need be though it may take some time.
Title: Re: Arduino Lightsaber
Post by: darkside on Nov 20, 2015, 06:20 am
one more thing need wire gage as well just in case.
Title: Re: Arduino Lightsaber
Post by: nom_smile on Nov 22, 2015, 05:49 pm
This question comes up once in a while. As far as I know there is no way to make it work on a Mac without a virtual machine.

I know, I'm just as shocked as you; I thought everything "just worked" on a Mac. (I couldn't resist).
@nom_smile, I think you were talking to me. That only refers to the arduino itself. I have that working already as I've used it to upload sketches for my multiwii multi rotors. What I am referring to is the wt855 sound module which is not an arduino piece of hardware.
This is from the post that jakesoft referenced about the arduino code to work with the module:
"There is a shared Google drive with the control software to upload wav files to the devices, the user manuals, and schematics , they are well written for this type product: https://docs.google.com/open?id=0B2_rhDNAxM4sbmRtM2dXM2ZxWUE"
The software is only pc compatible.
JakeSoft.. So the software needs a virtual audio interface? for it to work in a mac setting? (sorry been a bit busy)
Title: Re: Arduino Lightsaber
Post by: purgedsoul on Nov 23, 2015, 08:58 am
JakeSoft.. So the software needs a virtual audio interface? for it to work in a mac setting? (sorry been a bit busy)
No, the WT588D uploader/programmer software (This is the software that compiles the bin file to be uploaded to the WT588D module) works only on Windows.
Title: Re: Arduino Lightsaber
Post by: darkside on Nov 29, 2015, 10:18 pm
hey i am guessing that when you used the accelerometer that it eliminated the use of the motion sensor. is this correct?
Title: Re: Arduino Lightsaber
Post by: kingale on Nov 30, 2015, 12:23 am
Dear Friends just a couple of questions.

Im trying to do the same build as Jakesoft using an accelerometer and the clash sensor.
First of all, is there a way to include the "play command" to reproduce the boot up just once sound by including it in the void setup?

Is it possible to play the hum sound in the background and interrupt it as a swing is detected by the accelerometer? Then resume it and continue playing it in a loop.

Im trying to accomplish this without using any delay functions in the main loop to avoid lag.

Currently using the wt588d, an arduino nano and a mm8452 accelerometer.  So far i have accomplished to run the functions "power on and power off" (including led and corresponding sound) with an attach interrupt function, a hardware debounce with an inverse Schmitt trigger and the 1 line serial mode.
Title: Re: Arduino Lightsaber
Post by: DJWing79 on Dec 01, 2015, 01:02 am
hey billpealer, do you have the completed code that you can share with us? I've been working hard on mine and it works but could always use tweaking. I have a suggestion for the changing of the swing and clash sounds, use the CASE SELECT option in Arduino. Here's the working part of my code that does this. Note, i'm still using 3-line serial mode and am hoping to look at your completed code to modify mine for 1-line.
Code: [Select]


int clashValue;
int swooshValue;
int clashSound;
int swooshSound

(under loop)

switch (clashValue) {
    case 1:
      clashSound = 0x03;
      break;
    case 2:
      clashSound = 0x04;
      break;
    case 3:
      clashSound = 0x05;
    case 4:
      clashSound = 0x06;
      break;
  }
 switch (swooshValue) {
    case 1:
      swooshSound = 0x08;
      break;
    case 2:
      swooshSound = 0x09;
      break;
    case 3:
      swooshSound = 0x0a;
    case 4:
      swooshSound = 0x0b;
      break;
  }
clashValue = random(4);
  swooshValue = random(4);

(outside loop)

void swoosh() {               //am using a ADXL335 accelerometer and had to create values so the
  calibrated = false;         //vibration from the clash didn't trigger the swing sound
  if (canSwing = true) {
  if (isclashing == false) {
      sendcommand(swooshSound);
      delay(5);
    }
  }
  canSwing = false;
  delay (5);
}

void clash() {
  if (isOn) {
    digitalWrite(clashLed, HIGH);
    isclashing = true;
    sendcommand(clashSound);
    delayMicroseconds(2000);
    digitalWrite(clashLed, LOW);

    isclashing = false;

  }
}

Title: Re: Arduino Lightsaber
Post by: raphax on Dec 01, 2015, 07:27 pm
Hello, to program the wt588d-16p i need use this arduino scheme? or the scheme is only to play the sounds with arduino sensing the messagens? i didnt understand this...

Thanks
Title: Re: Arduino Lightsaber
Post by: JakeSoft on Dec 02, 2015, 01:59 am
hey i am guessing that when you used the accelerometer that it eliminated the use of the motion sensor. is this correct?
Yeah, the tilt sensor would have been kind of redundant, so I removed it in my Mk. III system when I added the accelerometer. I'm still not totally satisfied with how that's working, I've got to come up with a better swing detect algorithm.
Title: Re: Arduino Lightsaber
Post by: darkside on Dec 02, 2015, 02:22 am
thanks JakeSoft for the info i am still waiting on the rest of the parts. so as of now i am just getting the feel for how it should come together. any tips on the programming would be useful. and i also checked out your videos to better understand the setup. i say job well done. PS. the programming is rather new to me, i understand how to get into it its just the code writing that i am leery about. one line three line is new to me. first time trying this in any case.
Title: Re: Arduino Lightsaber
Post by: JakeSoft on Dec 02, 2015, 02:29 am
Im trying to do the same build as Jakesoft using an accelerometer and the clash sensor.
First of all, is there a way to include the "play command" to reproduce the boot up just once sound by including it in the void setup?
Yes, that would work.

Is it possible to play the hum sound in the background and interrupt it as a swing is detected by the accelerometer? Then resume it and continue playing it in a loop.

Im trying to accomplish this without using any delay functions in the main loop to avoid lag.
Yes, if you read the rest of this thread you'll see several ways to do exactly that. One caveat is that your hum sounds need to play from the start each time, you can't interrupt them and then start playing again from where you left off.
Title: Re: Arduino Lightsaber
Post by: billpealer on Dec 02, 2015, 08:41 pm
hey billpealer, do you have the completed code that you can share with us? I've been working hard on mine and it works but could always use tweaking. I have a suggestion for the changing of the swing and clash sounds, use the CASE SELECT option in Arduino. Here's the working part of my code that does this. Note, i'm still using 3-line serial mode and am hoping to look at your completed code to modify mine for 1-line.
i am not using a accelerometer so i can't say what will work for your set up.  can you tell me what ISNT working, and maybe we can sort it out.

this is the working code for 1 line serial.  i think others have said they have reduced the below delay times.

void WT588D_Send_Command(byte addr) {
    digitalWrite(WT588D_SDA, LOW);
    delay(5);

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

    digitalWrite(WT588D_SDA, HIGH);
    delay(100);
} //end WT588D_Send_Command
Title: Re: Arduino Lightsaber
Post by: DJWing79 on Dec 03, 2015, 02:41 am
What happens is when I tell it to play the hum sound it gets distorted and then starts clicking even when i put a long enough delay in for the sound to play.
Title: Re: Arduino Lightsaber
Post by: darkside on Dec 03, 2015, 05:46 am
ok i am guessing that the +5V in #6 indicates the 5V regulator which connects to both boards in the diagram. and the led mossfet gates i think i have figured out.
Title: Re: Arduino Lightsaber
Post by: darkside on Dec 03, 2015, 06:04 am
hey just checking things out on amazon for next build when i have mastered this one and found a WTV020-SD-16P sound board there. have anyone hear good things about it or what. it can either be a 5V or 3.3V.
Title: Re: Arduino Lightsaber
Post by: purgedsoul on Dec 03, 2015, 08:32 am
hey just checking things out on amazon for next build when i have mastered this one and found a WTV020-SD-16P sound board there. have anyone hear good things about it or what. it can either be a 5V or 3.3V.
Check out this thread on that particular module:

http://forum.arduino.cc/index.php?topic=117009.0

- older modules are 3.3V check if you have newer one that can accept 5V.
- you need to look for a compatible micro SD card 1GB (newer higher capacity cards will not be accepted)
- you need to convert your audio file so that it can be recognized by the module.
- SD card needs to be formatted so that memory spaces are contiguous.
- noticeable delay during playback between sound files (so no gapless playback).

Title: Re: Arduino Lightsaber
Post by: JakeSoft on Dec 04, 2015, 03:01 am
Check out this thread on that particular module:

http://forum.arduino.cc/index.php?topic=117009.0

- older modules are 3.3V check if you have newer one that can accept 5V.
- you need to look for a compatible micro SD card 1GB (newer higher capacity cards will not be accepted)
- you need to convert your audio file so that it can be recognized by the module.
- SD card needs to be formatted so that memory spaces are contiguous.
- noticeable delay during playback between sound files (so no gapless playback).


This is consistent with everything I have read about them. I looked into it as a candidate but rejected it for some of the above reasons. Obi1 even said that he tried it for his saber sound board project and it flunked out pretty much for the failure to do gap-less playback. I'm sure it's fine for some things, but for this application it's not up to the task.
Title: Re: Arduino Lightsaber
Post by: billpealer on Dec 04, 2015, 04:48 am
DJ, i can't even begin to understand till you post a sample of the code that interacts with the accelerometer.  if i had to guess, id say you have some noise in the PWM of the speakers,.. distorted how?  can you make a video?

also the clicking? ,.. hmm. sounds like the accelerometer is tweaking the arduino to send junk to the WT.    why dont you just drop $3.50 and do analog sensors like Jakes MKII.  i did.  they are good.  more than good. fine and dandy.  as long as you position them correctly and understand how they work,..  you can move in contrived ways that really make the thing sing.   also,.. if you want perfect sounds during a good rough duel,..  seriously,.  nothing on the market will do it. i have seen very expensive light saber duels, and they sound like poorly dubbed videos, and the smacking of polycarbonate will be louder than it all.

ok i am guessing that the +5V in #6 indicates the 5V regulator which connects to both boards in the diagram. and the led mossfet gates i think i have figured out.
do not use a regulator. waste of space. the arduino does it for you if you go to the RAW in pin.  5v-12v unregulated power... AKA a battery.



also,. no offense to Jake,..  his diagram does not go  into proper mosfet wiring nor how he delivers the correct voltage/current to the LEDs.  the attached photo will walk you thru how to do it with out a regulator, and WITH an led DRIVER, and how to wire the mosfet. the mosfet is tied to the WT588 and the LED in my setup.  turning off both LED and WT when there is no audio to play is not a bad thing.

also,.. to bypass default or interrupt hum,.. just program the WT so that every activation sound, except for blade off, is followed by 20-30 seconds of hum looped. it wont take up any more space on the device and plays seamlessly with less or no gaps.

so in the WT programer:

0x00 off sound,..  no hum.
0x01 on sound, followed by 30 seconds of hum
0x02 swing sound, 20 seconds of hum,
0x03 clash sound, 20 seconds of hum

etc
etc


you need 6 arduino commands,.

//button toggle code of choice
turn on led (or truly, send a pin HIGH state to the MOSFET)
turn off led (send a LOW state to the MOSFET

//button toggle code of choice
play on sound (0x01)  ( this should play 10ms after the turn on LED high state.  the WT needs 5-10ms to.. "boot up")
play off sound (0x00)
play clash (0x03)
play swing (0x02)

[img http://forum.arduino.cc/index.php?action=dlattach;topic=261980.0;attach=152407[/img]

if you are using an accelerometer,.  all of the above info may be moot.  i actually like the analog swing sensors. and the alternating debounce button codes with 100ms delays seems to really kill it!!  good swings, nice clashes,.and also a reversed debounce function to throw in alternating swing and clash sounds, if they happen close together,.  meaning..    a single swing with go HUM.  a full 360 or 2 swing triggers in less than 1000ms but more than 200ms will go zHum, VRhurm.  one hit will go CLAShh!  2 hits in less than 1000ms, but more than 200ms will go Clashh, Cleeerchzzs!  

capice?

sometimes the above doesn't work perfect or the same everytime, and gets rather random with you are moving around for a few minutes and holding the saber in wierd positions before you swing or clash it,..  but  random is fine with me too!  the real key is the right sound type plays when it should.

i don't even have a hum command or interrupt for arduino. heck i don't even have one on the WT,.  the sound is of course loaded to the WT, bu no Hex address has it to play.  it is just the tail of all the other sounds

in my off LED command,  i also give it (1200) delay so,.. the LED turns off, JUST as the off sound resolves,..  the LOW state also cuts power to the WT sound module.  this is so there are no false positives from the swing and clash sensors.  and again, less arduino code to mull over.  nothing says OFF like cutting the power.  no code needed.


Title: Re: Arduino Lightsaber
Post by: DJWing79 on Dec 04, 2015, 08:38 am
This code uses the 3-line serial mode and ADXL335 accelerometer, WT588D, Arduino Pro Mini 3.3v and the OneButton library. I got it working pretty well. But I am trying to move over to the 1-line serial mode and it isn't playing nice. that's what I mean. I hope this helps. I am also trying to develop a RGB color changing scheme via the buttons that I saw from another forum.
Title: Re: Arduino Lightsaber
Post by: DJWing79 on Dec 04, 2015, 02:52 pm
oh and I apologize for the code not being more streamlined and neat.
Title: Re: Arduino Lightsaber
Post by: chivotenkai on Dec 04, 2015, 05:56 pm
why use a 5V regulator for WT588D?
The arduino nano have a 5V output.
regards
Title: Re: Arduino Lightsaber
Post by: JakeSoft on Dec 04, 2015, 06:27 pm
do not use a regulator. waste of space. the arduino does it for you if you go to the RAW in pin.  5v-12v unregulated power... AKA a battery.
This is good advice if you are using both a 5V Arduino board and a WT588D-u (the one with the built in USB). The WT588D-u board lets you get away with just powering the VDD pin which can operate at 5V. You used a Nano which has a 5V regulator built in, so you are all set.

The 16-pin WT588D works differently. It won't operate unless you power both the VDD and VCC pins. (The manual may not say that, but that's how it really seems to work.) The VCC pin needs to be 3.3V.

So, let's say you are working with a 3.3V Pro Mini like I used and a 16-pin WT588D. The VDD pin on the WT588D may also be 3.3V just like the VCC (meaning you won't need an external regulator) but won't be as loud as if you give it 5V. So, if you are running with a 3.3V Arduino board or a 16-pin WT588D, then you need an external regulator for maximum loudness because you need both a 3.3V and a 5V source. However, it will work if you jumper both the VCC and VDD pins to 3.3V, it just won't be as loud. I'm not sure what happens if you give 5V to both VCC and VDD. I assume bad things like fried flash on the WT588D, but who knows?

A lot of experimenting to figure all that out.

(https://forum.arduino.cc/index.php?action=dlattach;topic=261980.0;attach=143399)


also,. no offense to Jake,..  his diagram does not go  into proper mosfet wiring nor how he delivers the correct voltage/current to the LEDs.  the attached photo will walk you thru how to do it with out a regulator, and WITH an led DRIVER, and how to wire the mosfet. the mosfet is tied to the WT588 and the LED in my setup.  turning off both LED and WT when there is no audio to play is not a bad thing.
No offense taken. Thanks for filling in the gap! It was clever how you exploited the VF of your chosen LED the way to did.  One question, though: How do you achieve maximum LED brightness if you are using something like a Cree XPE2 that has a forward voltage of ~3.5 v @ 1000ma? Or what if you are using a Lux Rebel red with a forward voltage of 2.4V @ 700ma? Is the LM2596 adjustable?

also,.. to bypass default or interrupt hum,.. just program the WT so that every activation sound, except for blade off, is followed by 20-30 seconds of hum looped. it wont take up any more space on the device and plays seamlessly with less or no gaps.
Hey! You stole my trick! :-) Yeah, this is by far the easiest way to get gapless transition to hum after a clash or swing.

if you are using an accelerometer,.  all of the above info may be moot.  i actually like the analog swing sensors. and the alternating debounce button codes with 100ms delays seems to really kill it!!  good swings, nice clashes,.and also a reversed debounce function to throw in alternating swing and clash sounds, if they happen close together,.  meaning..    a single swing with go HUM.  a full 360 or 2 swing triggers in less than 1000ms but more than 200ms will go zHum, VRhurm.  one hit will go CLAShh!  2 hits in less than 1000ms, but more than 200ms will go Clashh, Cleeerchzzs! 
I totally agree. Although adding an accelerometer allows you to do some cool things, people seriously underestimate what a PITA is to get it working properly while simultaneously underestimating what you can do with a tilt sensor. If you want to detect swings along another axis with simple tilt sensor, you can add a second sensor and orient it perpendicular to the first one. This is how the MR/Hasbro Force FX lightsaber sound boards work and people are putting them in custom sabers all the time. Reading what Bill posts here makes me want to revisit my Mk. II code and play with what can be done.
 
I've said it before, but there are many many MANY ways to wire/code this so it'll work. Thanks Bill for presenting one more by sharing your design.
Title: Re: Arduino Lightsaber
Post by: billpealer on Dec 04, 2015, 07:28 pm
yup yup yup.

all that he said  /\
                      ||

the 5v regulator is needed because the 3.3v pro mini VCC will only send 3.3 v to the WT. i forgot you are using a pro mini 3.3v.  jake man,  have you found a decent amp? 

i just did something really interesting,..  i got the Nano to STACK onto the WT588d-U INSIDE my hilt.  i just shaved 1.24 inches of space.  I am soldering tonight. both USB ports face the same way, so you can reprogram both units,. with out even taking it out of the hilt.   i may do 2 tilt sensors with the  new space. or an amp.  i found one on ebay that should work. 

and no,. i have never achieved maximum output fomr my LEDS,..  but i am getting a good consistant 70% output, and no resistors burning up my batts, and YES, the step down buck converter IS adjustable...  but it adjusts kinds cruddy.  .3v increments. the potentiometer is shite.  the luxeon 3w blue rebel is rated for 3.4v and 450ma for it's optimal operation. yeah, it maxes out with some other numbers, but for mcd, i am right in the zone.

the buck step down settings i got are:
2.82v, 3.18v, 3.37v, 3.45, 3.51,.. for what ever reason.  i think as it gets higher, it becomes more acute.
I use the 3.37 for my green Luxeon rebels at 600ma with no issue, and the 3.45v for my blue at 650ma  with no issues yet.  the leds get warm. i have had them running for 10 minutes with no issue. 
The LM2596 buck is rated for 3A out. that must be at the higher spectrum of Vin.  at 8v in.. i have never been able to push more than 650ma at 3.45v.  i did crank the blue up to 3.6, and got 690ma,. but i tuned it down pretty quick.  the current must be auto regulated.  just the voltage is adjustable.

i seriously think 500-600 ma is plenty for these 3W leds,..  pretty bright.


also,.  by adding the reversed debounce code to the tilt, it will trigger a swing when the ball rolls from one side,.  OR if the ball is left to rest in the closed circuit position for more than 200ms, it will play an alternating swing sound when the circuit closes (low state).  so  it acts like 2 sensors. and vice versa.
Title: Re: Arduino Lightsaber
Post by: billpealer on Dec 04, 2015, 07:47 pm
i learned the add hum trick back when i was just using local button mode.  worked like a charm.  so ..  i left it.

before i wreck my code,..  is there any proven reduction ratio to the 1 line serial mode delay times?,.. 600,200,200,600,100  respectively.

DK,. i think if you try to get rid of your If ,.. Hum statement,

}
    digitalWrite(switchLed, HIGH);


    if (digitalRead(WT588D_BUSY) == 1) {
      hum();
    }

that looks dangerously foul. you should not be using the busy pin as a trigger OR input sensor. can someone else take a look at the nugget?

Just add hum to the clash and swing sounds in the WT programmer, most of your issues will go away.  i am not sure because i can;t test it, but it looks like your interrupting your own resting state with hum, and giving it no delay,...  that sounds like the ticking you are hearing.  arduino is running the loop and finding the hum condition true and replaying it every 0ms,...  "Tk,Tk<tK,...."  Your "void hum ()" has no delay in it,..  whereas all your other sound statements have (5);

i say,. anywhere you have a delay in your code you are short changing your self.  all your 5s should be 10s,. and 10s to 20s.  and aslo,.  what the heck is this doing  ?
 
button.tick();
  delay(1);
  fadeValue = random(0, 105);
  fadeBase = random(15, 155);

delay 1?  really?  make that (10)

and also why all the serial prints?  is that for the accelerometer?

 
Title: Re: Arduino Lightsaber
Post by: JakeSoft on Dec 04, 2015, 08:17 pm
i just did something really interesting,..  i got the Nano to STACK onto the WT588d-U INSIDE my hilt.  i just shaved 1.24 inches of space.  I am soldering tonight. both USB ports face the same way, so you can reprogram both units,. with out even taking it out of the hilt.   i may do 2 tilt sensors with the  new space. or an amp.  i found one on ebay that should work. 
Really? That sounds cool. Send a few pics when you get it done, I'd like to see it. I always have to mount my 16-pin versions on a socket of some kind so I can pull the WT588D module out to reprogram it if I want to change the sounds. Having built in USB must be really useful here. Good thinking.

Title: Re: Arduino Lightsaber
Post by: JakeSoft on Dec 04, 2015, 08:35 pm
i learned the add hum trick back when i was just using local button mode.  worked like a charm.  so ..  i left it.
I actually built a lightsaber with no micorcontroller whatsoever by leveraging that capability.

https://youtu.be/C-JO2Te4g5E

DK,. i think if you try to get rid of your If ,.. Hum statement,

}
    digitalWrite(switchLed, HIGH);


    if (digitalRead(WT588D_BUSY) == 1) {
      hum();
    }

that looks dangerously foul. you should not be using the busy pin as a trigger OR input sensor. can someone else take a look at the nugget?

Just add hum to the clash and swing sounds in the WT programmer, most of your issues will go away.  i am not sure because i can;t test it, but it looks like your interrupting your own resting state with hum, and giving it no delay,...  that sounds like the ticking you are hearing.  arduino is running the loop and finding the hum condition true and replaying it every 0ms,...  "Tk,Tk<tK,...."  Your "void hum ()" has no delay in it,..  whereas all your other sound statements have (5);

I think it's fine to leave that in there, but Bill is right about why you are hearing a "tick tick tick". You aren't giving your sound module any time to react. That busy pin on the WT588D can take anywhere from 15 to 50 ms to change state after you send the command. You need to wait longer after you send the hum command before you check the state of the busy pin.
Title: Re: Arduino Lightsaber
Post by: DJWing79 on Dec 04, 2015, 09:12 pm
thanks for the responses guys, some clarifications. that code i posted works 95% flawlessly, but only in 3-line serial mode. once I try to adapt it to one-line serial mode (to save on how many wirings I need) then I get that weird ticking and clicking sound. the serial print is from the code I found for the accelerometer (from a motion alarm no less!) and I have not had the time to really go through and clean up the code, hence my apologies. I am not opposed to not using the busy pin, but am still fuzzy on the syntax. so should it be something like this?


Code: [Select]

if isOn {                         //isOn is my variable for the momentary button turning unit on and staying on
sendCommand (0x01);
sendCommand (0xF2);
}



or should the repeat come before? I am not sure, can you give me a suggestion?
Title: Re: Arduino Lightsaber
Post by: billpealer on Dec 04, 2015, 09:58 pm
thanks for the responses guys, some clarifications. that code i posted works 95% flawlessly, but only in 3-line serial mode. once I try to adapt it to one-line serial mode (to save on how many wirings I need) then I get that weird ticking and clicking sound. the serial print is from the code I found for the accelerometer (from a motion alarm no less!) and I have not had the time to really go through and clean up the code, hence my apologies. I am not opposed to not using the busy pin, but am still fuzzy on the syntax. so should it be something like this?
dude i just realized,..  the busyPin is NOT in 1 line serial mode.  ergo,.. your hum command won't work.  Der!

look at the code!  in one line serial mode, the busypin is gone from the WT code, homes.  you can assign it a pin in the int (which you did, because it is a hold over from your one line mode) or state in void setup (which you did not), but there is no code jamming in the WT 1line mode to change its state. right?!

so you need a different boolean arduino thinger to trigger your hum.

or you can listen to me, a schmuck that actually got a damn good working unit from listening to people, like Jake.  Or listen to Jake, the godfather- and take out your Hum statements.  and make your On command, and swing and clash commands just end with 20-30 seconds of looping hum,..  and that is done IN the WT programmer uploader application.

my setup code...  no busypin.
Code: [Select]
#define WT588D_SDA 9 //Module pin "P03" or pin # 10

int button = 2;         // the buton
int sw_sensor = 11;
byte file_count = 1;
bool saber_is_on;
bool swing_sound;
bool clash_sound;
int MOSFET_switch = 8;
long time = 0;         // the last time a sensor pin was toggled
long debounce = 200;   // the debounce time, increase if the button output is glitchy

void setup() {

   
  pinMode(WT588D_SDA, OUTPUT);   
  pinMode(button, INPUT_PULLUP);
  pinMode(sw_sensor, OUTPUT);  //swing sensor
  pinMode(cl_sensor, OUTPUT);  //clash sensor
  pinMode (MOSFET_switch, OUTPUT);  //one switch to rule them all and in the darkness bind them.
  digitalWrite(button, HIGH);
  digitalWrite(sw_sensor, HIGH);
  digitalWrite(cl_sensor, HIGH);
  saber_is_on = false;
  swing_sound = false;
  clash_sound = false;
  digitalWrite(WT588D_SDA, HIGH);
  digitalWrite(MOSFET_switch, LOW);
}
Title: Re: Arduino Lightsaber
Post by: JakeSoft on Dec 05, 2015, 12:43 am
dude i just realized,..  the busyPin is NOT in 1 line serial mode.  ergo,.. your hum command won't work.  Der!

look at the code!  in one line serial mode, the busypin is gone from the WT code, homes.  you can assign it a pin in the int (which you did, because it is a hold over from your one line mode) or state in void setup (which you did not), but there is no code jamming in the WT 1line mode to change its state. right?!

The busy pin functions on the WT588D any mode. It's even programmable to go either high or low when a sound is playing. I have used it in key, one-line, and three-line modes with success.
Title: Re: Arduino Lightsaber
Post by: B-Movie on Dec 05, 2015, 01:51 am
Just wanted to give a quick thanks to everyone contributing on this thread, I'm getting questions answered before I get the chance to ask them and have things coming together. Also great to get the hows and whys so I can learn it too, rather than just copying someones complete sketch. Awesome work everyone.
Title: Re: Arduino Lightsaber
Post by: billpealer on Dec 05, 2015, 04:04 am
The busy pin functions on the WT588D any mode. It's even programmable to go either high or low when a sound is playing. I have used it in key, one-line, and three-line modes with success.
but did you look at his attached code in entirety? he obviously is using it in high state. an the WT's high state voltage is not the same as the Arduino's, AND in 3 line mode,  the busy pin on the Arduino is set to go from high to low with delays for the WTsend_command funtion.  a full arduino 5v to 1v arduino high to low.  so THAT is making his hum sound work,. a full high state, a full low state and Delays,..  coming from the void Send_command(); function.  NOT from the WT's local busy signal.  or i still don't understand the cascading order of how arduino executes all the code from top down.  what else could it be?  if you remove the variables?  what changed from his 3 line to 1 line code?  only one friggin thing...  the Busypin is not being kicked on the send_command(); it is only being kicked local at the WT,.. no delays and maybe not enough difference tween high and low states.

}
    digitalWrite(switchLed, HIGH);


    if (digitalRead(WT588D_BUSY) == 1) {
      hum();
    }

and #define WT588D_BUSY pin#

is the only mention of "WT588D_BUSY" in dj's code.  plus the above code is pretty general,..  and DJ? why is the switchLed pin, being told to send a high state.?  shouldn't the LED be already on dude?

and the if the busypin is in a 1 (HIGH state), play hum function,..  is a global interrupt that will trigger the hum every loop cycle, with no delay as long as the busy pin is high, which it will be as long as there is a sound playing,..  it just reminds me of a non delaying feedback loop, and the tk,tk,tk you are hearing sure seems to support that.



so,. as long as a sound is playing, the WT device will send a mid voltage to pin 6? (or what ever he had assigned)  anyone ever take a V+ read off the WT's busy pin to confirm my assumption? if it is less than 3v,  would the arduino digitalRead even acknowledge that as a 1?  wouldn't that be a 0?  or can you  you say..
if (digitalRead(WT588D_BUSY) > 0)


plus there is no delay(20); in the end of the "void hum();"  the sole purpose of the busypin in the WT is to trigger a " lit while playing LED" . i still can't comprehend why the arduino (C) 3 line serial mode needs to send HIGH states down to the WT's busypin,.  especially since the busypin will be in a high state (at least 3v and 40ma to run a dinky LED, because the WT manual recommends putting a resistor in series at the busy pin and an LED.)
Title: Re: Arduino Lightsaber
Post by: DJWing79 on Dec 05, 2015, 06:38 am
the LED is the blade, so when I turn the blade on, the hum comes on. Like I said, that code works pretty dang well in 3-line mode, don't ask how, since I had help with the code and don't fully understand it.Once I have it cleared up more, I plan to post of a video of the saber in action. It responds very well to the accelerometer and instantly to the clash sensor (thank you interrupts!) and the hum just loops. I am trying to save wiring space by switching to 1-line serial mode. if I can't make that work, am just going to stick with 3-line and then post the cleaned up code and video with schematics.
Title: Re: Arduino Lightsaber
Post by: purgedsoul on Dec 05, 2015, 07:48 am
If anyone is interested someone created a library based on the 3 line mode:

http://forum.arduino.cc/index.php?topic=227435.msg2494139#msg2494139 (http://forum.arduino.cc/index.php?topic=227435.msg2494139#msg2494139)

though I haven't tried it yet.
Title: Re: Arduino Lightsaber
Post by: billpealer on Dec 05, 2015, 09:33 am
i hate soldering.

soooooo much.  how much flux can you breath in before you die?
Title: Re: Arduino Lightsaber
Post by: JakeSoft on Dec 05, 2015, 07:05 pm
Just wanted to give a quick thanks to everyone contributing on this thread, I'm getting questions answered before I get the chance to ask them and have things coming together. Also great to get the hows and whys so I can learn it too, rather than just copying someones complete sketch. Awesome work everyone.
I'm glad you are finding it useful. I encourage you to share your results. Best of luck to you!

On a side note, I'm happy to see so many getting involved in their own development. The hobby of lightsaber building has been becoming more popular of late probably due in no small part to a certain movie being released later this year. I developed my project in part because I was frustrated by the options available for adding sound to a lightsaber. You have the $20 cheapie Hasbro cards out of a toy on one hand and then in the other you have expensive $70+ commercial sound cards. There is nothing in between. I find the lack of variety boring, so I crated my own solution. I'm pleased to see others doing the same.
Title: Re: Arduino Lightsaber
Post by: DJWing79 on Dec 05, 2015, 09:05 pm
I found the problem, I had a bad bin file on my WT588D, the one-line serial code works, thanks guys! will try to get my fiance to take a video of me with my saber later today and post it (it still has the 3-line in it). Now on to my next question, anyone know a good code to allow you to change the colors of the RGB (my next build) from a two button configuration and save it to the EEPROM? I found a site that has an awesome code but am having issues adapting it in a way that I can understand. I tried reaching out to the poster of the article, but I haven't heard back.

http://www.fx-sabers.com/forum/index.php?topic=22838.0

Title: Re: Arduino Lightsaber
Post by: jshaw on Dec 05, 2015, 11:42 pm
So excited to have found this thread!  I've had a 3 cell graflex for close to 20 years now and finally got around to adding the externals for Luke's ANH hilt last month.  Now I'm hooked and want to add light and sound, so I've been reading all the forums, watching YouTube videos, and came to the conclusion that if I'm going to build a lightsaber, it should be more DIY than buying a soundboard and soldering it in.  Thus, I'm here, following along with the Ardiuno builds.

At this point, I have a couple of Arduinos, but am currently working on the Mini Pro,  as well as a tiny accellerometer , and I have both the clash and swing sensors from TCSS, WT588D, and Luxeon Tri Rebel (Blue, Royal Blue, Cool White) coming in the mail.  I don't have a lot of Arduino coding experience but I've had good luck w/ getting simple switches and leds working so far. 

Looking forward to more cool stuff happening in this thread as well as contributing more to it once I have the supplies.   
Title: Re: Arduino Lightsaber
Post by: darkside on Dec 06, 2015, 03:54 am
well thus far i have say 80% of the stuff needed based on jacksoft stuff. still learning as i read the thread and trying to understand schematics of the setups. i may not need a battery holder since i found my old 3aaa holder that goes into an old police tactical flash light which i think should be enough juice to power the system and save me some space as well. also i cannibalized an old dino of a flip phone for the vibrator motor to and in the system to give it a small vibration to give it a more real feel to it. the way of installing it was to have it wired to the speaker power wire which if i am correct should not mess with the sound and less coding for it so it is synced with the sound. also figuring out how the line code works since i have experience in either that or wiring up a system of such. "I will do or do not, no try." suggestions welcomed   
Title: Re: Arduino Lightsaber
Post by: DJWing79 on Dec 06, 2015, 06:50 pm
Here's my saber, its my test-bed, I am already planning improvements on the design. I will be posting the finished code once I clean it up and pictures and diagrams on my next build now that I have a better understanding of what I am doing.

https://www.dropbox.com/s/qj6zwcdvrho926e/Lightsaber.mp4?dl=0
Title: Re: Arduino Lightsaber
Post by: JakeSoft on Dec 06, 2015, 10:25 pm
Here's my saber, its my test-bed, I am already planning improvements on the design. I will be posting the finished code once I clean it up and pictures and diagrams on my next build now that I have a better understanding of what I am doing.

https://www.dropbox.com/s/qj6zwcdvrho926e/Lightsaber.mp4?dl=0
Looking good! All that hard worked paid off.
Title: Re: Arduino Lightsaber
Post by: billpealer on Dec 07, 2015, 03:10 am
So excited to have found this thread!  I've had a 3 cell graflex for close to 20 years now ...   
noice!!
Title: Re: Arduino Lightsaber
Post by: jshaw on Dec 07, 2015, 04:11 am
My basic goal (very simplistic) is to have "push button, receive light" all set to go for the Episode VII release, and I'm happy to say that I got that working pretty well tonight with a single LED.  Still waiting on shipping for most of the crucial parts, so spending my spare time experimenting with code and trying to figure out the best methods for testing things out.  I soldered pin headers onto my Ardiuno mini today in order to upload my sketches but am now worried that maybe I shouldn't have.  But it's a lot easier this way.

@billpealer, yeah, I love the classic Episode IV Luke saber and can't wait to have my own built up.  Child me would be stoked to know adult me will have a lightsaber.
Title: Re: Arduino Lightsaber
Post by: trtebe on Dec 07, 2015, 02:43 pm
Hello lightsaber manufacturers.

A wrining diagram someone show would be a great help to me.

Title: Re: Arduino Lightsaber
Post by: jshaw on Dec 07, 2015, 04:54 pm
Hello lightsaber manufacturers.

A wrining diagram someone show would be a great help to me.


In post #6, there's a basic guide that should be enough to get you going.
Title: Re: Arduino Lightsaber
Post by: raphax on Dec 08, 2015, 05:32 am
Help, do you have a scheme to power and upload the songs on a wt588d-16p?
Title: Re: Arduino Lightsaber
Post by: Canobi on Dec 08, 2015, 10:35 am
Help, do you have a scheme to power and upload the songs on a wt588d-16p?
You need the associated programming hardware and software to load sounds to the module:

Here's a download link for the software provided on the manufacturer's website:

http://www.waytronic.com/DownLoadCenter/WT588D%20VoiceChip%20Beta%201.6%20Setup.rar (http://www.waytronic.com/DownLoadCenter/WT588D%20VoiceChip%20Beta%201.6%20Setup.rar)


Here's a link for the software manual, though admittedly I googled this one, for some reason I couldnt find it on waytronics site:

http://www.google.co.uk/url?q=http://www.elechouse.com/elechouse/images/product/MP3%2520WT588D%2520USB%2520module/WT588D%2520software%2520user%2520manual.pdf&sa=U&ved=0ahUKEwiM6M749cvJAhWFRBQKHaF6BzQQFggRMAI&usg=AFQjCNGbMQDqre-hLQXoycS6Mamn4u08YA (http://www.google.co.uk/url?q=http://www.elechouse.com/elechouse/images/product/MP3%2520WT588D%2520USB%2520module/WT588D%2520software%2520user%2520manual.pdf&sa=U&ved=0ahUKEwiM6M749cvJAhWFRBQKHaF6BzQQFggRMAI&usg=AFQjCNGbMQDqre-hLQXoycS6Mamn4u08YA)

I bought my programmer board on ebey but seen it sold elsewhere as well.
Title: Re: Arduino Lightsaber
Post by: JakeSoft on Dec 09, 2015, 02:59 am
You need the associated programming hardware and software to load sounds to the module:

Here's a download link for the software provided on the manufacturer's website:

http://www.waytronic.com/DownLoadCenter/WT588D%20VoiceChip%20Beta%201.6%20Setup.rar (http://www.waytronic.com/DownLoadCenter/WT588D%20VoiceChip%20Beta%201.6%20Setup.rar)


Here's a link for the software manual, though admittedly I googled this one, for some reason I couldnt find it on waytronics site:

http://www.google.co.uk/url?q=http://www.elechouse.com/elechouse/images/product/MP3%2520WT588D%2520USB%2520module/WT588D%2520software%2520user%2520manual.pdf&sa=U&ved=0ahUKEwiM6M749cvJAhWFRBQKHaF6BzQQFggRMAI&usg=AFQjCNGbMQDqre-hLQXoycS6Mamn4u08YA (http://www.google.co.uk/url?q=http://www.elechouse.com/elechouse/images/product/MP3%2520WT588D%2520USB%2520module/WT588D%2520software%2520user%2520manual.pdf&sa=U&ved=0ahUKEwiM6M749cvJAhWFRBQKHaF6BzQQFggRMAI&usg=AFQjCNGbMQDqre-hLQXoycS6Mamn4u08YA)

I bought my programmer board on ebey but seen it sold elsewhere as well.
Also, see my YouTube channel for instructional videos on how to program the modules once you have the software and a programmer.


https://youtu.be/wQWYXCt8hiI

https://youtu.be/UgGT5Jxial4
Title: Re: Arduino Lightsaber
Post by: DJWing79 on Dec 09, 2015, 06:50 am
Hey Billpealer, can you post your finished code when you get the chance? I'd really like to see it, to see if there are things I can modify with my future boards.
Title: Re: Arduino Lightsaber
Post by: billpealer on Dec 10, 2015, 08:12 pm
Hey Billpealer, can you post your finished code when you get the chance? I'd really like to see it, to see if there are things I can modify with my future boards.
https://www.youtube.com/watch?v=yKps0fm1Wo0 (https://www.youtube.com/watch?v=yKps0fm1Wo0)

Yo DJ,
my code is unfinished, but working. It also will not work with the Accelerometer.,


What exactly are you looking to solve or answer? 

shh!! my code is actually 100% represented in this thread, with Jakesoft's posts, Illuis's, Sugarbombs, and my own.  it just combines it all. it is all here

I use a standard bool condition to turn on the MOSFET, and turn on/off the blade sound.  my entire button/pin configuration, and line diagram for hardware is also already posted.

then i use the Arduino "Switch" (debounce) tutorial code to run my analog swing and clash sensors.  tweaking the delay times a bit.

and then  finally the one line serial code at the end.

that's it.  no kidding. No .h libraries, or fancy statements.
Title: Re: Arduino Lightsaber
Post by: DJWing79 on Dec 10, 2015, 11:50 pm
I am not sure if it's my arduino uno going on the fritz or what, but I had the one-line serial mode audio working one minute, now its not. weird. I am going to try to get rid of the BUSY and wanted to know how you did it in your sketch. Do you have a power up and power down sound before the hum? (couldn't hear audio, my speakers were on fritz). I am having issues with double-fonting on the swing sound from my accelerometer and am going to try applying the debounce method to it.
Title: Re: Arduino Lightsaber
Post by: darkside on Dec 11, 2015, 04:04 am
hey jakesoft and billpealer i am rereading this thread and taking notes as i do. came across your reply from early this month thanks for the info and i shall put it to good use. but i am doing rather the same setup as jakesoft till i get a better understanding of it all. one thing that now has me perplexed is do i need something else to program the accelerometer or not? any way itching to get going on it all but waiting on the rest of the parts i need. it also looks like i am going to have to get my bread board from radioshack, the one i ordered is going to be almost a month. also been looking at both of your videos on utube. seen some others but not as well as yours. i have a 100 more ???? but will ask as i need to. oh billpealer one more thing... be glad you have a son to support you in your endeavor. all i have is my folks.
Title: Re: Arduino Lightsaber
Post by: darkside on Dec 11, 2015, 04:12 am
also i have about 7.5" to play with in the hilt i constructed. which i think i have accomplished by using a a 3aaa batterie holder from a tactical light that no longer works. 3x 1.5v should be enough to power it all. 
Title: Re: Arduino Lightsaber
Post by: darkside on Dec 11, 2015, 05:39 am
watching a Z movie (zombie) and thought if only they had some lightsabers!
Title: Re: Arduino Lightsaber
Post by: billpealer on Dec 11, 2015, 05:56 am
I am not sure if it's my arduino uno going on the fritz or what, but I had the one-line serial mode audio working one minute, now its not. weird. I am going to try to get rid of the BUSY and wanted to know how you did it in your sketch. Do you have a power up and power down sound before the hum? (couldn't hear audio, my speakers were on fritz). I am having issues with double-fonting on the swing sound from my accelerometer and am going to try applying the debounce method to it.
my power up sound has hum WITH IT.  i can't stress the ease of this method.  in the WT Waytronic sound uploader,  when you make the Hex address say  00 for off sound, and 01 for on sound,..  just add 4 or 5 copies of your hum after the on sound.  same for the clash and swing.  if every noise that has to trigger whilst on- after that sound resolves should also be followed by hum,.  skip the code and make those sounds actually PLAY the hum.  are you following?
in the WT588d uploader app,..  you of course need to open/upload all your sounds to it, and load them,.  but when you make your,. wtf is it called,. PLAYLISTS,.. when you make those,.  dont make a hum playlist,..  just add the hum to ALL your playlists,.  except the off sound,..  that is just one sound file.

I don't have a play hum sound command in the arduino.  it is ALL in the WT sound module.

if it worked in the arduino once and not again.... i would check physical connections.  and ypu should maybe not use the UNo, and do your testing ON the device you plan to use,.   i use nanos with usb for super easy changes and stuff.
Title: Re: Arduino Lightsaber
Post by: billpealer on Dec 11, 2015, 06:03 am
also i have about 7.5" to play with...
show off.
Title: Re: Arduino Lightsaber
Post by: billpealer on Dec 11, 2015, 06:21 am
spent an hour doing some real testing tonight with singe CR123A lithium 3.7v batts, and triple AAAs (alkaline and NIMH)

2 phone calls to my best bud electrical engineer and genius,..  YOU DONT NEED AND SHOULDN'T USE A RESISTOR FOR 3W LEDS if the V+ of the BATT IS LESS THAN 10% OVER THE VF of the LED.  There is a 6 page thread on custom saber shop of people who can;t figure out why their 1 ohm 5 watt resistors are only yielding 450ma.  so of course the custom saber guys want to sell the buck pucks.

the reason for only 400-500ma when using a resistor,..  The internal resistance of the battery is more than enough to drop the V by 10%.   MY MAN PJ,  WAS RIGHT.

4V fully charged CR123A,...  with 1 ohm 2W resistor  3.25v and 450ma.  even though that resistor on all the LED calcs should allow the LED to pull 3.4v and 750ma. 

4V fully charged CR123A,... NO RESISTOR...  3.33v and 700ma.  i'll be damned,. that is just about perfect for a blue luxeon star.

now  my pal went on to sing the praises of induction based buck step down converters because they produce cleaner power,. say 2 3.7v CR123A = 7.4 (closer to 8)  then stepped down to 3.4v. and anywhere tween 500 and 1000ma.  the ones i use give me about 620ma from 2 cr123a's.  it is my preferred set up, but wow,. one CR123A is 1/2 the space. 
Title: Re: Arduino Lightsaber
Post by: DJWing79 on Dec 11, 2015, 06:37 am
Billpeeler, what I mean is can you give us an example of your power-on code?
Title: Re: Arduino Lightsaber
Post by: darkside on Dec 11, 2015, 01:11 pm
show off.
not sure if thats a joke or not.
Title: Re: Arduino Lightsaber
Post by: darkside on Dec 11, 2015, 01:56 pm
also if anybody would like to try the 3aaa batterie holder i found them on am azon for under 5 bucks and there are 2 colours black or white.
Title: Re: Arduino Lightsaber
Post by: billpealer on Dec 11, 2015, 06:04 pm
Billpeeler, what I mean is can you give us an example of your power-on code?
i told you.  it is all in here.  Post 91,  see jake's comments.   with the exception of some delay timing tweaks,. that is my code.


not sure if thats a joke or not.
really?  not sure?,..  then i have failed at being funny, like my father before me.
Title: Re: Arduino Lightsaber
Post by: jshaw on Dec 11, 2015, 07:48 pm
The battery conversation is really interesting to me, and I've had a gut feel that cell phone style Li-On batteries are the way to go in sabers since I started reading forums.  I got in my RB/B/CW Tri-Rebel in yesterday and have the two blue LEDs on w/ the white for FoC, and running them from a 3.3V Arduino Pro Mini hooked up to a 3.7V Li-On battery, they are bright! I haven't pulled out the tools to measure their voltage and amperage, but my intuition says they are about where I want them to be.  Now if only my Graflex blade holder would show up...

For people looking for more lightsaber arduino code, these two links have some useful code, although they use different sound modules from what this thread discusses:

https://github.com/alextwin007/LightSaber
http://www.fx-sabers.com/forum/index.php?topic=22838.0
Title: Re: Arduino Lightsaber
Post by: billpealer on Dec 11, 2015, 09:52 pm
This will get you started:
http://arduino.cc/en/Tutorial/Fade

Programming-wise, fading these high-powered LEDs is no more complicated than that.
i am not understanding how this PWM modulation to an LED directly will also translate to the MOSFET and LED setup.

the mosfet is ON or Off. 
Title: Re: Arduino Lightsaber
Post by: billpealer on Dec 11, 2015, 10:24 pm
also if anybody would like to try the 3aaa batterie holder i found them on am azon for under 5 bucks and there are 2 colours black or white.
i get mine at the $1 store.

they come in little useless flashlights.  so i get 3 AAA and a holder $1.  and toss the flashlight.
Title: Re: Arduino Lightsaber
Post by: billpealer on Dec 11, 2015, 10:40 pm
The battery conversation is really interesting to me, and I've had a gut feel that cell phone style Li-On batteries are the way to go in sabers since I started reading forums.  I got in my RB/B/CW Tri-Rebel in yesterday and have the two blue LEDs on w/ the white for FoC, and running them from a 3.3V Arduino Pro Mini hooked up to a 3.7V Li-On battery, they are bright! I haven't pulled out the tools to measure their voltage and amperage, but my intuition says they are about where I want them to be.  Now if only my Graflex blade holder would show up...

For people looking for more lightsaber arduino code, these two links have some useful code, although they use different sound modules from what this thread discusses:

https://github.com/alextwin007/LightSaber
http://www.fx-sabers.com/forum/index.php?topic=22838.0
That guy had some good code, but it is only to run the "Joe Jedi" sound card. and uses a TCSS PWM LED driver to do the color mixing..  (What I assume Jake is doin' ")  I literally knew nothing about C, arduino, or Sound Modules before i started.  and this thread and a few kind people, took me all the way to where i am,.. 

I just bought a 3d printer and i am going to make chassis that hold the stacked nano/WT sound module and you can F using PCB boards,..  just wire the pins direct.  I have 3 more sabers in the works,.. 
Title: Re: Arduino Lightsaber
Post by: DJWing79 on Dec 11, 2015, 11:38 pm
PWM is simply on or off, just done in very rapid succession. So the MOSFET works the same by opening and closes in tune with the signal from the pin.
Title: Re: Arduino Lightsaber
Post by: JakeSoft on Dec 12, 2015, 01:51 am
2 phone calls to my best bud electrical engineer and genius,..  YOU DONT NEED AND SHOULDN'T USE A RESISTOR FOR 3W LEDS if the V+ of the BATT IS LESS THAN 10% OVER THE VF of the LED.  There is a 6 page thread on custom saber shop of people who can;t figure out why their 1 ohm 5 watt resistors are only yielding 450m.  so of course the custom saber guys want to sell the buck pucks.

the reason for only 400-500ma when using a resistor,..  The internal resistance of the battery is more than enough to drop the V by 10%.   MY MAN PJ,  WAS RIGHT.

Really?! Reading this got me excited. My setup uses a 3.3V Pro Mini and could operate on a 3.7V power source without the need for a buck boost. I could run my color change setup with a resistor on only the red die if I use a Cree XP-E2 RGB 3-up LED. Forward voltages are 3.7V @ 1000ma, 3.4V @ 1000ma, and 2.65V@ 1000 ma. I could just run the WT588D's VDD pin off direct battery power since it's under the 5.5V max rating, so I could also drop the regulator from the design and save space, money, and complexity! Oh, man, I've gotta try this!
Title: Re: Arduino Lightsaber
Post by: darkside on Dec 12, 2015, 03:31 am
sorry billpealer its just at home or at work i am use to the joke and yes i was not sure but as i thought about it i started to laugh. i do have a question though... i have a radioshake breadboard that i bought today. would it be possible for me to program the pro mini with it threw the cable i have with the soundboard programmer or do i realy need the ftdi breakout board. also do ya'll know any good c++ books i am in the mood for light reading.
Title: Re: Arduino Lightsaber
Post by: JakeSoft on Dec 12, 2015, 04:06 am
That guy had some good code, but it is only to run the "Joe Jedi" sound card. and uses a TCSS PWM LED driver to do the color mixing..  (What I assume Jake is doin' ")  I literally knew nothing about C, arduino, or Sound Modules before i started.  and this thread and a few kind people, took me all the way to where i am,.. 
Are you saying I used a TCSS PWM LED driver for the color mixing? No way, man! It's straight-up Arduino to my MOSFETs for direct control of the LEDs! I put the positive sides for all the LEDs though a V regulator so I have predictable voltage even as the battery drains. That keeps the colors true until the battery's under-voltage PCB kicks in and cuts power completely.

I just bought a 3d printer and i am going to make chassis that hold the stacked nano/WT sound module and you can F using PCB boards,..  just wire the pins direct.  I have 3 more sabers in the works,.. 
Did you finish the first saber yet? Let's see it!
Title: Re: Arduino Lightsaber
Post by: darkside on Dec 12, 2015, 01:56 pm
besides the custom saber shop any ideas as to where i can get a clash sensor or 2 they are currently out.
Title: Re: Arduino Lightsaber
Post by: purgedsoul on Dec 12, 2015, 02:17 pm
besides the custom saber shop any ideas as to where i can get a clash sensor or 2 they are currently out.
you can try here:

https://www.adafruit.com/search?q=vibration+sensor&b=1 (https://www.adafruit.com/search?q=vibration+sensor&b=1)
Title: Re: Arduino Lightsaber
Post by: darkside on Dec 13, 2015, 01:22 am
you can try here:

https://www.adafruit.com/search?q=vibration+sensor&b=1 (https://www.adafruit.com/search?q=vibration+sensor&b=1)
thanks purgedsoul... i checked it out and found the same style as what the css has granted a bit more in cost but hey i ordered anyway. now once i get it in i shall go to construct mode. now if coding was as easy.
Title: Re: Arduino Lightsaber
Post by: billpealer on Dec 13, 2015, 04:10 am
Are you saying I used a TCSS PWM LED driver for the color mixing? No way, man! It's straight-up Arduino to my MOSFETs for direct control of the LEDs! I put the positive sides for all the LEDs though a V regulator so I have predictable voltage even as the battery drains. That keeps the colors true until the battery's under-voltage PCB kicks in and cuts power completely.
Did you finish the first saber yet? Let's see it!
now is it a regulator buck boost? or a linear regulator? because as the batts voltage drops... a linear regulator requires a good 2v above the output and your current will drop considerably.  have you ever put an ammeter in line at say 50% batt life?   Can someone explain how PWM will work with a digital MOSFET.  PWM is by my understanding a digital way to control analog devices... like LEDs .

you wanna see it?  let me whip it out.  attached.  maybe a video tonight later.  kids just went to bed.  bah... this won't let you uplaod from your phone!?.  ach..  pics later.
Title: Re: Arduino Lightsaber
Post by: darkside on Dec 13, 2015, 05:51 am
you wanna see it?  let me whip it out.  attached.  maybe a video tonight later.  kids just went to bed.  bah... this won't let you uplaod from your phone!?.  ach..  pics later.
frustration leads to the darkside... calm your mind and it will soon come clear. and whipping it out won't salve a thing... at least that is what she said.
Title: Re: Arduino Lightsaber
Post by: JakeSoft on Dec 13, 2015, 06:38 pm
now is it a regulator buck boost? or a linear regulator? because as the batts voltage drops... a linear regulator requires a good 2v above the output and your current will drop considerably.  have you ever put an ammeter in line at say 50% batt life?   Can someone explain how PWM will work with a digital MOSFET.  PWM is by my understanding a digital way to control analog devices... like LEDs .
I just used a simple linear regulator. It's a pretty high quality one with a drop-out voltage of ~0.5 V meaning that as long as I have 5.5V from the battery, I'll get 5V at the output. I used a 7.4V Lithium Ion rechargeable battery as a power source, so the nominal voltage is well above he drop-out of the regulator.

The battery has built-in PCB protection that cuts off the battery power when it gets below a threshold and requires recharging. This seems to happen at well above 5.5V. So, the battery's built-in under-volt protection kicks in long before the drop-out voltage of my regulator matters. I've run it from full charge to empty with no noticeable difference in blade brightness.

There may be more efficient ways, but this way was cheap and easy. 
Title: Re: Arduino Lightsaber
Post by: billpealer on Dec 14, 2015, 04:40 am
i may go to 7.4v with an induction buck boost.  and a white cree with photo gels to get color.  i realized that this would also be the coolest flashlight ever.  and works as such.  the buck will adjust to,  3.7 and 850ma,  that is pretty ok for a cree.

still no explanation as to how PWM will some how get the MOSFET to LOWER the voltage to the LEDs....?

anyone got a good technique to keep the wires from twisting when putting it all together? i have already nipple twisted 2 cables from solder points.  i think i have it good now.  easily a dozen take-aparts and battery pulls with no issue.  i am this close to shaving 1/2 of my threads off. who the hell needs 7+ turns to keep these things in place. 4 tops.

photo attached.
https://www.youtube.com/watch?v=zW-Yeq0l6QM (https://www.youtube.com/watch?v=zW-Yeq0l6QM)

i also just modified my clash and swing debounce. gave them each a different debounce.  my swings were stepping on my clashes.  and when you think about it, you have to swing to get to a clash,.. so it makes sense that the swings would block out the clash from triggering,..

now that i type it,. maybe i should have just reduced the delay after the swing,..  

i'll try that next.
it works about as reliable as a Hasbro Force Saber.  i'd like it to work better,..   if i can't get it better in 1 hour, i'm leaving it.


thank again for all those that got me to this point. i promise to pay it forward.
Title: Re: Arduino Lightsaber
Post by: darkside on Dec 14, 2015, 06:05 am
what i have seen done on other projects to keep the wires from twisting like that is that you twist them the opposite way that way when you screw the piece on it will twist back without problems. it is old school but works well.
Title: Re: Arduino Lightsaber
Post by: darkside on Dec 14, 2015, 06:11 am
just watched your video that is a real good job there.
Title: Re: Arduino Lightsaber
Post by: billpealer on Dec 14, 2015, 07:00 am
just watched your video that is a real good job there.
thanks Darkside. i have been counter spinning the wires.  it works ok,.  but,..  if i can figure out how to do what i have done so far,.. i can out think this.  the protrusion of the button is what is the real set back,..

maybe i will have to bite the bullet and put in a switch box so the button clears the hilt.

i'll figure something out.  i refuse to make a 12"+ long light saber.  anything longer than 11.9 inches is unacceptable. though i was a major nerd for 33-36" long blades,  but the flex and reverb is really annoying. i may revert to 29-30"  it will look brighter too.   do they make a cylindrical 7.4v lipo?

oh,..
new code.  better respsonse.  different (additonal) debounce and delay times.
https://youtu.be/8x7UmLdfMDA (https://youtu.be/8x7UmLdfMDA)

Title: Re: Arduino Lightsaber
Post by: darkside on Dec 14, 2015, 08:53 am
it looks like you have it... i am still drawing out the wiring diagram for mine... well i was till i figured out the last piece and how it SHOULD go. now its wait for the rest of my stuff to come in the mail and hope that i have the proper gauge wire. the gauge is 22 i am thinking maybe smaller like a 24 gauge or so. what do you think. 
Title: Re: Arduino Lightsaber
Post by: JakeSoft on Dec 15, 2015, 12:02 am
it looks like you have it... i am still drawing out the wiring diagram for mine... well i was till i figured out the last piece and how it SHOULD go. now its wait for the rest of my stuff to come in the mail and hope that i have the proper gauge wire. the gauge is 22 i am thinking maybe smaller like a 24 gauge or so. what do you think. 
I use 26 gauge most of the time. You want everything as small and flexible as possible inside that hilt. It tough to get things to fit.
Title: Re: Arduino Lightsaber
Post by: darthgallion on Dec 15, 2015, 12:25 am
Hey guys, completely new to saberbuilding and arduino...could anybody direct me to a complete parts list? Thanks :)
Title: Re: Arduino Lightsaber
Post by: darkside on Dec 15, 2015, 12:45 am
Hey guys, completely new to saberbuilding and arduino...could anybody direct me to a complete parts list? Thanks :)
if you read this thread from the start you will have all the info you need to build you one. that is how i did it. good luck. one more thing click on the links to help you as you go. i found them rather helpful.
Title: Re: Arduino Lightsaber
Post by: darkside on Dec 15, 2015, 12:59 am
I use 26 gauge most of the time. You want everything as small and flexible as possible inside that hilt. It tough to get things to fit.
thanks jakesoft i will keep that in mind for future builds. might as well use up the 22 i have now.
Title: Re: Arduino Lightsaber
Post by: billpealer on Dec 15, 2015, 03:58 am
thanks jakesoft i will keep that in mind for future builds. might as well use up the 22 i have now.
I have 22awg for LEDs and from the batts to the buck, so not to add resistance or limit current.  24 for all else.  the insulation on my stock of 26 was shite.  when I used alligators from my helping hands.. it chewed thru it whilst tinning.  do'h.

anyone want to buy an arduino pro mini 3.3v?  I don't have a USB programmer and I like the Nanos.  $3.00 shipped. PayPal me and it's yours.  headers included. not soldered. just included.
Title: Re: Arduino Lightsaber
Post by: billpealer on Dec 15, 2015, 04:10 am
Really?! Reading this got me excited. My setup uses a 3.3V Pro Mini and could operate on a 3.7V power source without the need for a buck boost. I could run my color change setup with a resistor on only the red die if I use a Cree XP-E2 RGB 3-up LED. Forward voltages are 3.7V @ 1000ma, 3.4V @ 1000ma, and 2.65V@ 1000 ma. I could just run the WT588D's VDD pin off direct battery power since it's under the 5.5V max rating, so I could also drop the regulator from the design and save space, money, and complexity! Oh, man, I've gotta try this!
try it! you'll like it.  though for the cree it may drop below 3.7v pretty quick.  my 3.7v cr123a is 4.2 fully charged. on my blue luxeon measures 3.4v 800m . after 5 min was 3.3v and 700ma.  I do think the 2300mah on the batt is a lie. maybe 1200mah tops.  I may switch to a 18650. or look for some sort of round lipo.
Title: Re: Arduino Lightsaber
Post by: darkside on Dec 15, 2015, 06:01 am
it sounds like good advise from you both... billpealer i may try your combo as well since i have the 22awg already on my 3x aaa batterie holder. i am also reading C++ for dummies so i can better understand it so far my brain hurts from digesting it. i know it is simple for most but for me it takes time. i may wind up reading it several times. i have also been coming up with more saber designs as well along with a saber holster for my first one i made which is what i plan to put the fx in.
Title: Re: Arduino Lightsaber
Post by: Canobi on Dec 15, 2015, 10:51 am
still no explanation as to how PWM will some how get the MOSFET to LOWER the voltage to the LEDs....?
PWM manipulates voltage as a time constant, it can't adjust the current flow up or down in any way, 5v will always be 5v, it's either just on or off.

Took me a little while for it to click but the the key to how it works is in the name.

Pulse: denotes the way in which the voltage is delivered, in this case, as good as instantaneous, no ramping up or down.

Width: denotes the duration of time that current is allowed to flow.

Modulation: denotes the two functional states, on and off.

In terms of an LED, what's actually being described is blinking. Interestingly, if you speed up the frequency to around 50~60Hz, our brains can't keep up and we perceive the blinking as a steady light due to an effect called Persistance Of Vision.

Keep speeding up the frequency and the LED will start to dim and eventually appear to be off, even though it's still technically functioning.


I'm designing a set of easy to assemble saber PCBs based on different skill sets and other setup desirables with DJWing79. The entry level board  uses a single high power LED and the plan is to use PWM to drive the led at around 80~85%, and then ramp it up to 100% for the FoC effect as a budget friendly alternative to using RGBW or tri star LEDs, aimed at the novice fabricator, or for use in young padawan sabers.


Talking of which, I would love to see a pic of your module stack setup if possible. I've been commissioned to make a small custom hilt based on Yoda's stubbie for a 6yr old padawan's christmas present and can't see any other viable option for adding sound, even my boards would be too big for this diddy thing as it's actually to scale. I've rigged it so it lights up but a mute saber just aint the same:

(I put it next to my WIP as a size comparison)
(http://i1225.photobucket.com/albums/ee395/Can-obi/IMG_20151215_020538_1.jpg) (http://s1225.photobucket.com/user/Can-obi/media/IMG_20151215_020538_1.jpg.html)
Title: Re: Arduino Lightsaber
Post by: Protonerd on Dec 15, 2015, 03:04 pm
Here is a good explanation of PWM:
https://en.wikipedia.org/wiki/Pulse-width_modulation

Actually in this context it is used to digitally generate analog voltages between GND and the supply rail. I.e. arbitrary voltages between 0V and 5V. If you look at the waveform with a constant duty cyclfrom the perspective of the load (in this case LED, but PWM is used mostly to drive motors), it looks to be a constant voltage, due to the "inertia" of the load integrating the pulses. With PWM you can also generate any analog signal (sine wave, rectange etc.) digitally, therefore it's widespread use.

For Arduino it means: some output pins are PWM-capable. They can be used to generate different voltages between 0V and 5V. If you want 4V across your LED, set the PWM to ( round(255*4/5)).

Hope it helps :)
Title: Re: Arduino Lightsaber
Post by: billpealer on Dec 15, 2015, 04:07 pm
Quote
In terms of an LED, what's actually being described is blinking. Interestingly, if you speed up the frequency to around 50~60Hz, our brains can't keep up and we perceive the blinking as a steady light due to an effect called Persistance Of Vision.
i understand this. I am a producer.  50hz PAL.  60hz NTSC.

i did not know that increased flicker dims an led.  120hz HDTVs are not dim.  i will just have to play with a mosfet and led.  and regardless of how i conceptualize what's happening, at least just accept the findings. 

the stacked wt and nano is,.. here
https://www.youtube.com/watch?v=yKps0fm1Wo0 (https://www.youtube.com/watch?v=yKps0fm1Wo0)  around 2:37
Title: Re: Arduino Lightsaber
Post by: jonnieZG on Dec 15, 2015, 11:52 pm
Hi, guys! Thanks for this awesome thread, it is really inspiring!  :)  Now I am still collecting information to figure out what components to order, so after having it all read out, I have a couple of questions to ask:


Thanks!
Title: Re: Arduino Lightsaber
Post by: jonnieZG on Dec 15, 2015, 11:59 pm
Oh, just another thing! Has anyone tried to approximate the LED string effect by graduatelly turning the LED on and off? Of course, that is not the same as the actual LED string, but I believe it would look better than the immediate ON/OFF.
Title: Re: Arduino Lightsaber
Post by: billpealer on Dec 16, 2015, 04:18 am
Hi, guys! Thanks for this awesome thread, it is really inspiring!  :)  Now I am still collecting information to figure out what components to order, so after having it all read out, I have a couple of questions to ask:

  • How much memory do I need in the WT588D for a decent soundboard? Humming (idle, swing), clashes (preferably a few different samples), switch-on and switch-off sounds, beeps/perhaps voice prompts for setup...
  • Are the sounds MP3 or PCM?
  • What is the conclusion about the batteries - what form factor and technology are the best choice? I am aiming for the endurance, because I don't want the thing go dead on me in the middle of a party. ;)

Thanks!
1. my WT has 6 sounds.  the 10 second hum is the largest single file. total mem was less than 5mb. i have a the 16mb version

2. mine are all .wav files.

3. i am quite confident the jury's out.  the best long term battery usage is a driver that uses an induction coil based constant current system. Like a buck boost.  the problem with bucking is you need 1.5V+ over your max Vf to the LED.  that means you need at least 2 cells.  i am looking for a 7.4v lipo right now that is at least 1200mah that can fit the 1.125".. (28mm) diameter hilt.  i have got great results from a single 3.7v lithium.  It lasts less than 30 minutes of run time at 3.3v.  and after 30 minutes,.. really struggles.  the upside is i found a bitchin cr123A battery holder, that would look sick sci-fi-ish on a utility belt.  han or jedi style.  takes less than 60 seconds to batt swap.  it is pretty simple math if you are running your batts directly from the single cell.  ohm's law.  a 2000mah battery will run an LED at 750ma for just over 2 hours of operation with your other devices sucking at it as well.  give or take 10% - 20% margin of error, because of loss for heat and increases resistance due to the heat. accent LEDs etc.

maybe someone else can chime in on your 4th question.  I am not a huge fan of the "growing blade effect"  after watching starwars so many times, i am under the notion that there is no given blade emission rate. In ESB Luke seems to get his blade to fully emit in less than 3 frames of video. (100ms).  that is a bilnk.  then ObiWan in StarWars has the slowest blade emission of any scene i can think of as he faces off against darth.  over 30 frames of video.  more than 1000ms.  i do agree the slow to grow looks badass.  it's not my style tho. As I am not one to pick a fight, I will prefer to keep my blade at bay, and only engaged when threatened.  :) :p.
Title: Re: Arduino Lightsaber
Post by: JakeSoft on Dec 16, 2015, 04:43 am
I have 22awg for LEDs and from the batts to the buck, so not to add resistance or limit current.  24 for all else.  the insulation on my stock of 26 was shite.  when I used alligators from my helping hands.. it chewed thru it whilst tinning.  do'h.

If you put a few wraps of electrical tape around the jaws of your helping hands then it'll stop it from chewing through your insulation. It also allows you to hold more delicate parts without scratching them up, tearing them, etc.
Title: Re: Arduino Lightsaber
Post by: JakeSoft on Dec 16, 2015, 04:57 am
Hi, guys! Thanks for this awesome thread, it is really inspiring!  :)  Now I am still collecting information to figure out what components to order, so after having it all read out, I have a couple of questions to ask:

  • How much memory do I need in the WT588D for a decent soundboard? Humming (idle, swing), clashes (preferably a few different samples), switch-on and switch-off sounds, beeps/perhaps voice prompts for setup...

If you only want one sound font then 8M is plenty.

  • Are the sounds MP3 or PCM?

Use .wav format at 10K or 20K Hz for best performance. .MP3 is supported, but it will lag on switching sounds.

  • What is the conclusion about the batteries - what form factor and technology are the best choice? I am aiming for the endurance, because I don't want the thing go dead on me in the middle of a party. ;)


The best way to make sure you can run all day is to use a swapable battery that you can just change when it runs out. Even the best rechargables won't last for hours on end.

Oh, just another thing! Has anyone tried to approximate the LED string effect by graduatelly turning the LED on and off? Of course, that is not the same as the actual LED string, but I believe it would look better than the immediate ON/OFF.
You haven't seen my YouTube videos, have you?
Title: Re: Arduino Lightsaber
Post by: jonnieZG on Dec 16, 2015, 09:17 am
@billpealer and @JakeSoft - thanks for the answers!

The best way to make sure you can run all day is to use a swapable battery that you can just change when it runs out. Even the best rechargables won't last for hours on end.
You are right! Either way, we'll need a couple of extra batteries for swap.

You haven't seen my YouTube videos, have you?
I did see just this one at first: https://youtu.be/3PacAFmnF_8 - but now I see there are also a few others. :) I missed to notice the fade in and out effect, but I see it now. Cool! :)

What LED did you use for the blade in the Mk II Lightsaber (the one in the video above) - was it http://www.ledsupply.com/leds/luxeon-rebel-endor-star-rgb-high-power-led ? The flash on clash is awesome!

Also, what is the speaker and do you drive it directly or with an amp? It seems quite loud. I see some 24mm 8Ohm 2W speakers on eBay, but I'd like mine "to go to eleven" ;)
Title: Re: Arduino Lightsaber
Post by: Canobi on Dec 16, 2015, 04:11 pm
i understand this. I am a producer.  50hz PAL.  60hz NTSC.

i did not know that increased flicker dims an led.  120hz HDTVs are not dim.  i will just have to play with a mosfet and led.  and regardless of how i conceptualize what's happening, at least just accept the findings. 

the stacked wt and nano is,.. here
https://www.youtube.com/watch?v=yKps0fm1Wo0 (https://www.youtube.com/watch?v=yKps0fm1Wo0)  around 2:37
My knowlage of PWM mainly comes from synths for adjusting the ADR (attack, decay, release) times as I do a bit music and sound design on the side.

From what I understand, the dimming effect is produced by shortening the pulse width and at 50~60Hz this makes the LED appear to dim. Looks like I was wrong about ramping up to higher frequencies, my bad.
Title: Re: Arduino Lightsaber
Post by: jshaw on Dec 16, 2015, 09:15 pm
What sound fonts are you folks using?  I've grabbed the free ones from freesound.org[1] and made ~20s versions of all of them (strike0-hum, etc) by appending the hum to the "special" sounds, but they aren't super smooth transitions.  The 20s hum sounds great, but the transition from strike to hum, or swing to hum is clunky.  I've also seen the UltraSaber free sound fonts [2], but they are .lso files and I'm unsure how to play those.   

I'll probably buy a couple of soundfonts, but want to make sure they come as .wav files.

[1] http://www.freesound.org/people/joe93barlow/packs/5968/
[2] https://www.ultrasabers.com/Sound-Font-p/soundfont-manual.htm
Title: Re: Arduino Lightsaber
Post by: billpealer on Dec 16, 2015, 10:04 pm
What sound fonts are you folks using?  
here.

DL them before saberfont.com takes them down.
http://www.thecustomsabershop.com/Nano-Biscotte-Sound-Module-V2-P806.aspx (http://www.thecustomsabershop.com/Nano-Biscotte-Sound-Module-V2-P806.aspx)
Title: Re: Arduino Lightsaber
Post by: jshaw on Dec 16, 2015, 11:13 pm
here.

DL them before saberfont.com takes them down.
http://www.thecustomsabershop.com/Nano-Biscotte-Sound-Module-V2-P806.aspx (http://www.thecustomsabershop.com/Nano-Biscotte-Sound-Module-V2-P806.aspx)
Woah, that seems like it would be of concern to the folks who made these sound fonts...  Thanks for the pointer.
Title: Re: Arduino Lightsaber
Post by: JakeSoft on Dec 17, 2015, 02:00 am
There are a lot of free sound fonts out there for Obsidian, but to use them in your own custom application like we do around here requires some extra work. Follow these instructions to make them compatible with the WT588D.

1. Open Audacity. (can be downloaded for free here: http://audacityteam.org/)

2. Select File->Import->Raw Data

3. Browse to the .lsu file.

4. Select these options on the Import Raw Data dialog:
  - Encoding: Signed 16 bit PCM
  - Byte Order: Little-endian
  - Channels: 1 (Mono)
  - Start Offset: 0 bytes
  - Amount to Import: 100%
  - Sample rate: Anything from 44100 Hz to 48000 Hz

You can change the pitch and mood of the sounds by messing with the sample rate. Experiment until you get a sound you like. I recommend you do the hum and power on sounds first, then convert all the other files to match.


5. At the bottom left of the Audacity window, select "Project Rate" to either 10000 OR 20000.
6. select File->Export
7. Choose a file name and set save type as "WAV" then press Save.

You will now have a sound file that is compatible with the WT588D. Import it in the WT588D programming software as normal and enjoy.
Title: Re: Arduino Lightsaber
Post by: darkside on Dec 17, 2015, 04:30 am
i know this is going back to what was said before but i just found out... when my pro mini pack fell to the floor... it is a 5v not a 3.3v like i thought i had ordered. with 16MHz instead of 8MHz. so now i wont need that +5 regulator. but now i am wondering if my power source is too low for it all. on meter it showed 4.83v when fresh. or do you think that is enough bill, jake. yes or no
Title: Re: Arduino Lightsaber
Post by: JakeSoft on Dec 17, 2015, 04:38 am
i know this is going back to what was said before but i just found out... when my pro mini pack fell to the floor... it is a 5v not a 3.3v like i thought i had ordered. with 16MHz instead of 8MHz. so now i wont need that +5 regulator. but now i am wondering if my power source is too low for it all. on meter it showed 4.83v when fresh. or do you think that is enough bill, jake. yes or no
Your 5V Pro mini won't run on 4.83 volts.
Title: Re: Arduino Lightsaber
Post by: CrossRoads on Dec 17, 2015, 04:50 am
Connect the 4.83V to Vcc instead of RAW, bypass the 5V regulator.
Title: Re: Arduino Lightsaber
Post by: darkside on Dec 17, 2015, 05:07 am
thanks crossroads and jakesoft. first i will try your suggestion crossroads... i also checked out your sight for a min trying to figure out if you teach fencing or do circuits or both. well either way i will give it a shot thanks again. 
Title: Re: Arduino Lightsaber
Post by: billpealer on Dec 17, 2015, 09:54 pm
thanks crossroads and jakesoft. first i will try your suggestion crossroads... i also checked out your sight for a min trying to figure out if you teach fencing or do circuits or both. well either way i will give it a shot thanks again. 
is your 4.83v a nimh batt pack?  that is an odd total voltage for lithium or alkaline.


if it IS nimh (AAA?),  your voltage is gonna drop, and drop fast when the audio starts to suck it down, and the LEDs start to chew it up. 

i use a 4v lithium with one of these guys sending juice to the arduino and WT. 5.1v and 500ma.  good stable juice and will keep vout stable as vin drops. just your current will drop,  but i think even at 150ma and 5v is more than enough to drive it all.

http://www.ebay.com/itm/1-5V-to-500mA-DC-DC-5V-Out-Boost-Converter-Step-Up-Power-Module-for-Phone-Mp3-4-/161278319601?hash=item258cefdbf1:g:mqQAAOxyUylTT3Nt (http://www.ebay.com/itm/1-5V-to-500mA-DC-DC-5V-Out-Boost-Converter-Step-Up-Power-Module-for-Phone-Mp3-4-/161278319601?hash=item258cefdbf1:g:mqQAAOxyUylTT3Nt)
Title: Re: Arduino Lightsaber
Post by: darkside on Dec 18, 2015, 03:00 am
just standard energizer aaa 1.5v each. but i will check around but for now thi will do unless i find something sooner than next year.
Title: Re: Arduino Lightsaber
Post by: raphax on Dec 18, 2015, 04:06 pm
Also, see my YouTube channel for instructional videos on how to program the modules once you have the software and a programmer.


https://youtu.be/wQWYXCt8hiI

https://youtu.be/UgGT5Jxial4
But do you use an programmer, i need one ? Or it can be program with my arduino uno or nano ?
Title: Re: Arduino Lightsaber
Post by: darkside on Dec 18, 2015, 11:31 pm
ok just got my 3.3v FTDI basic from sparkfun will it do the trick or do i need to set it up for 5v somehow. on back three spots and to the left is 3.3v to the right 5v. at the time i ordered it i thought i had a 3.3v pro mini. dont want to go threw the hassel of returns and reorder. any help would be good.
Title: Re: Arduino Lightsaber
Post by: darkside on Dec 21, 2015, 12:06 am
got the answer i wa looking for so if you get one that has this set up on the underside of the ftdi. all you have to do is solder two of the three tabs to make it a 5v ftdi or a 3.3v one. i have SB's wt588d code now its a matter of producing one for the pro mini. and guess what today is sunday and yet the 26 awg wire came in so now its time to prep it all to be assembled and programmed.
Title: Re: Arduino Lightsaber
Post by: darkside on Dec 21, 2015, 12:13 am
i do have a question about the pro mini. is there a preprogram setting for it or do i need to generate my own? if some one could answer this soon that would be great.
Title: Re: Arduino Lightsaber
Post by: IngoJ on Dec 21, 2015, 01:37 am
Hi,
I have previously worked with the WTV020SD-16P sound module (earlier state breadboard prototype: https://youtu.be/ANJg5hdYp3g). Unfortunately, I did not get it to play the sounds without gaps. On Youtube I found the videos from JakeSoft and then ended up in this forum. In an earlier post Jake wrote that the WT588D module is able to play the sounds without gaps. Wonderful, so I decided to buy a WT588D and now I'm experimenting with it. The code of SugarBombs works fine. It plays the first eight sounds/playlists but as with the WTV020 I also have gaps between them. I already tried the One Line Mode with the same result.

What am I doing wrong? How did you guys solve it?

The code I'm using:
Code: [Select]

/*

This program cycles through the first eight files loaded onto a WT588D-16P Sound Module

The pins labeled on the data sheet as CLK, DI, DO, CS, REST are for programming
the module via the external USB programmer.

In the Waytronic VoiceChip beta software, the settings are configured as "Control Mode: Three Line Mode, and Busy Mode: LOW"


*/

#define WT588D_RST 7 //Module pin "REST" or pin # 1
#define WT588D_CS 6 //Module pin "P02" or pin # 11
#define WT588D_SCL 9 //Module pin "P03" or pin # 10
#define WT588D_SDA 8 //Module pin "P01" or pin # 9
#define WT588D_BUSY 10 //Module pin "LED/BUSY" or pin # 15

byte file_count = 1;

void setup() {

  pinMode(WT588D_RST, OUTPUT); 
  pinMode(WT588D_CS, OUTPUT);
  pinMode(WT588D_SCL, OUTPUT);
  pinMode(WT588D_SDA, OUTPUT);
  pinMode(WT588D_BUSY, INPUT); 

  digitalWrite(WT588D_CS, HIGH);
  digitalWrite(WT588D_RST, HIGH);
  digitalWrite(WT588D_SCL, HIGH);

}


void loop()
{

  WT588D_Send_Command(file_count);

  file_count++;

  if(file_count == 8) file_count = 0;

  delay(50); //give the module time to start playing

  while(digitalRead(WT588D_BUSY) == 0) { }

  delay(200);

}


void WT588D_Send_Command(unsigned char addr) {

  unsigned char i;

  digitalWrite(WT588D_CS, LOW);

  delay(5); //delay per device specifications

  for( i = 0; i < 8; i++)  {   
    digitalWrite(WT588D_SCL, LOW);   
    if(bitRead(addr, i))digitalWrite(WT588D_SDA, HIGH);
    else digitalWrite(WT588D_SDA, LOW);         
    delay(2);  //delay per device specifications   
    digitalWrite(WT588D_SCL, HIGH);   
    delay(2);  //delay per device specifications
  } //end for

  digitalWrite(WT588D_CS, HIGH);

} //end WT588D_Send_Command


Thanks and regards
Ingo

(I'm from germany and I hope my english is not too bad :) )
Title: Re: Arduino Lightsaber
Post by: darkside on Dec 21, 2015, 03:37 am
if i am not mistaken it may be the ms or you are plying the sound before it starts and or letting go to long after the sound is played in the loop. check them both to see which it is.
Title: Re: Arduino Lightsaber
Post by: raphax on Dec 21, 2015, 03:57 am
Hello, how can i upload my .wav without the programmer board? Using an arduino uno, nano, ftdi, etc. Can be like that? Anybody can do that?
Title: Re: Arduino Lightsaber
Post by: SoundTrix on Dec 21, 2015, 05:22 am
absolutely awesome thread, I had been trying different sound modules for some time (12months +) now, always a lag between sounds. I have just ordered some new Arduino Nano and WT588D-U units to try this again. Thanks JakeSoft and all, much good news and ideas here.
Title: Re: Arduino Lightsaber
Post by: darkside on Dec 21, 2015, 08:44 am
 WTH.... will someone please tell me why or what i am doing wrong i can't seem to figure out why my PIC K150 programmer is not doing what it should. i even downloaded the stuff from the website. was going to program the sound board... man i am lost
Title: Re: Arduino Lightsaber
Post by: darkside on Dec 21, 2015, 09:47 am
never mind obviously i bout a dyno of a programmer so i downloaded the proper stuff to run it. i will soon see if it does the trick after i get some sleep since it is almost 3 in the morning. 
Title: Re: Arduino Lightsaber
Post by: billpealer on Dec 21, 2015, 03:16 pm
Hi,
I have previously worked with the WTV020SD-16P sound module (earlier state breadboard prototype: https://youtu.be/ANJg5hdYp3g). Unfortunately, I did not get it to play the sounds without gaps. On Youtube I found the videos from JakeSoft and then ended up in this forum. In an earlier post Jake wrote that the WT588D module is able to play the sounds without gaps. Wonderful, so I decided to buy a WT588D and now I'm experimenting with it. The code of SugarBombs works fine. It plays the first eight sounds/playlists but as with the WTV020 I also have gaps between them. I already tried the One Line Mode with the same result.

What am I doing wrong? How did you guys solve it?
stop using this.
void loop()
{

  WT588D_Send_Command(file_count);

  file_count++;

  if(file_count == 8) file_count = 0;

  delay(50); //give the module time to start playing

  while(digitalRead(WT588D_BUSY) == 0) { }

  delay(200);

}

and  just cook up some button or switch code,  and have this be the executable.

WT588D_Send_Command(01);
or
WT588D_Send_Command(00);

what ever playlists you have made in your module.

tap the button a few times.  AND READ THIS THREAD CAREFULLY.  all the answers you seek are already written out.  I know because I am the dumbest guy in here and I got it all to work. i was ready to give up and just buy a hasbro lightsaber guts.  i didn't.
Title: Re: Arduino Lightsaber
Post by: IngoJ on Dec 21, 2015, 09:17 pm
Thanks Bill.
I used the "standard" code from SugarBombs only for testing purposes and better understanding the new sound module. Now I use my existing code that I wrote for the WTV020 module.

Regarding "gapless playback" I found this in your post #135 on page 10: "also,.. to bypass default or interrupt hum,.. just program the WT so that every activation sound, except for blade off, is followed by 20-30 seconds of hum looped. it wont take up any more space on the device and plays seamlessly with less or no gaps."

That brought me much further! I reprogrammed my WT588D-U with some HUM.WAV entries added to the playlists of my CLASH-, SWING-, ... sounds. And it works great that way. I'll make a new video and post it here.
Title: Re: Arduino Lightsaber
Post by: billpealer on Dec 22, 2015, 05:31 am
Thanks Bill.
I used the "standard" code from SugarBombs only for testing purposes and better understanding the new sound module. Now I use my existing code that I wrote for the WTV020 module.

Regarding "gapless playback" I found this in your post #135 on page 10: "also,.. to bypass default or interrupt hum,.. just program the WT so that every activation sound, except for blade off, is followed by 20-30 seconds of hum looped. it wont take up any more space on the device and plays seamlessly with less or no gaps."

That brought me much further! I reprogrammed my WT588D-U with some HUM.WAV entries added to the playlists of my CLASH-, SWING-, ... sounds. And it works great that way. I'll make a new video and post it here.
boom.

just got the new 3d printer in.  i have already printed battery sleds,. speaker housings, activation boxes,..  uh,  spacers,..  also,. i hate trying to tighten the button nut for 16mm buttons so i made an internal washer with concave fitting, so you can actually turn the nut.

anyone need a part?.  i feel i should pay this group back,..  Jake you too man. let me know,.  i'll print up a part.    i have black filament now. looks nice with chrome or raw aluminum.
check out the attachments.

also i defeated the wire twisting issue in my V1.0, analog style.  i just put the batt pack below the blade LED holder, and unscrew the blade holder,..  pull the batts out,. swap,. stuff em back in,. and screw the blade holder back in.

no twisting.  works fine.

new saber came in to day,. what do you all think?  silver brass, and black components? 11.4 inches from end to end.
Title: Re: Arduino Lightsaber
Post by: billpealer on Dec 22, 2015, 06:17 am
attached.   7mm 3d printed spacer on the pommel.  makes it a 4 turn screw and added 7mm.  10.75" is now 11"  i may add another 5mm spacer on the other side of the ribbed handle.

and 3d printed activation box. gives a lot more room in the hilt.  i can also print shrouds,..  ooh. OD is 37mm should be easy enough.
Title: Re: Arduino Lightsaber
Post by: Protonerd on Dec 22, 2015, 09:20 am
I really envy that activation box! It's always the biggest headache how to make a fitting activation box and you really need it, otherwise there is no way to fit in any meaningful circuitry in the hilt...
Title: Re: Arduino Lightsaber
Post by: darkside on Dec 22, 2015, 04:45 pm
No billpealer I must the dummest since I bought a pic chip programmer instead of the wt588d sound board programmer. So now I have to order the proper one which sets me back a week or two since it is coming from China. Duuh
Title: Re: Arduino Lightsaber
Post by: billpealer on Dec 22, 2015, 06:25 pm
No billpealer I must the dummest since I bought a pic chip programmer instead of the wt588d sound board programmer. So now I have to order the proper one which sets me back a week or two since it is coming from China. Duuh
it still boggles the mind why people just don't use the WT588D-U and skip the programmer, and the Nano with usb,. and skip the programer.  If you buy the Nano with no headers, it is only 2cm wide and 4mm tall.  it also lets you modify the software IN HILT.

My "TIE FIGHTER" MCU sled allows me to stack those 2 exact modules and holds them in the hilt either at 31mm OD for base hilts, and 28.5mm OD for the ribbed and V grooved extensions and chokes, from TCSS.

I'll gladly print these sleds for anyone who asks.
Title: Re: Arduino Lightsaber
Post by: darkside on Dec 22, 2015, 08:10 pm
That sounds good and all dut the way I have it for now is I have a 16 pin mount for the sound board that way I can remove it at any time to either put new sounds on it or adjust the programming without taking the hole thing apart. All I have to do is removed that one chip. I may do the same for my pro mini as well. Besides once I get good at it all then I may step up to what you have. I do have a question for you... Programming the pro mini is like the wt558d code right. If so I can use that as a get start point.
Title: Re: Arduino Lightsaber
Post by: DJWing79 on Dec 23, 2015, 12:07 am
Bill,

I too am trying my hand at 3D printing. Can you share with us what the ID, OD and threads used?
Title: Re: Arduino Lightsaber
Post by: darkside on Dec 23, 2015, 12:24 am
i am more interested in the type of 3d printer you used. not that i have the extra cash for one. so you made a devise for threading the 16mm nut onto the button now that has my curiosity peaked but must master the coding of my pro mini and wt588d. this is my testbed. now if you can 3d print some sort of a cree-rebel-RGB holder say big enough to fit in a 1" schedule 80 i think pvc length of say 1" i will give it a try. my pvc version is ok but need something a little cleaner. just tell me where i need to send the m'order.   
Title: Re: Arduino Lightsaber
Post by: billpealer on Dec 23, 2015, 04:49 am
17mm ID for a 16mm switch spacer/box. 20mm OD or 21mm wide for rectangular boxes.

for a firm fit.
32mm OD for internals for main TCSS tubing.
29mm for ribbed and V grooved tubing.
I don't know the tpi of tcss parts.

subract 1mm from that if you want it to slide with little effort.

I bought a DaVinci Jr. 1.0 printer. $230 on black Friday. normally $399.  you can get them for $300 I think now.

it's OK. not quite a $1500 makerbot.  but it works.

I do not recommend using this material to hold LEDs.  heat. ya know?  but I can print up a few.  what is the ID of your pvc ? the star form factor should fit comfy in a 22mm ID housing.

Title: Re: Arduino Lightsaber
Post by: darkside on Dec 23, 2015, 05:15 am
i don't have a caliper to give you the proper size... but the v4 infinity blade with 1" OD fits in it with little play. ok found a ruler the ID of the hilt is 1" ID... yes i know its rather small but hey its my first attempt at this from scratch. i do have multiple plans for 1-1/4" sized sabers for in the future.
Title: Re: Arduino Lightsaber
Post by: darkside on Dec 23, 2015, 05:39 am
hey billpealer could you tell which pins you used on your momentary switch. mine has 8 and only figured out that 2 are for the led. i even tried to find a spec sheet for mine and came up with nothing. i even got it from tcss
Title: Re: Arduino Lightsaber
Post by: billpealer on Dec 23, 2015, 04:12 pm
hey billpealer could you tell which pins you used on your momentary switch. mine has 8 and only figured out that 2 are for the led. i even tried to find a spec sheet for mine and came up with nothing. i even got it from tcss
I have 4 pins.  so it was a no brainer.  just tape the button down and hook up a simple circuit with an led.  when it lights up you have a hit.  when you take the tape off, if the light goes out you struck oil.  then mark the pins with a sharpie.
Title: Re: Arduino Lightsaber
Post by: darkside on Dec 23, 2015, 05:11 pm
thanks i will do that... but i think i ran into another snag... 16mm switches are too long for my hilt so i need to get the short ones for this one... well part of making a prototype. i will use the long ones in my next hilt. waste not want not... thanks again billpealer. half of says stop now and give up but the other half says must keep going it can be done... etcetera.
Title: Re: Arduino Lightsaber
Post by: billpealer on Dec 23, 2015, 10:58 pm
thanks i will do that... but i think i ran into another snag... 16mm switches are too long for my hilt so i need to get the short ones for this one... well part of making a prototype. i will use the long ones in my next hilt. waste not want not... thanks again billpealer. half of says stop now and give up but the other half says must keep going it can be done... etcetera.
there is no try.  i can send you a switch box and goodies.  it will save your long 30mm switch. message me your addy.

https://youtu.be/OL6TeyTw8V4 (https://youtu.be/OL6TeyTw8V4)

fixed, but the sound syc is off.  it's not a major deal.
Title: Re: Arduino Lightsaber
Post by: Canobi on Dec 24, 2015, 01:17 am
<tentatively puts hand up> um, would it be hard to make a switch box like this?

(http://i1225.photobucket.com/albums/ee395/Can-obi/IMG_20151223_172650.jpg) (http://s1225.photobucket.com/user/Can-obi/media/IMG_20151223_172650.jpg.html)

I've been looking at getting a custom button box master part made from alu as I have some billets. I was then going to take a mould and make cold casts using different metals such as cobalt, titanium, chromium etc, or just plain black resin depending on the hilt but the cheapest quote I've had is £200 for the one part (  "  ).. (><)..*?!(°°o)?!!!

I would be most grateful if you can help me out, though I'd be happy to make a trade of some sort rather than ask for a freebie.
I'm quite handy in the workshop so I could make you a custom hilt part in return, like an interesing emitter shroud, detail part or some such.

Talking of which, here's a pic of the mini saber I just finished up. It's 7 1/2" from end to end and has a 2 1/2' x 1" poly blade

(http://i1225.photobucket.com/albums/ee395/Can-obi/IMG_20151219_211407.jpg) (http://s1225.photobucket.com/user/Can-obi/media/IMG_20151219_211407.jpg.html)

Title: Re: Arduino Lightsaber
Post by: billpealer on Dec 24, 2015, 04:19 am
<tentatively puts hand up> um, would it be hard to make a switch box like this?

I've been looking at getting a custom button box master part made from alu as I have some billets. I was then going to take a mould and make cold casts using different metals such as cobalt, titanium, chromium etc, or just plain black resin depending on the hilt but the cheapest quote I've had is £200 for the one part


casting ain't cheap. none of those metals aint cheap.  you might be able to get it lathed from aluminum for about $250 if you have the CNC file.

but,..i can for sure make you what you need.  continue this in my messages please. message me.  i'll make you a few.  your mini hilt looks righteous. i do have some questions before i print.  message me.
Title: Re: Arduino Lightsaber
Post by: billpealer on Dec 24, 2015, 06:03 am
Jake, back to Arduino stuff.  You stated that even though you use a 3 axis tilt sensor for swing, you still use the analog clash sensor (switch) on interrupt.
is that still the case?

what's up with that? i looked at the sample code for the tilt sensor looks pretty straight forward.  were clash hits not generating enough data to trigger the arduino to send a command to the WT??

i am waiting for my sensor but it looks like a simple query of the xyz inputs is all that is needed, and the more g forces will trigger higher numbers.   did that not work as conceptualized for you?


so 
{
if xy or z is  <= "swingvalue" && > "restvalue" 
   
    { else  sendSwingCommand(0);
  }
}

no?
Title: Re: Arduino Lightsaber
Post by: darkside on Dec 24, 2015, 06:21 am
thanks billpealer... is that new video fixed yet i want to look  at it again.
Title: Re: Arduino Lightsaber
Post by: stinky1 on Dec 24, 2015, 10:23 am
Wow just found this thread and read it all,  and got a splitting migraine headache!!

Luckily I was able to find the processor some guy said he liked better,   a Arudino Nano.
He said he liked it cause it had the USB port already on it.   My question is,  is it basically
the same as a Pro Mini?  Will the command scripts work on the Nano just the same as the
Pro Mini?   

Also the Pro Minis are updated on Ebay, "Enhancement Pro Mini 3.3V/5V adjustable 16M MEGA328P Arduino pro mini compatible"  So is this one good?  I understand the 16M memory,  and the voltage
differential is for different LED drivers I suppose.

Basically I have very very little electronic experience.  The version IV module looks great,  I suppose once you know what you are doing,  adding the Accelerometer? I think,  probably is easy.

Really want to jump in,  but guess i'm still in primer mode.   Used a breadbox when i was a kid in some
Radio Shack circuit board kit.

On a off story, went to Disney store to check out 29 dollar,  colored blade lightsabers.
Seems they power up fine,  and you swing them they make noise.  But a few seconds after you stop
moving it,  it shuts right off!!    After reading this forum,  at least I figured out they have some auto
shut down setting set too high in them!!   Guess that is what triggered me looking up all this lol!!

Earlier in the thread a guy was talking about a voltage limiter,  I figure I would use two 18650's and then limit the voltage so light and effects could stay lit longer.

Anyways at 4:18 am,  I think I'll sleep on it.

Nice work!  I watched the vids and that is cool beans!!  Thanks for cheap alternative and I can actually learn something.



Title: Re: Arduino Lightsaber
Post by: Canobi on Dec 24, 2015, 11:02 am
casting ain't cheap. none of those metals aint cheap.  you might be able to get it lathed from aluminum for about $250 if you have the CNC file.

but,..i can for sure make you what you need.  continue this in my messages please. message me.  i'll make you a few.  your mini hilt looks righteous. i do have some questions before i print.  message me.
PM inbound ;)
Title: Re: Arduino Lightsaber
Post by: jonnieZG on Dec 24, 2015, 04:19 pm
Hey, guys! Just one more stupid question: I notice there is no actual power switch. The Arduino runs the whole time, waiting for the activation key to be pressed, right? How much current does it drain when in that stand-by?
Title: Re: Arduino Lightsaber
Post by: billpealer on Dec 24, 2015, 04:33 pm
Hey, guys! Just one more stupid question: I notice there is no actual power switch. The Arduino runs the whole time, waiting for the activation key to be pressed, right? How much current does it drain when in that stand-by?
i think the phantom drain of my setup is almost 300ma.  my 1200mah batts drain in under 4 hours on standby alone.
Title: Re: Arduino Lightsaber
Post by: billpealer on Dec 24, 2015, 04:39 pm
Wow just found this thread and read it all,  and got a splitting migraine headache!!

Luckily I was able to find the processor some guy said he liked better,   a Arudino Nano.
He said he liked it cause it had the USB port already on it.   My question is,  is it basically
the same as a Pro Mini?  Will the command scripts work on the Nano just the same as the
Pro Mini?   

Nice work!  I watched the vids and that is cool beans!!  Thanks for cheap alternative and I can actually learn something.
all adruinos program the same.  you just need to select the right model in the Arduino software so it uploads it to the device .  i think  it is about compiling the program.  i just know i have a ATTINY85, UNO, Nano, and Micro.  All the code i have ever made works on them all.
Title: Re: Arduino Lightsaber
Post by: billpealer on Dec 24, 2015, 05:25 pm
thanks billpealer... is that new video fixed yet i want to look  at it again.
fixed.
Title: Re: Arduino Lightsaber
Post by: stinky1 on Dec 24, 2015, 05:58 pm
This might help some people,  nice article about how guy made his light saber.
Code and purdy pictures included.

A Jedi quest: How did I build my lightsaber

http://www.carlosvadillo.com/?page_id=21

I like how he linked the module board together.
He used a ADA Fruit, which is comparable to the Nano.
Sure some useful info is here.


Title: Re: Arduino Lightsaber
Post by: billpealer on Dec 24, 2015, 06:48 pm
This might help some people,  nice article about how guy made his light saber.
Code and purdy pictures included.

A Jedi quest: How did I build my lightsaber

http://www.carlosvadillo.com/?page_id=21

I like how he linked the module board together.
He used a ADA Fruit, which is comparable to the Nano.
Sure some useful info is here.

anytime i see code that looks like (int i = 0; i < 3; i += 1)  i glaze over.  i see code like this all the time, including the WT code,. and i have 2 arduino books, they are no help.  and no one in this thread has been able to help me conceptualize how to articulate this type of code in my mind to understand it.  so i don't use it.  and i have asked. one day, maybe it will just click due to other ardunio-ing.  that hapenned last week with If / Else statements.  i now know what they are doing and how to write them from scratch when i need conditional events.
Title: Re: Arduino Lightsaber
Post by: stinky1 on Dec 24, 2015, 10:20 pm
I included it,  cause I guess I can figure it out better with the accessories attached and pictured.
Not just the bare electronic diagram.   You do supply that here in this post,  but the little tutorial with all the pictures helps me conceptualize putting it all together better.   I only started studying this two days ago.
So it helps gel the concepts covered here in my and hopefully other newbies minds on how to set it up.

I suppose if you wanted to make a led strip up down ignition style,  you would of course have to understand
the coding and commands to make it do that.  I wanted to do that,  but all in all the mixing color RGB
3 LED units are a whole lot more durable,  and I am gonna use a thick tube so I can hit stuff hard!!!

I thank the force for leading me to this post.  Time to order some components,  and I'll have to track down
a whats that thing called,  grounded electrostatic solder gun.

I did find a post about LED string lightsaber here for anyone interested.

https://forum.arduino.cc/index.php?topic=361566.0

Title: Re: Arduino Lightsaber
Post by: Canobi on Dec 24, 2015, 11:22 pm
Hey, guys! Just one more stupid question: I notice there is no actual power switch. The Arduino runs the whole time, waiting for the activation key to be pressed, right? How much current does it drain when in that stand-by?
I was after the same info until I learned about kill switches which isolate the battery from the rest of the circuit when not in use.
Title: Re: Arduino Lightsaber
Post by: jonnieZG on Dec 24, 2015, 11:38 pm
I was after the same info until I learned about kill switches which isolate the battery from the rest of the circuit when not in use.
Meh... That's not fool proof. I'll likely forget to switch it off and kill the battery... I was thinking about a passive stand-by control circuit based on motion or touch sensors : when the sabre is still, it would kill the power on the Arduinos. When you grab the sabre, the circuit would power up the controller giving it the 5 sec heads up for the boot to complete, so when you press the activation key it would promptly start. I just need to think it up some more...
Title: Re: Arduino Lightsaber
Post by: darkside on Dec 24, 2015, 11:48 pm
Meh... That's not fool proof. I'll likely forget to switch it off and kill the battery... I was thinking about a passive stand-by control circuit based on motion or touch sensors : when the sabre is still, it would kill the power on the Arduinos. When you grab the sabre, the circuit would power up the controller giving it the 5 sec heads up for the boot to complete, so when you press the activation key it would promptly start. I just need to think it up some more...
you can always put in a kill plug in the hilt which will break the circuit and kill power to the whole thing.
Title: Re: Arduino Lightsaber
Post by: jonnieZG on Dec 24, 2015, 11:57 pm
you can always put in a kill plug in the hilt which will break the circuit and kill power to the whole thing.
That is the simplest solution, but as I said before, really easy to forget to switch it off. Does anyone know how Ultra Sabres and other commercial products handle that problem?
Title: Re: Arduino Lightsaber
Post by: billpealer on Dec 25, 2015, 05:19 am
That is the simplest solution, but as I said before, really easy to forget to switch it off. Does anyone know how Ultra Sabres and other commercial products handle that problem?
they dont use arduinos
Title: Re: Arduino Lightsaber
Post by: Protonerd on Dec 25, 2015, 03:35 pm
Yes, we know how they handle it. In two ways:

- they (and nearly all experiences saber builders) use the kill key to detach the battery from the board. Easy and very effective method to reduce the current consumption to 0.

- most saber electronics out in the market they can go to sleep mode. While this still does not reduce current consumption to 0 as above, it keeps it so low that with a good sized battery you can maintain shelve life for weeks.

Certainly the Arduino boards as well as mostly all satellite boards used together with them you can program sleep mode. That is actually the next step I plan to implement for my arduino saber.

Still, I will Keep the kill key. I do not think anyway that waking up from sleep mode is much less shorter than boot after power on reset.

Title: Re: Arduino Lightsaber
Post by: JakeSoft on Dec 25, 2015, 10:58 pm
Jake, back to Arduino stuff.  You stated that even though you use a 3 axis tilt sensor for swing, you still use the analog clash sensor (switch) on interrupt.
is that still the case?

what's up with that? i looked at the sample code for the tilt sensor looks pretty straight forward.  were clash hits not generating enough data to trigger the arduino to send a command to the WT??

i am waiting for my sensor but it looks like a simple query of the xyz inputs is all that is needed, and the more g forces will trigger higher numbers.   did that not work as conceptualized for you?


so 
{
if xy or z is  <= "swingvalue" && > "restvalue" 
   
    { else  sendSwingCommand(0);
  }
}

no?
The code is actually a little more complicated than that. I did get clash detection to work, but it was so temperamental I got sick of working on it and just stuck with the clash sensor. You see, sometimes a hard hard swing would trigger a clash. I have seen this happen in YouTube videos of the commercial sound boards, so I know it must be a common drawback of using the accelerometer as a clash detector. I really hate that; it bugs me so much when I see it. This false-triggering never seems to happen with the clash sensor, so I'm still using that for now. Plus, as you know, the code is so easy with the clash sensor.

I won't rant here, but the accelerometer part of the code took me way too long to get working right and I still think it could be better. Far be it from me to discourage anyone from trying new things, but know what you're in for. As this thread demonstrates, I'm pretty happy to help out others develop their code, but I'd rather stay out of giving advice on the accelerometer motion detection. Here's hoping someone else reads this thread and can offer a better solution.

Your 3D printed parts look really good. I like your tie-fighter sled. I've got to try stacking WT588D on top of the Arduino board for shorter hilts. Did you solder directly to the WT588D pins, or use some kind of socket? How to you route your wires from your Arduino board to the sound module?
Title: Re: Arduino Lightsaber
Post by: purgedsoul on Dec 26, 2015, 06:15 pm
Hi, here's my code, it's a bit rough and needs improvements; but so far is working for me. Hey Jakesoft, if you don't mind, care to post a snippet of your accelerometer code (or pseudocode) on how to check for a swing event?
Title: Re: Arduino Lightsaber
Post by: Canobi on Dec 26, 2015, 08:55 pm
The code is actually a little more complicated than that. I did get clash detection to work, but it was so temperamental I got sick of working on it and just stuck with the clash sensor. You see, sometimes a hard hard swing would trigger a clash. I have seen this happen in YouTube videos of the commercial sound boards, so I know it must be a common drawback of using the accelerometer as a clash detector. I really hate that; it bugs me so much when I see it. This false-triggering never seems to happen with the clash sensor, so I'm still using that for now. Plus, as you know, the code is so easy with the clash sensor.

I won't rant here, but the accelerometer part of the code took me way too long to get working right and I still think it could be better. Far be it from me to discourage anyone from trying new things, but know what you're in for. As this thread demonstrates, I'm pretty happy to help out others develop their code, but I'd rather stay out of giving advice on the accelerometer motion detection. Here's hoping someone else reads this thread and can offer a better solution.

Your 3D printed parts look really good. I like your tie-fighter sled. I've got to try stacking WT588D on top of the Arduino board for shorter hilts. Did you solder directly to the WT588D pins, or use some kind of socket? How to you route your wires from your Arduino board to the sound module?
Seasons greetings all, hope you all had a good Christmas :)


One of the software engineers at work mentioned an arduino function called "constraint" that sounds perfect for accelerometers.

From what I understand you can set min/max limits that only do something if generated values fall with the set limits, anything that falls outside the limits is ignored.

Title: Re: Arduino Lightsaber
Post by: Canobi on Dec 26, 2015, 09:06 pm
This one is a heads up for anyone wanting to use an amp with the WT.

Here's a source for some super tiny 3w mono amplifier modules:

http://www.aliexpress.com/snapshot/7206812763.html?orderId=71837755517375

I've ordered some to play with so will report back once they've arrived.
Title: Re: Arduino Lightsaber
Post by: JakeSoft on Dec 28, 2015, 01:49 am
This one is a heads up for anyone wanting to use an amp with the WT.

Here's a source for some super tiny 3w mono amplifier modules:

http://www.aliexpress.com/snapshot/7206812763.html?orderId=71837755517375

I've ordered some to play with so will report back once they've arrived.
Looks promising. When you are done experimenting, maybe you can post up how it is supposed to be wired. I can't find a datasheet for this thing anywhere.
Title: Re: Arduino Lightsaber
Post by: purgedsoul on Dec 28, 2015, 04:57 am
This one is a heads up for anyone wanting to use an amp with the WT.

Here's a source for some super tiny 3w mono amplifier modules:

http://www.aliexpress.com/snapshot/7206812763.html?orderId=71837755517375

I've ordered some to play with so will report back once they've arrived.
I used a PAM8403 since the PAM8302 is not available locally from where I'm from. As per WT588D application notes you need to connect 1.2k and a 104 capacitor to ground between the WT588 DAC pin (PIN 2 on 16P module) and your amplifier's input.

If using an amplifier we need to set the option in WT588D programmer to use the DAC output instead of PWM.
Title: Re: Arduino Lightsaber
Post by: Canobi on Dec 28, 2015, 11:52 am
Looks promising. When you are done experimenting, maybe you can post up how it is supposed to be wired. I can't find a datasheet for this thing anywhere.
Yeh, it's probably the most obscure product I've encountered. I emailed the manufacturer for more info but haven't heard back yet.

On a plus side, I've finally manage to decipher the mostly missing silk screen on this pic of the underside:

(http://i1225.photobucket.com/albums/ee395/Can-obi/IMG_20151228_102621.jpg) (http://s1225.photobucket.com/user/Can-obi/media/IMG_20151228_102621.jpg.html)
Title: Re: Arduino Lightsaber
Post by: JakeSoft on Dec 28, 2015, 06:05 pm
Yeh, it's probably the most obscure product I've encountered. I emailed the manufacturer for more info but haven't heard back yet.

On a plus side, I've finally manage to decipher the mostly missing silk screen on this pic of the underside:

(http://i1225.photobucket.com/albums/ee395/Can-obi/IMG_20151228_102621.jpg) (http://s1225.photobucket.com/user/Can-obi/media/IMG_20151228_102621.jpg.html)
Now that's useful. Thanks. Maybe I'll pick one up myself after I get my Mk. IV system vetted.

I see inputs for Rin and Lin. I wonder if those should be shorted together for our purposes or if one should just be left unwired.
Title: Re: Arduino Lightsaber
Post by: billpealer on Dec 28, 2015, 06:47 pm
I used a PAM8403 since the PAM8302 is not available locally from where I'm from. As per WT588D application notes you need to connect 1.2k and a 104 capacitor to ground between the WT588 DAC pin (PIN 2 on 16P module) and your amplifier's input.

If using an amplifier we need to set the option in WT588D programmer to use the DAC output instead of PWM.

Do you need to set it to DAC mode?  the amp won't take the PWM?

i am waiting for this, and it appears that it can take audio direct. PWM.
http://www.ebay.com/itm/331652536370?_trksid=p2060353.m1438.l2649&ssPageName=STRK%3AMEBIDX%3AIT (http://www.ebay.com/itm/331652536370?_trksid=p2060353.m1438.l2649&ssPageName=STRK%3AMEBIDX%3AIT)
Title: Re: Arduino Lightsaber
Post by: Canobi on Dec 28, 2015, 09:31 pm
Now that's useful. Thanks. Maybe I'll pick one up myself after I get my Mk. IV system vetted.

I see inputs for Rin and Lin. I wonder if those should be shorted together for our purposes or if one should just be left unwired.
I've been pondering that myself, what throws things is the fact there's only one output channel. I'm beginning to think it can mix the two inputs to make a mono out so it might not matter whether we use Lin, Rin or both.

Title: Re: Arduino Lightsaber
Post by: Canobi on Dec 28, 2015, 09:40 pm
Do you need to set it to DAC mode?  the amp won't take the PWM?

i am waiting for this, and it appears that it can take audio direct. PWM.
http://www.ebay.com/itm/331652536370?_trksid=p2060353.m1438.l2649&ssPageName=STRK%3AMEBIDX%3AIT (http://www.ebay.com/itm/331652536370?_trksid=p2060353.m1438.l2649&ssPageName=STRK%3AMEBIDX%3AIT)
Good find, may have pick one of those up an all. I like the flexibility it offers when it comes to speaker impedance,a bit of number crunching may be needed to get everything balanced correctly but I see more pro's than con's for this diddy amp though.
Title: Re: Arduino Lightsaber
Post by: JakeSoft on Dec 28, 2015, 11:33 pm
I've been pondering that myself, what throws things is the fact there's only one output channel. I'm beginning to think it can mix the two inputs to make a mono out so it might not matter whether we use Lin, Rin or both.


If it can mix two channels into one then it might make for some interesting possibilities, like using two WT588d sound modules at the same time to play two sounds simultaneously through a common speaker.
Title: Re: Arduino Lightsaber
Post by: billpealer on Dec 29, 2015, 04:39 am
This one is a heads up for anyone wanting to use an amp with the WT.

Here's a source for some super tiny 3w mono amplifier modules:

http://www.aliexpress.com/snapshot/7206812763.html?orderId=71837755517375

I've ordered some to play with so will report back once they've arrived.
FYI  -  here is one based on the same chip with a dual speaker set up.

http://www.ebay.com/itm/2x-PAM8403-2-x-3W-Mini-Stereo-Class-D-Audio-Amplifier-Board-5V-Amp-Module-/301834046185?hash=item4646b60ae9:g:GfAAAOSwEetWBDws (http://www.ebay.com/itm/2x-PAM8403-2-x-3W-Mini-Stereo-Class-D-Audio-Amplifier-Board-5V-Amp-Module-/301834046185?hash=item4646b60ae9:g:GfAAAOSwEetWBDws)

i have to say,.  stereo in,..  but it looks like mixed mono out.  um,..  BOOOOOO!!!

at least the one in the link about has the mono and stereo wiring illustrated. dual speakers with 2 WTs is a neat idea Jake.  it's not true mixing,..  but rather..  a concert!
Title: Re: Arduino Lightsaber
Post by: SoundTrix on Dec 29, 2015, 05:06 am
If it can mix two channels into one then it might make for some interesting possibilities, like using two WT588d sound modules at the same time to play two sounds simultaneously through a common speaker.
Indeed, one on constant hum, the other playing effects...  Hmmmm... The possibilities are endless.
Title: Re: Arduino Lightsaber
Post by: purgedsoul on Dec 29, 2015, 10:01 am
Indeed, one on constant hum, the other playing effects...  Hmmmm... The possibilities are endless.
Aha! Now there's an idea...
Title: Re: Arduino Lightsaber
Post by: purgedsoul on Dec 29, 2015, 10:13 am
Do you need to set it to DAC mode?  the amp won't take the PWM?

i am waiting for this, and it appears that it can take audio direct. PWM.
http://www.ebay.com/itm/331652536370?_trksid=p2060353.m1438.l2649&ssPageName=STRK%3AMEBIDX%3AIT (http://www.ebay.com/itm/331652536370?_trksid=p2060353.m1438.l2649&ssPageName=STRK%3AMEBIDX%3AIT)
Not so sure, haven't tried it with mine, I'm just playing on the safe side since it took me years before I got my WT588. As stated in the application note:

"PWM audio output: Direct drive speaker, connect PWM+ and PWM- to speaker. PWM+ and PWM- can not short circuit and can not connect capacitor or resistor to GND. If necessary to connect to amplifier under this audio output mode, can apply difference mode output to amplifier."

aaaannnd i don't get it... might fry the PWM pins of the WT or might damage the amplifier input.


Title: Re: Arduino Lightsaber
Post by: jonnieZG on Dec 29, 2015, 10:17 am
Mixing two channels playing different rythm and pitch makes sense, but when both are some kind of noise - is an overkill...
Title: Re: Arduino Lightsaber
Post by: Canobi on Dec 29, 2015, 11:36 am
FYI  -  here is one based on the same chip with a dual speaker set up.

http://www.ebay.com/itm/2x-PAM8403-2-x-3W-Mini-Stereo-Class-D-Audio-Amplifier-Board-5V-Amp-Module-/301834046185?hash=item4646b60ae9:g:GfAAAOSwEetWBDws (http://www.ebay.com/itm/2x-PAM8403-2-x-3W-Mini-Stereo-Class-D-Audio-Amplifier-Board-5V-Amp-Module-/301834046185?hash=item4646b60ae9:g:GfAAAOSwEetWBDws)

i have to say,.  stereo in,..  but it looks like mixed mono out.  um,..  BOOOOOO!!!

at least the one in the link about has the mono and stereo wiring illustrated. dual speakers with 2 WTs is a neat idea Jake.  it's not true mixing,..  but rather..  a concert!
Not saying that's how it is, just how it looks. As I haven't recieved my order yet I can't confirm either way but will find out once I have them.

<edit> is your "um,..  BOOOOOO!!!" comment aimed at my electronics knowledge, the suggestion of a mixed mono output, both or something I'm not getting? Sorry, I'm asperges and not sure how to properly respond to that comment so will do my usual and cover that disadvantage up by presenting facts as I see them. In this case by scaling the two chips and making a diagram for the mono amp to compare them:

(http://i1225.photobucket.com/albums/ee395/Can-obi/IMG_20151229_200658.jpg) (http://s1225.photobucket.com/user/Can-obi/media/IMG_20151229_200658.jpg.html)
Title: Re: Arduino Lightsaber
Post by: ryang on Dec 30, 2015, 03:29 am
Been following this post for a while - conveniently timed with my own foray into an Arduino saber!  Great work by all involved! :)

I'm personally using kit from DFRobot, with a couple of changes - specifically the MP3 player & 6DOF gyro.
http://www.dfrobot.com/wiki/index.php?title=Beetle_SKU:DFR0282
http://www.dfrobot.com/wiki/index.php/DFPlayer_Mini_SKU:DFR0299
http://www.dfrobot.com/wiki/index.php/6_DOF_Sensor-MPU6050_(SKU:SEN0142)

Proved incredibly simple to setup and use.  Numbered the MP3s, with some text afterwards for my own use, initialised and was outputting sound in seconds!

I ended up removing the header pins on the final product to cut down on space.  Stuck it opposite the Beetle and ended up with a tiny little unit!

Now, the gyro is the tricky part - as mentioned.  I'm still tweaking the code, but it's pretty damned good so far - modest I know!

It's only pulling in the accel values and calculating direction and velocity - anything over a certain value is consider a "swing" and plays the according sound.  If direction changes and velocity is acceptable again, play another swing..

I haven't had a good crack at clash detection yet (too busy prepping another saber!!), but it should be relatively straight forward. if(swinging && deceleration > whatever) CLASH!!  Knowing my luck it won't be that easy though! LOL


Edit: And then I notice Protonerd's post...
Title: Re: Arduino Lightsaber
Post by: Protonerd on Dec 30, 2015, 10:20 pm
@ryang: as far as programming the MPU6050 chip is concerned you seem to be further ahead as I'm. I still use the raw acceleration values with different thresholds for swing and clash, but your idea with calculating the velocity got me thinking. I like it!

But first I want to make that damn interrupt triggering to work. It seems that just before Xmas on my bench I made some progress (i.e. somehow the MPU6050 did send interrupts if certain preset acceleration values were exceeded), but I could not try it with my saber because it had got a short somewhere (preatty difficult to maintain a development saber...)
If I can make it work, I will post the code (for a little background, I made a research in the net, so far it seems that no one could conjure out any interrupt from said chip, some even went so far as to state that this feature is buggy...I still cannot say for sure, but I got some kind of response)
Title: Re: Arduino Lightsaber
Post by: stinky1 on Dec 31, 2015, 01:19 am
Looking for some advice for parts purchase :


MINI USB Nano V3.0 ATmega328P CH340G 5V 16M-has usb-5v
probably use this.

High-quality WT588D-16p- needs module programmer board-  or can you program pins?

voice WT588D-U-32M voice module 5V Mini USB interface- has usb- port 5v
probably use

ADXL335 3-5v op voltage-probably use


3W cree RGB-probably use
5W cree RGB

Panasonic 18650=unprotected 1x or 2x? definie use

Protection Circuit Module PCB PCM for 7.4V 7.2V 2S Li-ion Li-polymer battery
   do you put in a resistor to limit the voltage to 5v on the boards?
   Put in Protection Circuit Module PCB PCM in charging circuit, or
            just get a two cell charger if don't want to recharge in saber.
UPDATE: OK RE-READING THE BOARD AND FOUND THAT THE ARDUINO HAS
5V VOLTAGE REGULATION.  STILL WONDERING ABOUT THE rgb BELOW.

I have read that generally a single LED runs fine on 3 v unregulated battery,
but I'm guessing color change RGB will need 2x 18650's.  I don't think it will
run 12-15 watts on a 5w cree RGB running 3 lights on etc in color mixing.

Anyways if someone could cull up a parts list for this build it would be appreciated.
Next I have to think switches. Like the lit circle one.

Oh and will 2x side by side battery box work in 1" drainpipe hilt,  or two single holders in a line,  or
just solder 2 together and heat shrunk with connector?  I think I saw some single cases with solder tabs.

Oh and a breadbox is a must I suppose...  god sorry it's been 30 years since i done anything like this.
Parts are scarce at the Custom Saber Shop,  so I figured I'd iron out the guts before assembling saber.
Title: Re: Arduino Lightsaber
Post by: Canobi on Jan 01, 2016, 12:38 am
Just finished fabricating the first of a new set of arduino saber system PCBs I've been working on with DJWing 79. Loads of changes and improvement over the last ones and way simpler to make at home:

(http://i1225.photobucket.com/albums/ee395/Can-obi/IMG_20151231_215622.jpg) (http://s1225.photobucket.com/user/Can-obi/media/IMG_20151231_215622.jpg.html)

I'll make the artwork PDFs available once we've had a chance to test them properly.
Title: Re: Arduino Lightsaber
Post by: jshaw on Jan 01, 2016, 06:33 pm
That pcb is intriguing!

So, working on my wiring, using a 3.7 V 1200 mah li-ion battery and a 3.3 V arduino connected to a Tri-Rebel Luxeon (wired independently), and I'm not convinced it's bright enough to light a 30"+ blade without some tweaking.

What do you folks think? Should I drop a buck puck in, or should I use the adjustable outputs to use a value other than HIGH?
Title: Re: Arduino Lightsaber
Post by: Canobi on Jan 02, 2016, 04:17 am
That pcb is intriguing!

So, working on my wiring, using a 3.7 V 1200 mah li-ion battery and a 3.3 V arduino connected to a Tri-Rebel Luxeon (wired independently), and I'm not convinced it's bright enough to light a 30"+ blade without some tweaking.

What do you folks think? Should I drop a buck puck in, or should I use the adjustable outputs to use a value other than HIGH?
Thanks :)

The boards work with 3v and 5v pro mini, though the input voltage can be higher. Also, the WT's audio outputs (DAC and PWM) have been broken out for easy access. The only real difference between them is that they support an increased number of high power LEDs (1~4).


As to the tri-rebel brightness, have you tried lighting up 30"+ with it, you may be suprised, I use 1w LEDs all the time with great results:

(http://i1225.photobucket.com/albums/ee395/Can-obi/IMG_20150930_123235.jpg) (http://s1225.photobucket.com/user/Can-obi/media/IMG_20150930_123235.jpg.html)

For 1w, how even it looks depend on the blades mod cons, usually cobinations of light tube, diffusion and tip mirror which I employ most of the time.
Title: Re: Arduino Lightsaber
Post by: JakeSoft on Jan 02, 2016, 05:03 am
Just finished fabricating the first of a new set of arduino saber system PCBs I've been working on with DJWing 79. Loads of changes and improvement over the last ones and way simpler to make at home:

(http://i1225.photobucket.com/albums/ee395/Can-obi/IMG_20151231_215622.jpg) (http://s1225.photobucket.com/user/Can-obi/media/IMG_20151231_215622.jpg.html)

I'll make the artwork PDFs available once we've had a chance to test them properly.

Oh, cool. I wish I were better at fabricating, but the whole process is more than I want to get into.
Title: Re: Arduino Lightsaber
Post by: CrossRoads on Jan 02, 2016, 05:07 am
Seems pretty popular - why not get a set of 10 or 20 boards made at iteadstudio and make them available for a couple bucks each plus mailing cost?
Title: Re: Arduino Lightsaber
Post by: jshaw on Jan 02, 2016, 05:16 am
Thanks :)

The boards work with 3v and 5v pro mini, though the input voltage can be higher. Also, the WT's audio outputs (DAC and PWM) have been broken out for easy access. The only real difference between them is that they support an increased number of high power LEDs (1~4).


As to the tri-rebel brightness, have you tried lighting up 30"+ with it, you may be suprised, I use 1w LEDs all the time with great results:

(http://i1225.photobucket.com/albums/ee395/Can-obi/IMG_20150930_123235.jpg) (http://s1225.photobucket.com/user/Can-obi/media/IMG_20150930_123235.jpg.html)

For 1w, how even it looks depend on the blades mod cons, usually cobinations of light tube, diffusion and tip mirror which I employ most of the time.
I'm waiting on my blade and blade holder to arrive, so no, I've yet to actually try it out w/ a blade and diffuser.  I tried just putting it against my blade cap, and it didn't seem too bright, but I guess I'll wait for my blade to arrive and then have a better idea. 

Seems pretty popular - why not get a set of 10 or 20 boards made at iteadstudio and make them available for a couple bucks each plus mailing cost?
I'd be into buying one of these if you were to make them.
Thanks for the pics and encouraging words, Canobi.   
Title: Re: Arduino Lightsaber
Post by: Canobi on Jan 02, 2016, 04:41 pm
Oh, cool. I wish I were better at fabricating, but the whole process is more than I want to get into.
That is exacly how I feel about coding lol. Though I will have to tackle it properly one day as in my case, it doesn't make sense not to.

Drop me a PM, maybe we can work something out ;)

Seems pretty popular - why not get a set of 10 or 20 boards made at iteadstudio and make them available for a couple bucks each plus mailing cost?
I'd love to but unfortunately I can't outsource the work as there are no gerber files for them (yet) and haven't found a fab house that will take PDFs.


I'm waiting on my blade and blade holder to arrive, so no, I've yet to actually try it out w/ a blade and diffuser.  I tried just putting it against my blade cap, and it didn't seem too bright, but I guess I'll wait for my blade to arrive and then have a better idea. 

I'd be into buying one of these if you were to make them.
Thanks for the pics and encouraging words, Canobi.
Not a problem, just PIF from all the help ive had on my saber smithing journey.  In fact, I was going to offer to make them exclusively for folks here anyway. I can't afford to price them as cheap as a fab house would but they won't be anywhere near as outrageous as a biscott or other saber board of that ilk, why I did them in the first place.

I like to encourage self sufficiency and enjoy the DIY aspect of this project so I will also work to any budgets as well and offer bare bones PCBs to populate yourself to fully assembled and ready to go units and anything in between as a way to suit as many skill levels as I can.

Talking of which, the SMT components have also been kept to a minimum since the possibility of hand soldering is rather quite high. This was taken into account early on and have deliberately left a touch more space between clusters of componants than would actually be necessary, though a fine tipped iron is still recommended as I've used SOT-23 and 0805 components which are quite small (barring the FoC resistor that is).

Here's a quick look at the artwork for all four boards:

(http://i1225.photobucket.com/albums/ee395/Can-obi/IMG_20151223_110250.jpg) (http://s1225.photobucket.com/user/Can-obi/media/IMG_20151223_110250.jpg.html)

And a mock up showing what they would look like with the modules mounted (the cap is just a placeholder to show where the impact switch sits as I didn't have one on hand when I took the pic) :

(http://i1225.photobucket.com/albums/ee395/Can-obi/IMG_20160101_012617.jpg) (http://s1225.photobucket.com/user/Can-obi/media/IMG_20160101_012617.jpg.html)


I should mention that these boards are routed for one line comms, though I also have three line versions as well if reqired.
Title: Re: Arduino Lightsaber
Post by: JakeSoft on Jan 02, 2016, 06:27 pm
That is exacly how I feel about coding lol. Though I will have to tackle it properly one day as in my case, it doesn't make sense not to.

Drop me a PM, maybe we can work something out ;)

I like to encourage self sufficiency and enjoy the DIY aspect of this project so I will also work to any budgets as well and offer bare bones PCBs to populate yourself to fully assembled and ready to go units and anything in between as a way to suit as many skill levels as I can.

Talking of which, the SMT components have also been kept to a minimum since the possibility of hand soldering is rather quite high. This was taken into account early on and have deliberately left a touch more space between clusters of componants than would actually be necessary, though a fine tipped iron is still recommended as I've used SOT-23 and 0805 components which are quite small (barring the FoC resistor that is).

Here's a quick look at the artwork for all four boards:

(http://i1225.photobucket.com/albums/ee395/Can-obi/IMG_20151223_110250.jpg) (http://s1225.photobucket.com/user/Can-obi/media/IMG_20151223_110250.jpg.html)

And a mock up showing what they would look like with the modules mounted (the cap is just a placeholder to show where the impact switch sits as I didn't have one on hand when I took the pic) :

(http://i1225.photobucket.com/albums/ee395/Can-obi/IMG_20160101_012617.jpg) (http://s1225.photobucket.com/user/Can-obi/media/IMG_20160101_012617.jpg.html)


I should mention that these boards are routed for one line comms, though I also have three line versions as well if reqired.
Have you considered piggy-backing your accelerometer on top of the Pro Mini? This would make the 3V version shorter. I did this with my Mk IV prototype and an ADXL335. (See video here: Arduino Mk IV Hardware (https://youtu.be/vXeh5lgRX-E) ).

Also, what is the small board under the Pro Mini's programming pin headers?

I've really enjoyed participating in this thread from the beginning. It's great to see all of the ideas and skills people are bringing to the table. What I've watched people struggle with the most is the coding side of it. I'm wondering if I should entertain the idea of selling pre-programmed Pro Mini boards. That way people who don't want to learn C++ (which is no small feat if you've never programmed anything before) don't have to, but could still play with the hardware side.
Title: Re: Arduino Lightsaber
Post by: Canobi on Jan 02, 2016, 10:58 pm
Have you considered piggy-backing your accelerometer on top of the Pro Mini? This would make the 3V version shorter. I did this with my Mk IV prototype and an ADXL335. (See video here: Arduino Mk IV Hardware (https://youtu.be/vXeh5lgRX-E) ).
I like it but how is it with the sensitivity being at the pommel end?



Quote from: JakeSoft
Also, what is the small board under the Pro Mini's programming pin headers?
That is the smallest 3w amplifier module I've ever found:

(http://i1225.photobucket.com/albums/ee395/Can-obi/IMG_20151121_144235.jpg) (http://s1225.photobucket.com/user/Can-obi/media/IMG_20151121_144235.jpg.html)

I'm not sure what the status is with these boards now though. I went back to get more and found the sellers online shop completely empty :( Weirdly though, links to buy new ones are attached to my original order so not sure what the manufacturer's trading status actually is.



Quote from: JakeSoft
I've really enjoyed participating in this thread from the beginning. It's great to see all of the ideas and skills people are bringing to the table. What I've watched people struggle with the most is the coding side of it. I'm wondering if I should entertain the idea of selling pre-programmed Pro Mini boards. That way people who don't want to learn C++ (which is no small feat if you've never programmed anything before) don't have to, but could still play with the hardware side.
Now your talking, that would compliment my hardware offerings ;)

If I send you a pin list and function rundown, could you work the code around the new board designs?

I've also got another small offering to aid with changing sample sets on the board (well any board or setup actually). I've designed a small programmer shield for post mounted WT modules, though it does require a header pin swop out to use it but is simplicity itself once done:

(http://i1225.photobucket.com/albums/ee395/Can-obi/IMG_20160102_211331.jpg) (http://s1225.photobucket.com/user/Can-obi/media/IMG_20160102_211331.jpg.html)

Basically, the WT pins are removed and replaced with regular ones, only this time they're soldered long side up giving enough length afterward to make a decent connection with header sockets (it's not a WT but you get the idea) :

(http://i1225.photobucket.com/albums/ee395/Can-obi/IMG_20151112_020707.jpg) (http://s1225.photobucket.com/user/Can-obi/media/IMG_20151112_020707.jpg.html)

The shield is then attached to the module via the shield's header sockets and the male pins on other side go in the programmer.
Title: Re: Arduino Lightsaber
Post by: JakeSoft on Jan 03, 2016, 02:26 am
I like it but how is it with the sensitivity being at the pommel end?
I'm not sure, but I don't think it'll be a problem. My software allows for user adjustment of swing sensitivity anyway, so it should work anywhere.

That is the smallest 3w amplifier module I've ever found:

I'm not sure what the status is with these boards now though. I went back to get more and found the sellers online shop completely empty :( Weirdly though, links to buy new ones are attached to my original order so not sure what the manufacturer's trading status actually is.
That's too bad it can't be found now. It seems darn near perfect, no bulky capacitors taking up a ton of room like I find on others.


Now your talking, that would compliment my hardware offerings ;)

If I send you a pin list and function rundown, could you work the code around the new board designs?
Probably. I defined all of my pins in a header file, so it should be just changing a few #define lines of code to move pins around as I please. Although, my code is developed to work with an AXDL335 analog accelerometer, not whatever you have pictured which seems to be some kind of serial interface judging from the silk screen. Because of this, the analog input pins must be mapped to the AXDL335 or it won't work.

Basically, the WT pins are removed and replaced with regular ones, only this time they're soldered long side up giving enough length afterward to make a decent connection with header sockets (it's not a WT but you get the idea) :

(http://i1225.photobucket.com/albums/ee395/Can-obi/IMG_20151112_020707.jpg) (http://s1225.photobucket.com/user/Can-obi/media/IMG_20151112_020707.jpg.html)

The shield is then attached to the module via the shield's header sockets and the male pins on other side go in the programmer.
Yeah, I hate those flimsy pins that the WT modules come with. Does anyone know what kind of socket or female header is supposed to mate with them? I tried several types but nothing seems to fit right. I've taken to just cutting a 16-pin DIP socket in half and spacing it out so the pins line up. The only other way that's reliable is to just solder directly to the pins.
Title: Re: Arduino Lightsaber
Post by: Canobi on Jan 03, 2016, 03:44 am
The accelerometer in the pic is an MMA8452Q. I've had it quite a while, my remit at the time was to get the smallest breakout I could find that was well supported which this one is. There's plenty of documentation and it comes with example code as well.


As to a match for the WT pins, their exact title is: SKT SIL turned pin strip which look like this:

(http://i1225.photobucket.com/albums/ee395/Can-obi/IMG_20160103_023224.jpg) (http://s1225.photobucket.com/user/Can-obi/media/IMG_20160103_023224.jpg.html)

They can also be found under the heading of round pin female header socket.
Title: Re: Arduino Lightsaber
Post by: jshaw on Jan 03, 2016, 04:55 am
Have any of you experimented w/ the "shimmer" effect?  I'm playing around w/ the basic "fade" sketch to see if stepping one LED up while the other counts down, and adding in a bright and off to break up the pulse a bit.

Code: [Select]


int blue = 9;           // pure blue pwm
int rblue = 5;          // royal blue pwm
int brightblue = 150;   // minimum LED brightness
int brightrblue = 255;  // maximum LED brightness
int fadeAmount = 5;     // how many points to fade the LED by

void setup() {
  // declare pin 9 and 5 pints to be outputs
  pinMode(blue, OUTPUT);
  pinMode(rblue, OUTPUT);
}

void loop() {
  // set the brightness of the pins to high and low
  analogWrite(rblue, brightrblue);
  analogWrite(blue, brightblue);

  // true blue goes up while royal blue goes down
  brightblue = brightblue + fadeAmount;
  brightrblue = brightrblue - fadeAmount;

  // reverse the direction of the fading at the ends of the fade:
  if (brightblue == 150 || brightblue == 255) {
    fadeAmount = -fadeAmount ;
    // go bright and off to break up the straight pulsing effect
      analogWrite(rblue, 255);
      analogWrite(blue, 0);
  }
  // wait for 5 milliseconds to see the dimming effect
  delay(5);
}


Any other ideas on how to achieve a shimmer effect w/ 1-3 LEDs (vs a LED string)?
Title: Re: Arduino Lightsaber
Post by: Canobi on Jan 03, 2016, 12:47 pm
Have any of you experimented w/ the "shimmer" effect?  I'm playing around w/ the basic "fade" sketch to see if stepping one LED up while the other counts down, and adding in a bright and off to break up the pulse a bit.

Code: [Select]


int blue = 9;           // pure blue pwm
int rblue = 5;          // royal blue pwm
int brightblue = 150;   // minimum LED brightness
int brightrblue = 255;  // maximum LED brightness
int fadeAmount = 5;     // how many points to fade the LED by

void setup() {
  // declare pin 9 and 5 pints to be outputs
  pinMode(blue, OUTPUT);
  pinMode(rblue, OUTPUT);
}

void loop() {
  // set the brightness of the pins to high and low
  analogWrite(rblue, brightrblue);
  analogWrite(blue, brightblue);

  // true blue goes up while royal blue goes down
  brightblue = brightblue + fadeAmount;
  brightrblue = brightrblue - fadeAmount;

  // reverse the direction of the fading at the ends of the fade:
  if (brightblue == 150 || brightblue == 255) {
    fadeAmount = -fadeAmount ;
    // go bright and off to break up the straight pulsing effect
      analogWrite(rblue, 255);
      analogWrite(blue, 0);
  }
  // wait for 5 milliseconds to see the dimming effect
  delay(5);
}


Any other ideas on how to achieve a shimmer effect w/ 1-3 LEDs (vs a LED string)?
Ooh, thanks for the reminder =)

I have but not with code. I was looking at an easy hardware solution a while back but kind of got sidetracked from that avanue of investigation when I started working on the new boards.

I did find one too but never got round to trying it out properly. Now you've brought that back to my attention I will have another look as I could use it for the Sprite.

(http://i1225.photobucket.com/albums/ee395/Can-obi/IMG_20151116_154145.jpg) (http://s1225.photobucket.com/user/Can-obi/media/IMG_20151116_154145.jpg.html)


Here's a link to the article I found that gave me the idea for the schematic above:

http://www.evilmadscientist.com/2011/does-this-led-sound-funny-to-you/ (http://www.evilmadscientist.com/2011/does-this-led-sound-funny-to-you/)

The transistor he uses is no longer available but I found two almost identical equivalents in through hole and surface mount packages. I will find out what their names are if anyone is interested.
Title: Re: Arduino Lightsaber
Post by: jshaw on Jan 03, 2016, 04:26 pm
Ooh, thanks for the reminder =)

I have but not with code. I was looking at an easy hardware solution a while back but kind of got sidetracked from that avanue of investigation when I started working on the new boards.

I did find one too but never got round to trying it out properly. Now you've brought that back to my attention I will have another look as I could use it for the Sprite.

(http://i1225.photobucket.com/albums/ee395/Can-obi/IMG_20151116_154145.jpg) (http://s1225.photobucket.com/user/Can-obi/media/IMG_20151116_154145.jpg.html)


Here's a link to the article I found that gave me the idea for the schematic above:

http://www.evilmadscientist.com/2011/does-this-led-sound-funny-to-you/ (http://www.evilmadscientist.com/2011/does-this-led-sound-funny-to-you/)

The transistor he uses is no longer available but I found two almost identical equivalents in through hole and surface mount packages. I will find out what their names are if anyone is interested.

Getting that flicker with hw, especially if it doesn't require an LED in the circuit would be pretty cool. Although if we had to use one of those "candle LEDs" it could be neat for a crystal chamber.
Title: Re: Arduino Lightsaber
Post by: Canobi on Jan 03, 2016, 07:59 pm
Getting that flicker with hw, especially if it doesn't require an LED in the circuit would be pretty cool.
I did look at other alternatives but none of them would have produced a flicker as random as candle LEDs do.
Title: Re: Arduino Lightsaber
Post by: Canobi on Jan 03, 2016, 10:12 pm
Anyone used a Leonardo before?

Found this and started wondering if it could be used for this sytem instead of the pro mini.

(http://i1225.photobucket.com/albums/ee395/Can-obi/IMG_20160101_145109.jpg) (http://s1225.photobucket.com/user/Can-obi/media/IMG_20160101_145109.jpg.html)
Title: Re: Arduino Lightsaber
Post by: JakeSoft on Jan 04, 2016, 01:52 am
Anyone used a Leonardo before?

Found this and started wondering if it could be used for this sytem instead of the pro mini.

(http://i1225.photobucket.com/albums/ee395/Can-obi/IMG_20160101_145109.jpg) (http://s1225.photobucket.com/user/Can-obi/media/IMG_20160101_145109.jpg.html)
Hmm, well it does have just barely enough I/O for my application. What does the price look like? It's tough to find anything cheaper than a Pro Mini which, aside from the size, was attractive to me when doing component selection.

Here is a the Arduino pinout of my Mk. IV system.

(http://i68.tinypic.com/2qsnlo2.jpg)
Title: Re: Arduino Lightsaber
Post by: Protonerd on Jan 04, 2016, 11:28 am
Have any of you experimented w/ the "shimmer" effect?  I'm playing around w/ the basic "fade" sketch to see if stepping one LED up while the other counts down, and adding in a bright and off to break up the pulse a bit.

Code: [Select]


int blue = 9;           // pure blue pwm
int rblue = 5;          // royal blue pwm
int brightblue = 150;   // minimum LED brightness
int brightrblue = 255;  // maximum LED brightness
int fadeAmount = 5;     // how many points to fade the LED by

void setup() {
  // declare pin 9 and 5 pints to be outputs
  pinMode(blue, OUTPUT);
  pinMode(rblue, OUTPUT);
}

void loop() {
  // set the brightness of the pins to high and low
  analogWrite(rblue, brightrblue);
  analogWrite(blue, brightblue);

  // true blue goes up while royal blue goes down
  brightblue = brightblue + fadeAmount;
  brightrblue = brightrblue - fadeAmount;

  // reverse the direction of the fading at the ends of the fade:
  if (brightblue == 150 || brightblue == 255) {
    fadeAmount = -fadeAmount ;
    // go bright and off to break up the straight pulsing effect
      analogWrite(rblue, 255);
      analogWrite(blue, 0);
  }
  // wait for 5 milliseconds to see the dimming effect
  delay(5);
}


Any other ideas on how to achieve a shimmer effect w/ 1-3 LEDs (vs a LED string)?
Best shimmer effect, which also works if you have single LED (or RGB) if you adjust the PWM of the drive based on the fluctuations of the sounds. How this is done is easy>
https://forum.arduino.cc/index.php?topic=361566.30
post #32

Main idea is to connect SPK- and SPK+ to one analog input each and in each loop convert the voltage on the speaker pins and adjust the drive of the LED(s) with a scaling of your choice. You can look at the video (observe the wall, the blade is simply too bright for the camera).
Title: Re: Arduino Lightsaber
Post by: jshaw on Jan 04, 2016, 04:16 pm
Best shimmer effect, which also works if you have single LED (or RGB) if you adjust the PWM of the drive based on the fluctuations of the sounds. How this is done is easy>
https://forum.arduino.cc/index.php?topic=361566.30
post #32

Main idea is to connect SPK- and SPK+ to one analog input each and in each loop convert the voltage on the speaker pins and adjust the drive of the LED(s) with a scaling of your choice. You can look at the video (observe the wall, the blade is simply too bright for the camera).
That's a really interesting idea. I've never thought about using speakers as input...  Now if only all of my parts would arrive.
Title: Re: Arduino Lightsaber
Post by: Canobi on Jan 05, 2016, 12:00 am
Hmm, well it does have just barely enough I/O for my application. What does the price look like? It's tough to find anything cheaper than a Pro Mini which, aside from the size, was attractive to me when doing component selection.

Here is a the Arduino pinout of my Mk. IV system.

(http://i68.tinypic.com/2qsnlo2.jpg)
OK, so I'm going to bite the bullet and change the accelerometer on the PCB for the ADXL to make a new set as it seems the most popular choice.

One thing is stumping me though. I noticed the ADXL's ground pin is attached to pin 13 on the pro mini in your MkIV diagram. I must be missing something, how come it's not attached to common?
Title: Re: Arduino Lightsaber
Post by: JakeSoft on Jan 05, 2016, 02:49 am
OK, so I'm going to bite the bullet and change the accelerometer on the PCB for the ADXL to make a new set as it seems the most popular choice.
Oh, cool. And yes, it is. It's the GY-61 is actually the smallest I've found so far. That's what I used.

One thing is stumping me though. I noticed the ADXL's ground pin is attached to pin 13 on the pro mini in your MkIV diagram. I must be missing something, how come it's not attached to common?
Because my software is magic! ;-)

The short answer is that it has to do with the hardware I used to build my Mk IV. prototype. It was just easier that way and I knew how to make the software handle it.
Title: Re: Arduino Lightsaber
Post by: T_R_O_N on Jan 05, 2016, 08:37 am
Hello everyone

I'm new to the forum, and I've been finding this thread very interesting, I would like to thank JakeSoft for sharing his ideas with us. So far I've read about half of the 21 pages, and the information has been very helpful, but I have a few questions. Hopefully no one has asked these questions before, and if they have, I hope it's alright for me to ask them again.

Firstly what programming knowlage do I need in order to work with the Arduino? I have a good basic understanding of Java, and a small ammount of C++

Secondly I'm having trouble with finding a place that sells sound modules for the Arduino in South Africa. So far the closest thing I've been able to get is this: https://www.robotics.org.za/index.php?route=product/product&path=65_152&product_id=1249

The only other sound module I could get costs more than the Arduino Pro Micro itself. Would it be possible to build the system without using a sound module, and then have the Arduino play the sound on its own? By use of a similar system to this: https://learn.adafruit.com/trinket-audio-player/sound-playback

I would appreciate any help, it is my first time building something with an Arduino, and I hope that I am not biting off more than I can chew.
Title: Re: Arduino Lightsaber
Post by: JakeSoft on Jan 05, 2016, 04:25 pm
Firstly what programming knowlage do I need in order to work with the Arduino? I have a good basic understanding of Java, and a small ammount of C++
There are people in this thread who have built a successful prototype who started with less. You should be fine as long as you are willing to do a lot of reading and learning on your own.

Secondly I'm having trouble with finding a place that sells sound modules for the Arduino in South Africa. So far the closest thing I've been able to get is this: https://www.robotics.org.za/index.php?route=product/product&path=65_152&product_id=1249
I always have to order my sound modules direct from China on Ebay. There are no distributors that I'm aware of in the U.S.A. either.

The only other sound module I could get costs more than the Arduino Pro Micro itself. Would it be possible to build the system without using a sound module, and then have the Arduino play the sound on its own? By use of a similar system to this: https://learn.adafruit.com/trinket-audio-player/sound-playback
Possible? Yes. Easy? Not really. You'd need to code up some kind of scheduler to handle processor loading so it was balanced between LED control, sensor I/O, and audio processing. You'd also likely have to add external storage of some kind to hold the sound files (SD card reader, for example). Add in all of these changes and the solution starts to look less and less like what is discussed here.

In this thread we pretty much stick to the WT588D as the workhorse for sound. This thread is the first and oldest on the topic, but be aware that others have surfaced lately that use different sound hardware. You may want to check some of those out too.

In this thread, racemaniac did his own audio processing. You might be able to glean something from there.
RGB Led String Lightsaber (https://forum.arduino.cc/index.php?topic=366701.0)

In this thread, Protonerd used a different audio module than we use here and reports good results.
Arduino Lightsaber for/with LED String Blade (https://forum.arduino.cc/index.php?topic=361566.0)


I hope that helps, and welcome to the forums.
Title: Re: Arduino Lightsaber
Post by: jonnieZG on Jan 05, 2016, 10:17 pm
@JakeSoft, is there a reason why you used a 3.3V Arduino instead a 5V version, since the WT588D is a 5V device? I am talking about the schematic in post #6. As far as I've learned by now, it is not recommended to mix 3.3V with 5V shields and vice versa... Am I missing something?

This is what I mean: http://jeelabs.org/2010/12/16/voltage-3-3-vs-5/ (http://jeelabs.org/2010/12/16/voltage-3-3-vs-5/)
Title: Re: Arduino Lightsaber
Post by: stinky1 on Jan 05, 2016, 10:24 pm
Howdy,  nother FNG question:

The WT588D and -WT588DU all seem to come with pre soldered pins.
The WT588D obviously needs the little green cpu clamp style programming box.
Though I see there is a adapter cable module for the WT588D
So I figure the WT588DU does not need to be in the board because of the USB.

But I see that all the modules come with the pins pre soldered in place,  so what do
you do?  De solder the pins so you can then attach the wires?  Or attach the wires to
the pins?

Also should I get a 16M or 32M one.  I want to order but If I have one doubt its a no go.

Title: Re: Arduino Lightsaber
Post by: JakeSoft on Jan 05, 2016, 11:44 pm
@JakeSoft, is there a reason why you used a 3.3V Arduino instead a 5V version, since the WT588D is a 5V device? I am talking about the schematic in post #6. As far as I've learned by now, it is not recommended to mix 3.3V with 5V shields and vice versa... Am I missing something?

This is what I mean: http://jeelabs.org/2010/12/16/voltage-3-3-vs-5/ (http://jeelabs.org/2010/12/16/voltage-3-3-vs-5/)
Hmm. Interesting read. I haven't had any problems so far, so I assume that the manufacturer of the sound board has designed the modules to handle VDD of 5V and 3.3V on VCC. Read back in this thread a bit and see the discussion BillPealer and I had about this exact topic. The summary is that if you are using the WT588D-u (with built-in USB) then you don't need a 3.3V supply in your project. If you use the 16-pin version then you do. I used the 16-pin version. Several people have built spin-off designs with 5V Minis, Nanos, etc. Feel free to use whatever you are conformable with or have on hand.
Title: Re: Arduino Lightsaber
Post by: Canobi on Jan 06, 2016, 12:16 am
Howdy,  nother FNG question:

The WT588D and -WT588DU all seem to come with pre soldered pins.
The WT588D obviously needs the little green cpu clamp style programming box.
Though I see there is a adapter cable module for the WT588D
So I figure the WT588DU does not need to be in the board because of the USB.

But I see that all the modules come with the pins pre soldered in place,  so what do
you do?  De solder the pins so you can then attach the wires?  Or attach the wires to
the pins?

Also should I get a 16M or 32M one.  I want to order but If I have one doubt its a no go.
I've swapped mine out for regular header pins cus those turned pins are effin horrible. As Jakesoft mentioned in an earlier post, they don't fit header sockets very well either.

In this case I've fixed them in long side up so the module will work with a programmer shield I've designed for post mounted WT modules. The fem headers fit nice and snug and mostly cover the solder bumps, though I went light with the solder and used just enough to surround each pin with a slight rise:

(http://i1225.photobucket.com/albums/ee395/Can-obi/IMG_20160105_224042.jpg) (http://s1225.photobucket.com/user/Can-obi/media/IMG_20160105_224042.jpg.html)


As to mem size, 16M should be plenty unless you plan to have multiple profiles with accompanying sound sets.
Title: Re: Arduino Lightsaber
Post by: Canobi on Jan 06, 2016, 03:08 am
I had a rather interesting idea for an arrangement so made a quick sketch. It's late and I'm tired and need to hit the sack so theres a lot of detail missing, I just aimed to capture the jist for deeper investigation later:

(http://i1225.photobucket.com/albums/ee395/Can-obi/IMG_20160106_014655.jpg) (http://s1225.photobucket.com/user/Can-obi/media/IMG_20160106_014655.jpg.html)
Title: Re: Arduino Lightsaber
Post by: stinky1 on Jan 06, 2016, 06:12 am
I'll definetly go with the WT588DU-32.  Cause i want a lot of sounds.

You use the programmer board, but I'm goin the USB I figure.

So then you would use female pin clips with wires on the module to make the connections?
Just like computer clips ahhhh... damn I'm dense.

Or do the boards come un-soldered and are not pictured that way on Yahoo?
Desoldering that long strip would put a lot of heat onto the board.   

The Arduino definitely comes un-soldered.

? For Jakesoft
Also what voltage rating "mosfets do you use on the led's?  I know that the red can't run as much
power as the Blue and Green.  You say you run at 1amp,  but I read they run at like
3 watts Blue and Green,  and like 2.3 for the Red.    So bust out that resistor calculator thing I suppose if I want to use resistors.  I have two 18650's I'm gonna use, for power.  So I'm wondering about the levels that I would want on the RGB 3w LED I'm gonna use.  I'll read other posts as well on CSS forums.  I guess they all use 350 mah, Voltage(Vf): Red:2.0-2.5V Green:3.2-3.6V Blue:3.2-3.86.  So again mosfets, buckpucks, and capacitors. 
Maybe this?
http://www.ebay.com/itm/Water-Proof-Power-Supply-LED-Driver-for-3x3w-10w-20w-30w-50w-100w-SMD-LED-Light-/321813500544?var=&hash=item4aed945280:m:mn8PQXKV_jQqUiSktcQGv7A
As I hit the next part purchase I'm asking whats perplexin me.



Told ya I'm a noob,  If I had to write the above from memory,  good luck lol!

Ok time to order parts.




Title: Re: Arduino Lightsaber
Post by: billpealer on Jan 06, 2016, 04:25 pm
Hmm. Interesting read. I haven't had any problems so far, so I assume that the manufacturer of the sound board has designed the modules to handle VDD of 5V and 3.3V on VCC. Read back in this thread a bit and see the discussion BillPealer and I had about this exact topic. The summary is that if you are using the WT588D-u (with built-in USB) then you don't need a 3.3V supply in your project. If you use the 16-pin version then you do. I used the 16-pin version. Several people have built spin-off designs with 5V Minis, Nanos, etc. Feel free to use whatever you are conformable with or have on hand.
The VDC-in for the WT for both versions is 2.8 -5.5v as reported by the manufacturer, and they have to at the VDD pin22. (although they show 3.3-5v in their wiring diagrams)  I have not heard of anyone saying their WT will NOT work with over 3.3v and less than 5.5v.  I think Mr. Jake said his WT non-usb will NOT work if he did not include the Vcc AND Vdd inputs. Both.  I have a connection from the Arduino Nano 5vpin going to the WT VDD and my WT VCC pin is vacant. As per my sketch.  Have you tried to eliminate the VCC on your WT and just send 5V direct to the WT's VDD via your 5v regulator, and skip a solder point, Jake?

I think it is safe to assume you do not "NEED" 3.3v for the WT at all for either model.  I think volume was the main reason you made your decision to include 5v to the WT, right Jake?  I am not super versed but VCC and VDD supply power in slightly different ways if the manufacture is labeling properly.  VCC powers a bipolar transistor and VDD powers a FET. I do not know how this may effect the WT's operations. But i do know that i don't use the VCC pin on the WT.  I also don't use the non usb version,  so speculation is in play.
Title: Re: Arduino Lightsaber
Post by: billpealer on Jan 06, 2016, 04:41 pm
Because my software is magic! ;-)
Magic?!
oye.  Dude, what do you use the BusyPin for?  it is not being called to do anything in the WTSendCommand.


Title: Re: Arduino Lightsaber
Post by: JakeSoft on Jan 06, 2016, 05:59 pm
Have you tried to eliminate the VCC on your WT and just send 5V direct to the WT's VDD via your 5v regulator, and skip a solder point, Jake?
Yes, I did try it. I didn't work. I first used the WT588D-u and assumed I could wire the 16p the same way; you can't. Please, someone else try this and confirm, but it never works for me unless I put voltage to both the VDD and VCC pins on the 16-pin modules.

Dude, what do you use the BusyPin for?  it is not being called to do anything in the WTSendCommand.
I use it for a few things in my code. The most important is sound calibration. I never show it in my videos, but I have a routine that plays each sound and measures how long it took to play and then stores off that timing data. Notice how my blade ramp-up and ramp-down effects are closely synchronized with the power-up and power-down sounds? Notice how my clash sounds are never interrupted by a swing sound? I know how long each sound takes to play. Those values are not hard-coded, they are dynamically captured. This allows me to change sounds without having to recompile my code.
Title: Re: Arduino Lightsaber
Post by: billpealer on Jan 06, 2016, 07:47 pm


I use it for a few things in my code. The most important is sound calibration. I never show it in my videos, but I have a routine that plays each sound and measures how long it took to play and then stores off that timing data. Notice how my blade ramp-up and ramp-down effects are closely synchronized with the power-up and power-down sounds? Notice how my clash sounds are never interrupted by a swing sound? I know how long each sound takes to play. Those values are not hard-coded, they are dynamically captured. This allows me to change sounds without having to recompile my code.
i thought you used it to get the 3axis to ground.  but i think any pin set to input and LOW in Arduino is ground.
Title: Re: Arduino Lightsaber
Post by: JakeSoft on Jan 06, 2016, 08:35 pm
i thought you used it to get the 3axis to ground.  but i think any pin set to input and LOW in Arduino is ground.
Did you quote the correct post? I was talking about the WT588D sound module but now you seem to be talking about the ADXL335 accelerometer. You are correct however that any pin set LOW then effectively becomes a ground. I did exploit that when I soldered the ADXL335 GND pin to an arduino I/O pin. I just set the I/O pin to ground and it works great.
Title: Re: Arduino Lightsaber
Post by: billpealer on Jan 06, 2016, 09:47 pm
Did you quote the correct post? I was talking about the WT588D sound module but now you seem to be talking about the ADXL335 accelerometer. You are correct however that any pin set LOW then effectively becomes a ground. I did exploit that when I soldered the ADXL335 GND pin to an arduino I/O pin. I just set the I/O pin to ground and it works great.
no missquote,..  but i thought your "magic software" was going to tie in the WT BusyPin to arduino pin13 and then the ground of the 3axis.  from how i understand the busypin,  it is more or less a ground gate.  opening and closing ground when the sound module is actively playing sound.  like how a MOSFET works.  a ground switch.

I have over come my audio triggers by only using 5 sounds, and i know the duration in ms for each.  i do though have my swing sound delays shorter than their actual duration,.  so a Swing can lead to a Clash prior to the swing resolving.  but a clash will always resolve to full decay. then allow for another swing, or clash there after.

in the Hasbro sabers there are 2 swing sounds..  a single and double. 

it would be cool, if you could in the code make it read a clash to lock up, as a clash sensor trigger with no swing trigger,..  meaning a clash followed by NO movement would inherently be a bind or lock up. play lock up sound and loop it till movement,.. ie  a swing or clash.  i have tried with no avail.
Title: Re: Arduino Lightsaber
Post by: Protonerd on Jan 06, 2016, 10:32 pm
I guess it would be quite a challenge to "motion detect" a blade lock-up...even when the blades collide, the opponents try to force they way past the guard of the other and they struggle, i.e. there is still constant motion. That is why usually a 2nd switch is used to trigger a lock-up (I use the same as the one used to trigger blaster block and used to step through the different sound fonts).
Title: Re: Arduino Lightsaber
Post by: JakeSoft on Jan 06, 2016, 11:10 pm
I guess it would be quite a challenge to "motion detect" a blade lock-up...even when the blades collide, the opponents try to force they way past the guard of the other and they struggle, i.e. there is still constant motion. That is why usually a 2nd switch is used to trigger a lock-up (I use the same as the one used to trigger blaster block and used to step through the different sound fonts).
Yeah, I did something similar on mine with a second button. You can see it in action in my Mk. II video. It's equivalent to the the infamous "aux switch" that the commercial sound cards sometimes employ. It does kind of break the illusion of being in a real saber fight because you have to remember to push the button, but it seem to be the standard way to handle it in a way that is reliable and the user can trigger it at appropriate times vs. trusting the software to figure out what's going on in the fight. It is still an interesting idea to try to have it happen automatically, but I'm not sure how you'd do it consistently. Maybe a quick press of the aux or activation switch would prime it such that the next clash impact event would trigger a lockup sound instead of a clash? I like mine the way it is, but that might work if someone wants to try it.
Title: Re: Arduino Lightsaber
Post by: Canobi on Jan 07, 2016, 03:12 am
How about making a loop out of a length of force sensitive resistor strip to fit inside the rim of the blade seat/emitter neck?

 https://www.sparkfun.com/products/9674 (https://www.sparkfun.com/products/9674)

ok, so I'm only guessing at this point which means it's probably not quite as simple as I make out but could the coding go something like:  If resistance drops below x threshold for y amount of time, you have a "trigger lockup sound" scenario?

While I'm on that train of thought, could the resistance threshold setting could be made adjustable as well to give different sensitivity levels?
Title: Re: Arduino Lightsaber
Post by: jshaw on Jan 07, 2016, 03:30 am
How about making a loop out of a length of force sensitive resistor strip to fit inside the rim of the blade seat/emitter neck?

 https://www.sparkfun.com/products/9674 (https://www.sparkfun.com/products/9674)

ok, so I'm only guessing at this point which means it's probably not quite as simple as I make out but could the coding go something like:  If resistance drops below x threshold for y amount of time, you have a "trigger lockup sound" scenario?

While I'm on that train of thought, could the resistance threshold setting could be made adjustable as well to give different sensitivity levels?
I'm not sure a ring of it would even be necessary. In theory, a lock up would be pressure from the front of the blade, meaning that the base of the blade would be pushing forward. So, if one were to countersink one of these on the front of the blade chassis, then I think one could detect a lockup based on duration of pressure.  Theoretically, of course.
Title: Re: Arduino Lightsaber
Post by: ryang on Jan 07, 2016, 10:43 am
I'm not sure a ring of it would even be necessary. In theory, a lock up would be pressure from the front of the blade, meaning that the base of the blade would be pushing forward. So, if one were to countersink one of these on the front of the blade chassis, then I think one could detect a lockup based on duration of pressure.  Theoretically, of course.
That sounds like it would work quite well.  You'd have to always have the lightsaber the one way though.  Align it with the switch to your natural hold, would suffice.

Adafruit calls it like it is though - https://www.adafruit.com/products/166
"These sensors are fairly low cost, and easy to use but they're rarely accurate. They also vary some from sensor to sensor perhaps 10%. So basically when you use FSR's you should only expect to get ranges of response."

And it's a log scale as well, so you'd hope the pressure would be sufficiently different to it's "resting" pressure..  Would need investigation!!  :)
Title: Re: Arduino Lightsaber
Post by: Canobi on Jan 07, 2016, 01:20 pm
Wish I could code, I'd have been way down that path of investigation  long ago lol.

According to the data sheet, like normal resistors there are different values that have different pressure ranges (up to 50kg) so one would need to be found that would work for the lockup (something like 12~20kg would be ok, I don't think anyone wants to risk breaking a poly blade even if they are pretty robust).

Widening the voltage threshold range would help deal with the strips response inaccuracies but a hunch tells me the key to the lockup working is the time thresholds.

but a ring would negate the need to have the hilt oriented as it would be able to sense pressure from the whole 360° radius.

I suppose you could line the hilt with multiple strips in parallel but in order to avoid gaps you'd need 10x the length in total and a slew of extra wiring to achive the same sense raduis.
Title: Re: Arduino Lightsaber
Post by: Canobi on Jan 07, 2016, 02:03 pm
Here is a the Arduino pinout of my Mk. IV system.

(http://i68.tinypic.com/2qsnlo2.jpg)
To make routing on a one sided PCB a little more straightforward I may have to shuffle the pin list a bit.

As a small precaution I'm going to stick to the power rail setup as it is so the WT's GND reference won't need accounting for in code as it could be a pitfall for the unwary adventurer.

Out of interst, is the accent LED you're term for the FoC LED? I couldn't see a reference to it in the diagram and only count 3 fets.
Title: Re: Arduino Lightsaber
Post by: jshaw on Jan 07, 2016, 02:08 pm
Wish I could code, I'd have been way down that path of investigation  long ago lol.

According to the data sheet, like normal resistors there are different values that have different pressure ranges (up to 50kg) so one would need to be found that would work for the lockup (something like 12~20kg would be ok, I don't think anyone wants to risk breaking a poly blade even if they are pretty robust).

Widening the voltage threshold range would help deal with the strips response inaccuracies but a hunch tells me the key to the lockup working is the time thresholds.

but a ring would negate the need to have the hilt oriented as it would be able to sense pressure from the whole 360° radius.

I suppose you could line the hilt with multiple strips in parallel but in order to avoid gaps you'd need 10x the length in total and a slew of extra wiring to achive the same sense raduis.
My issues with the strip are
1. It's really long, far too long to fit in the hilt
2. Running them up the blade would affect the lighting

 Finding the proper combination of timing and amount of pressure would be tricky. Once I have the basics working, I might experiment with this.
Title: Re: Arduino Lightsaber
Post by: billpealer on Jan 07, 2016, 03:23 pm
My issues with the strip are
1. It's really long, far too long to fit in the hilt
2. Running them up the blade would affect the lighting

 Finding the proper combination of timing and amount of pressure would be tricky. Once I have the basics working, I might experiment with this.
plus the blade tension screw puts as much if not more force on the side wall of the blade holder (emmitter) than smacking it.

depending on how you tighten that screw could/would give false positives.

i think i can do it with the analog switches and specific parries if the sensors are oriented properly.

anyone have any base button code for procedural events?  i am thinking something like this

so:
Code: [Select]

int CL_sensor = 9  //sensor button pin
int SW_Sensor = 10 // swing sensor pin
long time = 0  //time of nothing
long debounce = 150 //150ms is the margin of error to determine a legit clash or false positive
bool lock_sound

setup
digitalWtite(CL_sensor,HIGH);
digitalWtite(SW_sensor,HIGH);
lock_sound = false;

void loop()
{

  // if the clash sensor was toggled and not just held at a state for less than 150ms
 
 if (digitalRead(CL_sensor) == HIGH && digitalRead(CL_sensor) == LOW && millis() - time > debounce && (digitalRead(SW_sensor) == HIGH   // the clash sensor was triggered AND the swing sensor is at rest in the closed state, such that the blade is horizontal aka saber parry 5
{   
 
   if (lock_sound)

     lock_sound = false;
     delay(5);  // do nothing.  get coffee but be back in 5 ms
 else
      lock_sound = true;
      WT_send_command(6); // clash sound followed by 3 seconds of lock up sound then hum sound
      delay(800);  // enough time for the clash to play thru to lock up but allow for additional input there after

    time = millis();   
  }
}

i haven't even begun to test that kind of logic.  i am waiting for some hardware.
Title: Re: Arduino Lightsaber
Post by: JakeSoft on Jan 07, 2016, 03:55 pm
To make routing on a one sided PCB a little more straightforward I may have to shuffle the pin list a bit.

As a small precaution I'm going to stick to the power rail setup as it is so the WT's GND reference won't need accounting for in code as it could be a pitfall for the unwary adventurer.
That's fine. I can shuffle the pins around somewhat without much effort. There are just a few limitations that have to be adhered to:

1) The 4 LEDs must be on PWM capable pins (they have little white circles around them on the silk screen in the picture I posted)
2) The X, Y, and Z accelerometer inputs must go to analog inputs (A1, A2, etc.).
3) Clash sensor must be in pin 2.

If you make the PCB just ignore the AXDL335 VDD and VCC pins on the arduino, that's fine; my software will still work if it's powered more directly by a 3.3V power rail. If the accelerometer pins are left as is, you could just map the X, Y, and Z inputs to the module and ignore the ones I'm using as power pins, don't give them a trace at all. That way the module could either be piggy-backed on the arduino or use your board's mapping. It also opens the door to  making a shorter, simpler version of your PCB with no mapping for the accelerometer pins at all, assuming it would be piggybacked.

Out of interst, is the accent LED you're term for the FoC LED? I couldn't see a reference to it in the diagram and only count 3 fets.
The accent LED is for lighted switches or indicator lights. In my videos, that is the output that is controlling the blinking of the LED in the ring switches that I use. It's an optional indicator light.
Title: Re: Arduino Lightsaber
Post by: Protonerd on Jan 07, 2016, 06:21 pm
I missed the part of the discussion focusing on the sound module, so maybe it is somewhere there in this thread...

My current build focuses on another MP3 player chip, which does the job wonderfully, but needs a micro SD. Not bad, but I'm lately looking at a solution which can (re)-use the micro USB of the Arduino to upload the files to the MP3 chip. Can the WT588d in cooperation with the Arduino Nano somehow handle it? That would be a great solution, which would even top the commercially available saber boards, which currently also have an micro SD.

So what I want:
- changing sound files using USB from PC directly

What I do not want:
- micro SD card
- programmer module
- 2 USD connectors
Title: Re: Arduino Lightsaber
Post by: JakeSoft on Jan 07, 2016, 06:45 pm
I missed the part of the discussion focusing on the sound module, so maybe it is somewhere there in this thread...

My current build focuses on another MP3 player chip, which does the job wonderfully, but needs a micro SD. Not bad, but I'm lately looking at a solution which can (re)-use the micro USB of the Arduino to upload the files to the MP3 chip. Can the WT588d in cooperation with the Arduino Nano somehow handle it? That would be a great solution, which would even top the commercially available saber boards, which currently also have an micro SD.

So what I want:
- changing sound files using USB from PC directly

What I do not want:
- micro SD card
- programmer module
- 2 USD connectors
I think the UltraSabers board does this already, but I agree it would be a nice feature.

You should get in touch with purgedsoul on this forum. He claims to have cracked programming the WT588D by directly connecting to the on board flash via SPI. He posted some code in this thread: http://forum.arduino.cc/index.php?topic=227435.15 (http://forum.arduino.cc/index.php?topic=227435.15). I have been meaning to try it, but alas, only so much time to devote and I have not gotten to it yet.

I don't see a lot of details about wiring, so if you figure that out then please check back with us and let us know how to do it.
Title: Re: Arduino Lightsaber
Post by: billpealer on Jan 07, 2016, 06:52 pm
- 2 USD connectors
USD?
neither require connectors.  one off the shelf mini usb cable works. I wonder if you could fuse the 2 ports.....
i have the Nano and WT module on a stack  the USBs are right next to each other,  you just pull it out the chassis, plug in the USB for arduino, and if you need to make a change to the WT, stick it in the other hole. It's all SORTS of fun.  pull it out, put it back,..  repeat. :) (that part you laugh at Canobi)  What is the goal with one port?  Are you trying to seal the hilt? Make an un-tinkerable sellable thing-a-maroo? I like my hilt open-able. Swapping batts is better than charging IME.

Title: Re: Arduino Lightsaber
Post by: Canobi on Jan 07, 2016, 09:14 pm
My issues with the strip are
1. It's really long, far too long to fit in the hilt
2. Running them up the blade would affect the lighting

 Finding the proper combination of timing and amount of pressure would be tricky. Once I have the basics working, I might experiment with this.
The strip can be cut to the correct length without issue and it's only 15.2mm wide so should fit above or below the retention screw.
Title: Re: Arduino Lightsaber
Post by: Dizzyua on Jan 07, 2016, 09:22 pm
Maybe someone know if I can programming arduino pro mini ATMEGA328 and sound module WT588D-16p via this device http://www.aliexpress.com/snapshot/7181287510.html?orderId=71709818091103 ?

And second question: If not maybe Arduino NANO V3.0 (with usb connector) and sound module WT588D-16p can help me with it? I can connect both boards and programming both about sensor reactions and write sound files for motions?
Title: Re: Arduino Lightsaber
Post by: JakeSoft on Jan 08, 2016, 03:27 am
Lots of people have asked for parts lists. There are TONs of options, but here is a list of parts I've used for the Mk. III and Mk. IV systems.

1) Arduino Pro Mini:  3.3V/8MHz version
2) WT588D:            WT588D 16p (16-Pin version, with 8M or 16M flash)
3) 16-pin DIP socket: (Digikey PN ED3046-5-ND) (Link (http://www.digikey.com/product-detail/en/ED16DT/ED3046-5-ND/4147596))
4) MOSFETS:           Farchild RFD14N05L (Link (http://www.digikey.com/product-detail/en/RFD14N05L/RFD14N05L-ND/458750))
5) Clash Sensor:      SW-18020P (Link (http://www.ebay.com/itm/like/281370202884?ul_noapp=true&chn=ps&lpid=82))
6) Accelerometer: GY-61 ADXL335 (Link (http://www.ebay.com/itm/ADXL335-3-axis-Analog-Output-Accelerometer-Module-angular-transducer-for-Arduino-/310508944191?hash=item484bc67b3f:g:nS4AAOxyE-dRyoiF))
 
Voltage regulator depends on intended power source. For lower voltage batteries, say 3.7 to 6 Volts, use

7a) 3.3V Regulator:    Digikey PN MCP1825S-3302E/AB-ND

For higher voltage batteries (like 7.4V) use:

7b) 5v Regulator:      Digikey PN 576-1143-ND (Link (http://www.digikey.com/product-detail/en/MIC29500-5.0WT/576-1143-ND/771612))
Title: Re: Arduino Lightsaber
Post by: ryang on Jan 08, 2016, 03:36 am
plus the blade tension screw puts as much if not more force on the side wall of the blade holder (emmitter) than smacking it.

depending on how you tighten that screw could/would give false positives.
The screw would be acting as a cantilever in this case, the force from the blade would be redirected to the bottom of the blade on the opposite side.  Again, you'd have to calibrate the sensor first after tightening the screw, but you'll still see an increase in the force on hit.

i think i can do it with the analog switches and specific parries if the sensors are oriented properly.

anyone have any base button code for procedural events?  i am thinking something like this
I don't think you'd even need a 2nd button.  Assuming you're only using the button for on/off (momentary press), you could program it to clash when the button is held before/during/after a hit.
Title: Re: Arduino Lightsaber
Post by: stinky1 on Jan 08, 2016, 04:09 am
Wow great timing Jakesoft!  i have been reading about putting in resistors and how to figuring out
the Ohms for them.  I understand that now.

But you use the Mosfets to control the RGB LEDs.  So the Mosfet is like the resistor, limiting the voltage,   but allowing the dimming of the LED's through the Arduino coding.

I am planning on using this RGB star:  http://www.ebay.com/itm/1pcs-3W-RGB-LED-3-CHIP-6-Pin-Bead-Lamp-LED-Star-Light-/121149855858?hash=item1c35181872:g:xOgAAOxyYSJR8iHf

With these specs:
Forward Voltage VF (V) :  red (min 1.9, typ 2.2, max 3.1),Green/Blue (min 2.8, typ 3.5, max 4.0)
DC Forward Current (mA) :  red 385 ,Green/Blue 350
Average Forward Current (mA) : red 350, Green/Blue 350

People are using the Luxeon,  and I see them saying 700 to 1,000 mah.  So is that the total mah
combined from the 3 LED's  Or are the Luxeons more powerful?  
http://www.ledsupply.com/leds/luxeon-rebel-endor-star-rgb-high-power-led

           voltage          Min     TYP   MAX
Green LXML-PM01 2.55  2.90 3.51 -2.0 to -4.0 10
Blue LXML-PB01        2.55 3.03 3.51 -2.0 to -4.0 10
Red LXML-PD01        2.31 2.90 3.51 -2.0 to -4.0 12
Red LXM2-PD01 1.80 2.10 2.80 -2.0 to -4.0 8

So I guess they are comparable, and the Mosfets you specified above will work fine?

Sorry for the basic electronic questions,  I understand the coding better as I have
done BASIC programming.  

I have found some nice links today that explained it well for resistors:

http://electronics.stackexchange.com/questions/48522/what-resistor-to-use-with-this-rgb-led

http://forums.thecustomsabershop.com/showthread.php?14081-Tutorial-Calculating-Resistor-Values

Thanks I'm goin to play with the hotlinks on the parts list now  ;-)>
Title: Re: Arduino Lightsaber
Post by: jshaw on Jan 08, 2016, 04:23 am
Have any of you looked into in-hilt charging yet?  I know that battery swaps are much preferred as they should be fast and simple (assuming you design your sled/chassis appropriately), but I also like the idea of being able to charge the battery without pulling it.

I'm thinking that the SparkFun LiPoly Charger ( https://www.sparkfun.com/products/12711 ) should work? 
Title: Re: Arduino Lightsaber
Post by: ryang on Jan 08, 2016, 04:25 am
Have any of you looked into in-hilt charging yet?  I know that battery swaps are much preferred as they should be fast and simple (assuming you design your sled/chassis appropriately), but I also like the idea of being able to charge the battery without pulling it.
Looked at it and decided to just run removable battery packs.  I'm also being povo and running 4x AA Eneloops.. :)
Title: Re: Arduino Lightsaber
Post by: jshaw on Jan 08, 2016, 04:48 am
Wow great timing Jakesoft!  i have been reading about putting in resistors and how to figuring out
the Ohms for them.  I understand that now.

But you use the Mosfets to control the RGB LEDs.  So the Mosfet is like the resistor, limiting the voltage,   but allowing the dimming of the LED's through the Arduino coding.

I am planning on using this RGB star:  http://www.ebay.com/itm/1pcs-3W-RGB-LED-3-CHIP-6-Pin-Bead-Lamp-LED-Star-Light-/121149855858?hash=item1c35181872:g:xOgAAOxyYSJR8iHf

With these specs:
Forward Voltage VF (V) :  red (min 1.9, typ 2.2, max 3.1),Green/Blue (min 2.8, typ 3.5, max 4.0)
DC Forward Current (mA) :  red 385 ,Green/Blue 350
Average Forward Current (mA) : red 350, Green/Blue 350

People are using the Luxeon,  and I see them saying 700 to 1,000 mah.  So is that the total mah
combined from the 3 LED's  Or are the Luxeons more powerful? 
http://www.ledsupply.com/leds/luxeon-rebel-endor-star-rgb-high-power-led

           voltage          Min     TYP   MAX
Green LXML-PM01 2.55  2.90 3.51 -2.0 to -4.0 10
Blue LXML-PB01        2.55 3.03 3.51 -2.0 to -4.0 10
Red LXML-PD01        2.31 2.90 3.51 -2.0 to -4.0 12
Red LXM2-PD01 1.80 2.10 2.80 -2.0 to -4.0 8

So I guess they are comparable, and the Mosfets you specified above will work fine?

Sorry for the basic electronic questions,  I understand the coding better as I have
done BASIC programming. 

I have found some nice links today that explained it well for resistors:

http://electronics.stackexchange.com/questions/48522/what-resistor-to-use-with-this-rgb-led

http://forums.thecustomsabershop.com/showthread.php?14081-Tutorial-Calculating-Resistor-Values

Thanks I'm goin to play with the hotlinks on the parts list now  ;-)>

The Luxeons are more high powered than many of the other off-the-shelf brands.  Their website provides tons of information regarding their various LEDs.  For the triple LED setup, check these: http://www.luxeonstar.com/sinkpad-20mm-tristar-leds
Title: Re: Arduino Lightsaber
Post by: stinky1 on Jan 08, 2016, 05:05 am
The Luxeons are more high powered than many of the other off-the-shelf brands.  Their website provides tons of information regarding their various LEDs.  For the triple LED setup, check these: http://www.luxeonstar.com/sinkpad-20mm-tristar-leds
Yikes!!!  Thats out of my price range!!!  I need the 23 dollars for a cheapo ESD solder gun!!

So yeah, mosfets that match the cheapo Star, besides I like the idea the LED's all fit neatly
under the lens.  The open spread apart LED stars need different lens.  Guess i should say I'm goin
low budget as I can.
Title: Re: Arduino Lightsaber
Post by: ryang on Jan 08, 2016, 05:20 am
Yikes!!!  Thats out of my price range!!!  I need the 23 dollars for a cheapo ESD solder gun!!
Take a look at some of the genuine Cree's - they're super bright and a bit cheaper.  Well, depending on what you want...  I found a local supplier who stuck a single blue to a 25mm star for ~$8, and did a 2x red, 1x white for ~$20.
Title: Re: Arduino Lightsaber
Post by: T_R_O_N on Jan 08, 2016, 09:47 am
Thanks for the advice JakeSoft.

So far I think I'm going to go for an Arduino nano, a wt588d-u, and an adxl345 accelerometer.

I'm also looking at getting this book: Programing Arduino Getting Started with Sketches  (http://www.amazon.com/gp/aw/d/B006GMVISY/ref=mp_s_a_1_1?qid=1452241888&sr=1-1&pi=SY200_QL40&keywords=Arduino&dpPl=1&dpID=51XbQX5lh6L&ref=plSrch)

Do I still need to use a vibration sensor to detect clashes, or could I have the adxl345 handle both the clash, and swing detection?

Title: Re: Arduino Lightsaber
Post by: Protonerd on Jan 08, 2016, 01:27 pm
USD?
neither require connectors.  one off the shelf mini usb cable works. I wonder if you could fuse the 2 ports.....
i have the Nano and WT module on a stack  the USBs are right next to each other,  you just pull it out the chassis, plug in the USB for arduino, and if you need to make a change to the WT, stick it in the other hole. It's all SORTS of fun.  pull it out, put it back,..  repeat. :) (that part you laugh at Canobi)  What is the goal with one port?  Are you trying to seal the hilt? Make an un-tinkerable sellable thing-a-maroo? I like my hilt open-able. Swapping batts is better than charging IME.


:) I meant USB port (micro one...) And yeah, that thing with in and out is fun in another context, but wrt electronics it could be done better. I also thought about simply wiring the signals together and let the modules sort out what message is for whom, but never got around to try it.

As to enclosed saber: is there something like that? I mean, all custom saber need access to the inside. What I have in in-hilt charging for most of my sabers, comfortable to charge and the rechargable 3.7V batteries are better in terms of room/capacity as AAA/AA. Still I have to admit that I came to hate the recharge port and now looking for alternatives...

But looking at the most popular saber building sites, in-hilt charging is the preferred way, not battery swap.

@jshaw: wow, that is a good find! I will sure look into that module. I'm curious if the charging curve fits those required by mainstream 3.7V batteries.
Title: Re: Arduino Lightsaber
Post by: Canobi on Jan 08, 2016, 02:11 pm
Looking into one using the MCP73833. The circuit for it is smaller than the cell it charges which opens up many possibilities.
Title: Re: Arduino Lightsaber
Post by: Canobi on Jan 08, 2016, 02:21 pm
That's fine. I can shuffle the pins around somewhat without much effort. There are just a few limitations that have to be adhered to:

1) The 4 LEDs must be on PWM capable pins (they have little white circles around them on the silk screen in the picture I posted)
2) The X, Y, and Z accelerometer inputs must go to analog inputs (A1, A2, etc.).
3) Clash sensor must be in pin 2.

If you make the PCB just ignore the AXDL335 VDD and VCC pins on the arduino, that's fine; my software will still work if it's powered more directly by a 3.3V power rail. If the accelerometer pins are left as is, you could just map the X, Y, and Z inputs to the module and ignore the ones I'm using as power pins, don't give them a trace at all. That way the module could either be piggy-backed on the arduino or use your board's mapping. It also opens the door to  making a shorter, simpler version of your PCB with no mapping for the accelerometer pins at all, assuming it would be piggybacked.

The accent LED is for lighted switches or indicator lights. In my videos, that is the output that is controlling the blinking of the LED in the ring switches that I use. It's an optional indicator light.
Thanks for the heads up on the PWM markings and pin designations, forgot they were fixed position.


I'm always looking for ways to make my boards smaller and Bill's genius stack gave me an idea (thanks Bill :) ). I've had a play with some strip board and various headers to find a workable arrangement. I hate making circuits with strip board but I do use it like lego for working out physical dimentions and arrangements.

Size wise, it would fit hilts with a minimum ID of 28mm if the headers are used in the regular fashion. However, it would be possible to lower the depth by modifying some of the male headers mid assembly and mounting one or two modules flush to the board (the pro mini and WT can both do this as there's no surface mount components on the flip side of them).

As to the layout I'm reworking now, I've used the Spectrum as the template as it supperts upto 6 LEDs. Here's what the pin list looks like:

2= Clash sensor
3= NFET gate1 (FoC LED)
5= NFET gate2
6= NFET gate3
7= PWR button
8= AUX button
9= NFET gate4

10= Accent LED 1
11= Accent LED 2
12= BUSY
13= SCK
A0= X
A1= Y
A2= Z



As it didn't seem likely that anyone would want to change the white LED for a different colour, I've opted to include an SMT resistor on the PCB for 1,2 and 3w setups and resurved output channel 1 (gate 1) exclusively for the FoC function since the LEDs Vf and power ratings will be a fixed point.

The other three LED output channels have been left resistor free however. Regular resistors will need putting in series with the LEDs in the usual fashion but setting it up this way allows the PCB to suppert custom and regular colour swap outs regardless of voltage or watt.
Title: Re: Arduino Lightsaber
Post by: JakeSoft on Jan 08, 2016, 04:38 pm
Thanks for the heads up on the PWM markings and pin designations, forgot they were fixed position.


I'm always looking for ways to make my boards smaller and Bill's genius stack gave me an idea (thanks Bill :) ). I've had a play with some strip board and various headers to find a workable arrangement. I hate making circuits with strip board but I do use it like lego for working out physical dimentions and arrangements.

Size wise, it would fit hilts with a minimum ID of 28mm if the headers are used in the regular fashion. However, it would be possible to lower the depth by modifying some of the male headers mid assembly and mounting one or two modules flush to the board (the pro mini and WT can both do this as there's no surface mount components on the flip side of them).
This sounds interesting. It seems like you've really only got two options to make the system space efficient:
1) Make it long and as flat as possible, so you could possibly mount the circuits on top of a battery
2) Make it short and fat by stacking the modules on top of each other

Do keep in mind though, that you'll want to keep these as accessible as possible for hobbyists if you intend others to assemble them. Many are operating with $20 soldering irons and so-so soldering skills. One reason one might be interested in building their own sound board is that $100+ commercial sound boards are too expensive for them. If they need a $100 soldering station to build the board, then they aren't really ahead of the game unless they plan to build a lot of them. If you intend to sell completed boards, however, go for it and use all the tricks you have at your disposal to make it small as possible.

As to the layout I'm reworking now, I've used the Spectrum as the template as it supperts upto 6 LEDs. Here's what the pin list looks like:

2= Clash sensor
3= NFET gate1 (FoC LED)
5= NFET gate2
6= NFET gate3
7= PWR button
8= AUX button
9= NFET gate4

10= Accent LED 1
11= Accent LED 2
12= BUSY
13= SCK
A0= X
A1= Y
A2= Z

I think I can work with this pin arrangement. I'll experiment on my breadboard when i can get the time. I don't currently have a dedicated FOC LED, just the 3 for R/Gr/B, but I could add one easily enough. I don't have a second accent LED either, but it's OK if that output doesn't do anything for now, right?

As it didn't seem likely that anyone would want to change the white LED for a different colour, I've opted to include an SMT resistor on the PCB for 1,2 and 3w setups and resurved output channel 1 (gate 1) exclusively for the FoC function since the LEDs Vf and power ratings will be a fixed point.
Is that true? What LED are you assuming people will use for FOC? Cree and Luxeon have different specs. What battery source voltage are you assuming? What if somebody wants to use a different color LED for dedicated FOC?
Title: Re: Arduino Lightsaber
Post by: billpealer on Jan 08, 2016, 07:54 pm
:) I meant USB port (micro one...) And yeah, that thing with in and out is fun in another context, but wrt electronics it could be done better. I also thought about simply wiring the signals together and let the modules sort out what message is for whom, but never got around to try it.

As to enclosed saber: is there something like that? I mean, all custom saber need access to the inside. What I have in in-hilt charging for most of my sabers, comfortable to charge and the rechargable 3.7V batteries are better in terms of room/capacity as AAA/AA. Still I have to admit that I came to hate the recharge port and now looking for alternatives...

But looking at the most popular saber building sites, in-hilt charging is the preferred way, not battery swap.

@jshaw: wow, that is a good find! I will sure look into that module. I'm curious if the charging curve fits those required by mainstream 3.7V batteries.
i would wire the USBs together.  if you have the extra parts, and aptitude and dexterity to do that,..  i would.  i am fairly certain the drivers and software for each thing will sort out the programming.  meaning the WT programmer will not try to shove a bin file to the arduino. and Vice Versa.

i use the nano and wtU.  they both employ usb mini ports.  easy peasy.   just programmed an attiny85 with built in usb. Programming that was a major pain.  from finding the right drivers and technique to program it with out using another arduino as the uploader.  that was 4 evenings i'll never get back. But i am dying to test it as the mcu. it's small. no "input_pullup" function by the way. pin3 has a pullup resistor,..  "input" works in its stead. tested.   tween that and adding pwm to my LEDs. and figuring out a repeatable lock up with out another hilt button.    busy busy.  oh and my method of using the same mosfet to toggle power to the WT and LED will not work if i add PWM.  it was geeking the WT for whatever reason. i think it was resetting it.  anyone have a hypothesis? i'll need 2 mosfets for LED PWM.  one for PWM for the LED, and the other HIGH/LOW for the WT mosfet.  oh well.  2 mosfets.  also,.  my green Cree just arrived.  if i run a 7.4v set up (as my line diagram illustrates), and i am pushing 3.5v and 850ma with the adjustable buck booster that i identified. it is about 30% brighter than my blue star rebel running 3.34v at 750ma. (again that is directly off the battery no resistors- don't forget each 3.7 v lith battery has about 1ohm and 3watts of internal resistance)  so i am thinking running it at 75% power via PWM and then 100% for FoC would be sexy.

i also had to rewire the 14650 twin bat pack because the +/- wires were too perpendicular to the pack. my sled system rocks it, but when you pull the hilt base, the threads were scrubbing on the wires.  now they are clear.

http://www.ebay.com/itm/14650-7-4V-850mAH-Li-ion-Rechargeable-Battery-15C-SM-Plug-For-RC-Helicopter-Part-/291537040118?hash=item43e0f632f6:g:NgkAAOSwT6pVsJ8q (http://www.ebay.com/itm/14650-7-4V-850mAH-Li-ion-Rechargeable-Battery-15C-SM-Plug-For-RC-Helicopter-Part-/291537040118?hash=item43e0f632f6:g:NgkAAOSwT6pVsJ8q)

i really like the 14650 form factor.  i may print a custom battery holder that will allow me to use paired singles.  then i don't have to use a 2s ballancer to charge the pack.  i mean.. there would be no pack.

i feel like there are a 100 ways to skin the arduino and audio playback cat. Everyone who has posted code, has triggered their audio in different ways. but there are far less ways to get a good battery system with constant current to your LEDs.  it was a major thing for me when i discovered you don't need anything to power blue or green star rebels if you use a 3.7v lith.  it's the crees that need over 3.4v.  FYI  i tried to use a single 3.7v batt on my new cree.  it worked,..  and was brighter than the blue led, i think green just may be more lumens.   but the voltage was still 3.34 v and 750ma.  same as the blue rebel.  now if i understand resistance,.  if you hooked 2 batts up parallel, it would decrease their internal resistance. by,. what is it half?  or a factor of some sort? so you could get closer to the cree's peak of 3.6v 1000ma.


Title: Re: Arduino Lightsaber
Post by: DJWing79 on Jan 08, 2016, 11:09 pm
Has anyone tried to fabricate their own hilts? If so, does anyone know the threading that MHS uses? and lastly...how do you ensure that the "face" of one part always matches the "face" of the other part? I have a 3D printer and am trying to make pieces that line up correctly when screwed together.
Title: Re: Arduino Lightsaber
Post by: jshaw on Jan 08, 2016, 11:32 pm
Has anyone tried to fabricate their own hilts? If so, does anyone know the threading that MHS uses? and lastly...how do you ensure that the "face" of one part always matches the "face" of the other part? I have a 3D printer and am trying to make pieces that line up correctly when screwed together.
The threading that TCSS uses is "proprietary", at least from what I've read on various forums.  I'm sure there's an equation to figure out how many threads will get 2 parts to line up, but I don't know it.
Title: Re: Arduino Lightsaber
Post by: billpealer on Jan 09, 2016, 12:23 am
Has anyone tried to fabricate their own hilts? If so, does anyone know the threading that MHS uses? and lastly...how do you ensure that the "face" of one part always matches the "face" of the other part? I have a 3D printer and am trying to make pieces that line up correctly when screwed together.
the aluminum TCCS threads will chew right thru your prints.  you'll never be able to tighten it correctly for moderate battle.  for show,..  why even thread?,.  just glue it up. If you are making your own pieces,. use your own threading convention. i would advise against battling with a printed hilt. my gut says it won't hold up.


 i have made extensions and blade holder shrouds that are pretty darn good looking.  i just finished an activation box that is also a blade emitter shroud in one.  came out great.  If anyone is interested, i'll render an image.  just make your ID of the parts 36.85mm  and it will fit snug over the TCSS main extensions bodies, and many of the blade holders.  my hilt extensions that go OVER threaded parts but NOT over the body are,...  35mm ID.

TCSS parts faces do NOT match up.  i have screwed 2 different gear extensions to the same 4" body extension and the gear knob for each was in a different location.  No !@#ting.  That is why i made my extensions with the 3d printer. i can now screw on parts with accurate positions and turn count. maybe get an extra cm. I have been told that extra cm makes a world of difference.  plus i use black filament, no painting required.

cheers
Title: Re: Arduino Lightsaber
Post by: DJWing79 on Jan 09, 2016, 12:37 am
I'm planning to print my own hilts in either carbon or steel PLA. From what I've read, with sufficient fill % they should be very durable. the standard PLA i've printed out in test is pretty tough too, but I haven't stuck my blade inside to test impact (that comes later :) ). What I am wondering is how to guarantee that the faces of my 3d print match up because I want to make some cool designs. I too am frustrated how the TCSS parts can't align either. It ruined my fiance's saber that I made for her because parts didn't match up and those spacing rings they sell are a joke, they too easily get loose when you're tightening and look horrible.
Title: Re: Arduino Lightsaber
Post by: JakeSoft on Jan 09, 2016, 01:54 am
Do I still need to use a vibration sensor to detect clashes, or could I have the adxl345 handle both the clash, and swing detection?

Technically, no you don't need it, but the code is somewhat tricky to get working right. I'd recommend you stick with using the clash sensor if you are new because it's much easier to code for. You can always rework it later if you get good enough to detect clashes with your adxl345.

Best of luck to you.
Title: Re: Arduino Lightsaber
Post by: billpealer on Jan 09, 2016, 01:59 am
I'm planning to print my own hilts in either carbon or steel PLA. From what I've read, with sufficient fill % they should be very durable. the standard PLA i've printed out in test is pretty tough too, but I haven't stuck my blade inside to test impact (that comes later :) ). What I am wondering is how to guarantee that the faces of my 3d print match up because I want to make some cool designs. I too am frustrated how the TCSS parts can't align either. It ruined my fiance's saber that I made for her because parts didn't match up and those spacing rings they sell are a joke, they too easily get loose when you're tightening and look horrible.
sure about that?

Stainless Steel PLA
Proto-pasta Stainless Steel PLA is a dense material that prints as easily as standard PLA but results in heavy prints that can be finished post-print to achieve amazing results. Perfect for jewelry, costumes, props, figurines, crafting, robots, and more!
What is it made out of?
Proto-pasta Stainless Steel PLA is a compound of Natureworks 4043D PLA and finely ground, powderized stainless steel. In filament form, it is rather brittle, and should be handled with care to avoid breakage.
Is it stronger?
No. Proto-pasta Stainless Steel offers the aesthetic and density of metal, but because the stainless steel is finely powderized and encased in PLA, it is not stronger than standard PLA."

that is from the people that make the stuff. and it is LESS durable than PLA.  brittle.  not what you want when applying lateral leveraging force to an orifice that has to contain the blade.  you could 3d print everything BUT the blade holder.  that would do,..  a bit better.  or mixed media,.  PVC blade holder and hilt with 3d printed,..  accents. and do-dads.
Title: Re: Arduino Lightsaber
Post by: DJWing79 on Jan 09, 2016, 02:07 am
the carbon said it was really tough...the PLA i already printed (with 20% infill) is already really strong
Title: Re: Arduino Lightsaber
Post by: JakeSoft on Jan 09, 2016, 02:21 am
Not saying that's how it is, just how it looks. As I haven't recieved my order yet I can't confirm either way but will find out once I have them.

(http://i1225.photobucket.com/albums/ee395/Can-obi/IMG_20151229_200658.jpg) (http://s1225.photobucket.com/user/Can-obi/media/IMG_20151229_200658.jpg.html)
I just looked into these today and holy cow, they are cheap! And easy to find! I can find them on eBay, a lot of 10 for under $5 shipped?! If these work then it's a no-brainer to add one if if you want more loud in your saber. Looks like it expects line level input, though. Will probably have to use DAC output on the WT588D.

Has anyone had a chance to try out these modules yet?
Title: Re: Arduino Lightsaber
Post by: stinky1 on Jan 09, 2016, 02:27 am
ooh looky what I found!

LESSON 13: Controlling an RGB LED with Arduino

https://www.youtube.com/watch?v=gqAHOoqo3OI
http://www.toptechboy.com/arduino/lesson-13-controlling-rgb-led-with-arduino/

https://learn.adafruit.com/adafruit-arduino-lesson-3-rgb-leds

Figuring out the ratings to the mosfets is beyond me though. Figured out resistors. Guess that will be the next search.

WOWSERS!  Looks like this fixes all,  or at least will help speed up making the circuit for schmucks like me!

(https://cdn.solarbotics.com/products/photos/85bdac3e9f8be207dbd22ba3bd0df8f3/IMG_5214.jpg?w=375)

https://solarbotics.com/product/60160/ (https://solarbotics.com/product/60160/)
Title: Re: Arduino Lightsaber
Post by: DJWing79 on Jan 09, 2016, 02:37 am
@billpealer,

if the blade holder isn't strong enough with 3d printed material, then i'd have to use a standard blade holder, and unfortunately I guess TCSS won't give out the thread specs
Title: Re: Arduino Lightsaber
Post by: DJWing79 on Jan 09, 2016, 03:09 am
oh and I forgot to say, my hilts are 1.65 in in diameter with the inner diameter at 1.26 in. So almost .4 in thickness, am hoping it's thick enough to withstand abuse, especially with the carbon...have to wait on my stainless steel extruder
Title: Re: Arduino Lightsaber
Post by: jshaw on Jan 09, 2016, 03:51 am
ooh looky what I found!

LESSON 13: Controlling an RGB LED with Arduino

https://www.youtube.com/watch?v=gqAHOoqo3OI
http://www.toptechboy.com/arduino/lesson-13-controlling-rgb-led-with-arduino/

https://learn.adafruit.com/adafruit-arduino-lesson-3-rgb-leds

Figuring out the ratings to the mosfets is beyond me though. Figured out resistors. Guess that will be the next search.

WOWSERS!  Looks like this fixes all,  or at least will help speed up making the circuit for schmucks like me!

(https://cdn.solarbotics.com/products/photos/85bdac3e9f8be207dbd22ba3bd0df8f3/IMG_5214.jpg?w=375)

https://solarbotics.com/product/60160/ (https://solarbotics.com/product/60160/)
Yeah, I'm still working through what mosfets I'll need for mine... 

As for that solarbotics LED, that would be ideal for some of us, but at 1.9", it's probably too large for most hilts.  I know my Graflex ID is ~1 3/8", so certainly too small for that LED cluster.
Title: Re: Arduino Lightsaber
Post by: JakeSoft on Jan 09, 2016, 04:54 am
As to the layout I'm reworking now, I've used the Spectrum as the template as it supperts upto 6 LEDs. Here's what the pin list looks like:

2= Clash sensor
3= NFET gate1 (FoC LED)
5= NFET gate2
6= NFET gate3
7= PWR button
8= AUX button
9= NFET gate4

10= Accent LED 1
11= Accent LED 2
12= BUSY
13= SCK
A0= X
A1= Y
A2= Z
OK, I adjusted my I/O pin assignments to comply with this and got it working on my breadboard. I'm including the code for the header file that defines the pins in case anyone else wants to make software compliant with Canobi's PCB.

@Canobi: Check this out and confirm it looks right to you.

Code: [Select]

/*
 * Pins_Canobi.h : Defines pinout for Canobi's 3-channel PCB.
 *
 *  Created on: Jan 8, 2016
 *      Author: JakeSoft
 */

#ifndef PINS_CANOBI_H_
#define PINS_CANOBI_H_

//General I/O Pins
#define CLASH_PIN 2 //Clash sensor interrupt pin
#define LED_RED_PIN 3 //PWM output for RED LED
#define LED_GREEN_PIN 5 //PWM output for GREEN LED
#define LED_BLUE_PIN 6 //PWM output for BLUE LED
#define ACTIVATE_PIN 7 //Activation switch
#define AUX_PIN 8 //Aux switch
#define LED_FOC_PIN 9 //Flash-on-clash LED (not implemented by JakeSoft SW)
#define ACCENT1_PIN 10 //Accent LED
#define ACCENT2_PIN 11 //Secondary Accent LED (not implemented by JakeSoft SW)

//Serial pins for WT588d Sound board
#define WT588D_BUSY 12 //Module pin "LED/BUSY"
#define WT588D_SDA 13 //Module pin for DATA

//Accelerometer Pins
#define AXDL335_Z_PIN A0 //Z axis
#define AXDL335_Y_PIN A1 //Y axis
#define AXDL335_X_PIN A2 //X axis
#define AXDL335_VCC_PIN A3 //Accel power (not used by Canobi's PCB)
#define AXDL335_GND_PIN A4 //Accel ground (not used by Canobi's PCB)

#endif /* PINS_CANOBI_H_ */



Title: Re: Arduino Lightsaber
Post by: purgedsoul on Jan 09, 2016, 07:31 am
I just looked into these today and holy cow, they are cheap! And easy to find! I can find them on eBay, a lot of 10 for under $5 shipped?! If these work then it's a no-brainer to add one if if you want more loud in your saber. Looks like it expects line level input, though. Will probably have to use DAC output on the WT588D.

Has anyone had a chance to try out these modules yet?
Loud, like really loud. I had to lower the WT volume.
Title: Re: Arduino Lightsaber
Post by: JakeSoft on Jan 09, 2016, 04:43 pm
Loud, like really loud. I had to lower the WT volume.
Awesome. Did you have to use DAC on the WT, or were you able to use the differential PWM outputs?
Title: Re: Arduino Lightsaber
Post by: billpealer on Jan 09, 2016, 04:51 pm
oh and I forgot to say, my hilts are 1.65 in in diameter with the inner diameter at 1.26 in. So almost .4 in thickness, am hoping it's thick enough to withstand abuse, especially with the carbon...have to wait on my stainless steel extruder
.4" IS thick.  post a video maybe of some combat, illustrating the results.
Title: Re: Arduino Lightsaber
Post by: DJWing79 on Jan 09, 2016, 07:04 pm
I plan to, will not have electronics in it (for obvious reasons if it fails). I have to finish printing out all the parts, but I think I might have solved the alignment issue. I am printing a part that has the threads all the way through (1.43in x 12) and another piece that threads into it but has threads only halfway down and the other half isn't threaded...what I will do is thread it down until the notch on both pieces aligns and then I will mark it, and then I should know the depth for each piece. I sure hope it works.
Title: Re: Arduino Lightsaber
Post by: amine2 on Jan 09, 2016, 07:34 pm
very cool (y) :D .
though  , you could make those sound effects with some math and the PWM outputs , or if you want some specific sounds you can use interrups , an 8bit DAC and an SD card (lower quality but it will work well) .
that way you would not need a chip . though as it is the project is really cool (y)
Title: Re: Arduino Lightsaber
Post by: Canobi on Jan 09, 2016, 09:41 pm
This sounds interesting. It seems like you've really only got two options to make the system space efficient:
1) Make it long and as flat as possible, so you could possibly mount the circuits on top of a battery
2) Make it short and fat by stacking the modules on top of each other
That was pretty much the scenario until hilt diameters were discussed. I always thought saber hilts were approx 1.25" OD but that appears to be smaller than some of the IDs mentioned so will need to reassess my build strategy and materials. Gives a lot more room in terms of PCB space though so I may not have to keep trying to make them as small as I originally thought.

Do keep in mind though, that you'll want to keep these as accessible as possible for hobbyists if you intend others to assemble them. Many are operating with $20 soldering irons and so-so soldering skills. One reason one might be interested in building their own sound board is that $100+ commercial sound boards are too expensive for them. If they need a $100 soldering station to build the board, then they aren't really ahead of the game unless they plan to build a lot of  If you intend to sell completed boards, however, go for it and use all the tricks you have at your disposal to make it small as possible.
My aim has always been to make the PCBs as simple and easy to work with as possible and not just for the unskilled either as I happen to be one of those people that use a cheap £20 iron. I even fabricate my boards using home contructed equipment.

My pride and joy is a mini PCB drill press I built from scrap A/C inverter drive heatsinks and other reclaimed parts I got from work:

(http://i1225.photobucket.com/albums/ee395/Can-obi/IMG_20140502_095720.jpg) (http://s1225.photobucket.com/user/Can-obi/media/IMG_20140502_095720.jpg.html)
(http://i1225.photobucket.com/albums/ee395/Can-obi/IMG_20160109_183219.jpg) (http://s1225.photobucket.com/user/Can-obi/media/IMG_20160109_183219.jpg.html)
(http://i1225.photobucket.com/albums/ee395/Can-obi/IMG_20140511_094828.jpg) (http://s1225.photobucket.com/user/Can-obi/media/IMG_20140511_094828.jpg.html)


I think I can work with this pin arrangement. I'll experiment on my breadboard when i can get the time. I don't currently have a dedicated FOC LED, just the 3 for R/Gr/B, but I could add one easily enough. I don't have a second accent LED either, but it's OK if that output doesn't do anything for now, right?
Cool :)

The second accent LED is only really a suggestion. I broke out the unused pin in case someone writing their own code for the board had a reason to use it as it could also be used for other PWM type shenanigans.

Is that true? What LED are you assuming people will use for FOC? Cree and Luxeon have different specs. What battery source voltage are you assuming? What if somebody wants to use a different color LED for dedicated FOC?
My apologies, my asperger's can sometimes make my thinking a little black and white and does indeed fill the gaps with all sorts of assumptions so I've amended the layout. All four channels are now resistor free.

Here's a smaller lower res pic of the board:

(http://i1225.photobucket.com/albums/ee395/Can-obi/IMG_20160109_174512.jpg) (http://s1225.photobucket.com/user/Can-obi/media/IMG_20160109_174512.jpg.html)

Dropbox link to high res image (it's quite big though):

 https://www.dropbox.com/s/0uoptk965n55yl0/WrenagadeTech%E2%97%8F%C2%B0_%20Saber%20fx%20PCB%20%28ADXL%20varient%29.jpg?dl=0 (https://www.dropbox.com/s/0uoptk965n55yl0/WrenagadeTech%E2%97%8F%C2%B0_%20Saber%20fx%20PCB%20%28ADXL%20varient%29.jpg?dl=0)


@Canobi: Check this out and confirm it looks right to you.

Code: [Select]

/*
 * Pins_Canobi.h : Defines pinout for Canobi's 3-channel PCB.
 *
 *  Created on: Jan 8, 2016
 *      Author: JakeSoft
 */

#ifndef PINS_CANOBI_H_
#define PINS_CANOBI_H_

//General I/O Pins
#define CLASH_PIN 2 //Clash sensor interrupt pin
#define LED_RED_PIN 3 //PWM output for RED LED
#define LED_GREEN_PIN 5 //PWM output for GREEN LED
#define LED_BLUE_PIN 6 //PWM output for BLUE LED
#define ACTIVATE_PIN 7 //Activation switch
#define AUX_PIN 8 //Aux switch
#define LED_FOC_PIN 9 //Flash-on-clash LED (not implemented by JakeSoft SW)
#define ACCENT1_PIN 10 //Accent LED
#define ACCENT2_PIN 11 //Secondary Accent LED (not implemented by JakeSoft SW)

//Serial pins for WT588d Sound board
#define WT588D_BUSY 12 //Module pin "LED/BUSY"
#define WT588D_SDA 13 //Module pin for DATA

//Accelerometer Pins
#define AXDL335_X_PIN A0 //X axis
#define AXDL335_Y_PIN A1 //Y axis
#define AXDL335_Z_PIN A2 //Z axis
#define AXDL335_VCC_PIN A3 //Accel power (not used by Canobi's PCB)
#define AXDL335_GND_PIN A4 //Accel ground (not used by Canobi's PCB)

#endif /* PINS_CANOBI_H_ */

Looks a OK :)

I still need to finish updating the identifier silk to reflect the new changes, so ignore the labals in the pic(s) for the LED output array as they will change (as will one or two other minor details no doubt).
Title: Re: Arduino Lightsaber
Post by: Canobi on Jan 09, 2016, 09:53 pm
On second thought, perhaps the only change I'd make would be to rename "second accent led" to "PWM output" as it's more generic.
Title: Re: Arduino Lightsaber
Post by: JakeSoft on Jan 10, 2016, 02:07 am
That was pretty much the scenario until hilt diameters were discussed. I always thought saber hilts were approx 1.25" OD but that appears to be smaller than some of the IDs mentioned so will need to reassess my build strategy and materials. Gives a lot more room in terms of PCB space though so I may not have to keep trying to make them as small as I originally thought.
I think a good design target is to not make the board any wider than 1". That way it'll fit inside PVC that is commonly used to make lightsabers. The 1" PVC electrical conduit is also commonly used to make sleds and chassis for lightsabers, so fitting inside those would be a boon. 1" will easily fit inside MHS parts which typically have in ID of 1.25".

My pride and joy is a mini PCB drill press I built from scrap A/C inverter drive heatsinks and other reclaimed parts I got from work:
Cool setup. You're quite handy! I can drill and tap holes and cut things with a rotary tool. That's about the extent of my metal-working skills. (I told you I hate fabricating!)

My apologies, my asperger's can sometimes make my thinking a little black and white and does indeed fill the gaps with all sorts of assumptions so I've amended the layout. All four channels are now resistor free.
No worries. That's the advantage of working collaboratively, many ideas make for better product.

Here's a smaller lower res pic of the board:

(http://i1225.photobucket.com/albums/ee395/Can-obi/IMG_20160109_174512.jpg) (http://s1225.photobucket.com/user/Can-obi/media/IMG_20160109_174512.jpg.html)
This looks pretty good. If you are still including the LP2992 LDO as an SMD component? If so, I'd suggest just routing power from that to the VCC on the arduino for the 3.3V version if you can. The drop out voltage on that part is going to be better than anything you'll get from the on-board regulator on the Arduino, especially some of the clones. In fact, I've had some bad experiences with Arduino Pro Mini 3.3V clones using sub-spec onboard regulators that cut out at 5 volts! That won't fly when you're running a 3.7V battery.

I have taken a hard look at the drawing you posted. I have a few comments and suggestions. Do with them what you will. There is really only one error that I noticed, the rest are just ideas for improvement.

1) The mappings for the Busy and VCC (3.3V) pins on the WT588D are each off by one pin. The Busy pin is right next to the VDD pin and the VCC pin is right after that. (VDD, BUSY, VCC, with no skipped pins).
2) You may not need to leave room for the clash sensor. They work best when placed as close to the blade as possible, but people often mount their soundboards close to the pommel. This means that folks will likely run wires from the board up the hilt toward the blade anyway for their clash sensor. It's OK to leave it as is, I'm just pointing out that the space may not be used often. It's an opportunity to make the board smaller, maybe.
3) If you still plan to include the LP2992 LDO, just run power from that to the VCC pin on the arduino (at least for the 3.3V version) and the VCC pin of the WT588D as well. It makes the entire part a 3.3V device with the option to add an LDO or buck to boost power to the VDD on the WT588D for more performance if desired. Otherwise, just bridge the WT588D's VDD to 3.3v as well and call it a day.
4) Why not route pins 2, 3, 5, 6, and 9 toward the inside of the board and take pins 7 (Activation Switch) and 8 (Aux Switch) out to the edge of the board? That way nobody has to solder wires for their switches to the middle of the board. I can see that becoming a big pain, especially if there is a PRO-Mini sitting on the other side and you can't thread the wire through to solder it in through-hole fashion after the MCU is mounted. The signals from the other pins never leave the board, so they don't need that premium edge real estate.

That's all for my notes. Don't take that laundry list to mean I'm not impressed; I really am. I'm excited and look forward to working out a way to combine your board with my software.


Title: Re: Arduino Lightsaber
Post by: billpealer on Jan 10, 2016, 06:18 am
anyone get PWM LED fading working from an LED driver?

i cant get it to wrk.

the driver wont allow me to put the MOSFET at the 8.4v source,..  so i have to put it at the 3.4v output.  i can get to set the voltage,.  but not turn off or do any triggering,..

analogWrite(LEDPWM, 255);  equals the full 3.4v

analogWrite(LEDPWM, 220);  equals about full 3.25v

i can't measure a analogWrite 0, because the thing has never shut off.  i have to pull the fet, or a wire.

I noticed Canobi's PCB has 10kohm resistors on the MOSFET section.  My primary mosfet works,..  the one that uses digitalWrite,. and it also uses a common ground with everything else and NO resistor. is that what i am missing?  a common ground for the PWM mosfet?  i am hesitant to mix the 5v arduino ground and the 3.4v power from the Buck Step down driver.
Title: Re: Arduino Lightsaber
Post by: Canobi on Jan 10, 2016, 12:02 pm
The 10k resistors pull the pins to ground when not in use as I've been told they can sometimes float causing miss readings.
Title: Re: Arduino Lightsaber
Post by: JakeSoft on Jan 10, 2016, 05:46 pm
I noticed Canobi's PCB has 10kohm resistors on the MOSFET section.  My primary mosfet works,..  the one that uses digitalWrite,. and it also uses a common ground with everything else and NO resistor. is that what i am missing?  a common ground for the PWM mosfet?  i am hesitant to mix the 5v arduino ground and the 3.4v power from the Buck Step down driver.

As Canobi said, he added pull-down resistors for the MOSFET gates to stop them from floating. This is sort of a standard thing to do. The reason your application works without them is that when you do a digitalWrite(LOW) in code, the Arduino will pull the pin to ground so it's not left floating. So in practice you don't technically need them. I've done it both ways.
Title: Re: Arduino Lightsaber
Post by: billpealer on Jan 10, 2016, 06:59 pm
The 10k resistors pull the pins to ground when not in use as I've been told they can sometimes float causing miss readings.
they are not needed on my 3.7v set up.  have you got a working set up?

have you tried with and with out resistors?
Title: Re: Arduino Lightsaber
Post by: Canobi on Jan 10, 2016, 07:45 pm
I think a good design target is to not make the board any wider than 1". That way it'll fit inside PVC that is commonly used to make lightsabers. The 1" PVC electrical conduit is also commonly used to make sleds and chassis for lightsabers, so fitting inside those would be a boon. 1" will easily fit inside MHS parts which typically have in ID of 1.25".
Not to worry, the board stands at 24.42mm which accommodates many different routing options so there's actually no need to make it any wider.


Cool setup. You're quite handy! I can drill and tap holes and cut things with a rotary tool. That's about the extent of my metal-working skills. (I told you I hate fabricating!)
Necessity is the mother of invention. I got so perplexed with snapped wires during "on the fly" installments that I came to the decision to make my own PCBs to avoid all that crap.

After finding out what was need to put a lab together, I winged the whole lot following any tutorials I could find that were relevent as I've no formal education in engineering, chemistry, or electronics for that matter but if a colourblind dyslexic like myself can do it, anyone can.


This looks pretty good. If you are still including the LP2992 LDO as an SMD component? If so, I'd suggest just routing power from that to the VCC on the arduino for the 3.3V version if you can. The drop out voltage on that part is going to be better than anything you'll get from the on-board regulator on the Arduino, especially some of the clones. In fact, I've had some bad experiences with Arduino Pro Mini 3.3V clones using sub-spec onboard regulators that cut out at 5 volts! That won't fly when you're running a 3.7V battery.
I was going for system voltage flexibility so combinations like 3v mini, 5v WT setups were possible but if the LDOs on the pro mimis are less than reliable I'll take another look at the power rail setup.


I have taken a hard look at the drawing you posted. I have a few comments and suggestions. Do with them what you will. There is really only one error that I noticed, the rest are just ideas for improvement.

1) The mappings for the Busy and VCC (3.3V) pins on the WT588D are each off by one pin. The Busy pin is right next to the VDD pin and the VCC pin is right after that. (VDD, BUSY, VCC, with no skipped pins).
Oops, my bad. Will correct that post haste.

2) You may not need to leave room for the clash sensor. They work best when placed as close to the blade as possible, but people often mount their soundboards close to the pommel. This means that folks will likely run wires from the board up the hilt toward the blade anyway for their clash sensor. It's OK to leave it as is, I'm just pointing out that the space may not be used often. It's an opportunity to make the board smaller, maybe.
I had considered that which is why I put it up front with the accelerometer and made sure the pads were under an open spot so wires could be traces from there easily if necessary. Other than that, it's position is non critical to the boards dims, although I noticed I can still shave off about 4mm from the overall length anyway.

3) If you still plan to include the LP2992 LDO, just run power from that to the VCC pin on the arduino (at least for the 3.3V version) and the VCC pin of the WT588D as well. It makes the entire part a 3.3V device with the option to add an LDO or buck to boost power to the VDD on the WT588D for more performance if desired. Otherwise, just bridge the WT588D's VDD to 3.3v as well and call it a day.
That's pretty much how the power rails work right now, the only difference is that the pro mini rail is unregulated for 3v setups but it wouldn't take much to address that issue.

4) Why not route pins 2, 3, 5, 6, and 9 toward the inside of the board and take pins 7 (Activation Switch) and 8 (Aux Switch) out to the edge of the board? That way nobody has to solder wires for their switches to the middle of the board. I can see that becoming a big pain, especially if there is a PRO-Mini sitting on the other side and you can't thread the wire through to solder it in through-hole fashion after the MCU is mounted. The signals from the other pins never leave the board, so they don't need that premium edge real estate.
Ah, that'll take a lot more to rework than the power rail but the idea with that setup was to solder in the buttons/accent LED/PWM wires first, then mount the modules after as the header pins allow just enough room to trace them out from underneath. But your right, there's no way you'd solder wires in after the module have been mounted and the comms lines should indeed be on the inside. I'll need a couple days for that one.

That's all for my notes. Don't take that laundry list to mean I'm not impressed; I really am. I'm excited and look forward to working out a way to combine your board with my software.
I'll PM you ;)
Title: Re: Arduino Lightsaber
Post by: Canobi on Jan 10, 2016, 07:53 pm
As Canobi said, he added pull-down resistors for the MOSFET gates to stop them from floating. This is sort of a standard thing to do. The reason your application works without them is that when you do a digitalWrite(LOW) in code, the Arduino will pull the pin to ground so it's not left floating. So in practice you don't technically need them. I've done it both ways.
I put the 10k gate resistors on as a precaution but if they're not essential then I'll ditch those as well it'll help to simplify hand soldering.
Title: Re: Arduino Lightsaber
Post by: JakeSoft on Jan 10, 2016, 10:11 pm
I put the 10k gate resistors on as a precaution but if they're not essential then I'll ditch those as well it'll help to simplify hand soldering.
You could leave the traces there then people could choose to put the resistor if they really wanted to. Otherwise, they could put nothing there and it would just be an open circuit.

I'm curious, what software are you using to generate your images? Looking at your layouts has me kind of eager to learn enough to play with my own designs, but I'm not sure where to start. I tried Fritzing, but it's pretty terrible if there is no part library for everything you want to use, and there doesn't appear to be one for WT588D. Adding your own is a big pain too. Yuck.

I have not found a tool that doesn't want you to start with a schematic first. All I want to do is make some simple mapping boards with vias and manual traces, I'm not sure why that's so difficult.
Title: Re: Arduino Lightsaber
Post by: Canobi on Jan 11, 2016, 01:11 am
Well the resistors are less than pennies each but having tried it, it was a pain to solder them so close to the fet so it would make populating the board quicker and simpler to leave them off.


As to what I use, I design my layouts on my android phone. I found a couple of apps called DriodPCB and PCB design companion, both of which are totally free, totally awesome and have very little to no adds.

Design companion has a ruck of useful calculators needed for working out trace widths and the like while DriodPCB is where all the fun happens as you literally "draw" the circuit using a variety of tools (some of which can't actually be used yet but the devs are working on those).
Title: Re: Arduino Lightsaber
Post by: JakeSoft on Jan 11, 2016, 02:34 am
Well the resistors are less than pennies each but having tried it, it was a pain to solder them so close to the fet so it would make populating the board quicker and simpler to leave them off.
Yeah, anything you can do to make it easy will make it better IMO. Maybe even a version with all though-hole components. If you use the I-PAK packaged FETs, you can fit them three-wide on a 1 inch board. I personally lack the dexterity to solder SMD components properly. Soldering the pin headers on the Arduino is about as small as I go.

As to what I use, I design my layouts on my android phone. I found a couple of apps called DriodPCB and PCB design companion, both of which are totally free, totally awesome and have very little to no adds.

Design companion has a ruck of useful calculators needed for working out trace widths and the like while DriodPCB is where all the fun happens as you literally "draw" the circuit using a variety of tools (some of which can't actually be used yet but the devs are working on those).
Oh, that sounds cool. I don't have an Android device, but  maybe I could get an emulator and try it out. Too much setup for me to get into right now. I'll let you have all the "fun" in the meantime.
Title: Re: Arduino Lightsaber
Post by: stinky1 on Jan 11, 2016, 04:13 am
Found it!!


"Now I needed to power each LED (Red, Green, and Blue) individually. This is what I came up with: Three MOSFETs wired like so: Gate goes to Arduino Nano output. Source goes to ground. Drain goes to LED negative with current limiting resistor for each LED. "

(http://i46.tinypic.com/346mgsp.jpg)

Jake's been holdin out on us!!! >:(

Lol only kidding,  found that post on CSS forums where they said take Arduino elswhere!!  :smiley-mr-green:

The Pertinax MkII is all I need!!!  And that is what this thread is showing how to build.

http://forums.thecustomsabershop.com/showthread.php?16950-Pertinax&s=35f9001cb72b6a1df3147c4f507752fd&highlight=ARDUINO

http://forums.thecustomsabershop.com/showthread.php?15366-Novus-Animus

 I took the dive and ordered all the parts,  guess I still have to figure out the resistors and buy them too.  I understand the smaller brown resistors limiting the voltage for the RGB led's,  but what are the grey resistors doing?  Sorry my newbness drags your guys brilliance down.  :smiley-eek-blue:
Title: Re: Arduino Lightsaber
Post by: JakeSoft on Jan 11, 2016, 04:20 am
Found it!!


"Now I needed to power each LED (Red, Green, and Blue) individually. This is what I came up with: Three MOSFETs wired like so: Gate goes to Arduino Nano output. Source goes to ground. Drain goes to LED negative with current limiting resistor for each LED. "

(http://i46.tinypic.com/346mgsp.jpg)

Jake's been holdin out on us!!! >:(

Lol only kidding,  found that post on CSS forums where they said take Arduino elswhere!!  :smiley-mr-green:

The Pertinax MkII is all I need!!!  I took the dive and ordered all the parts,  guess I still have to figure out the resistors and buy them too.  I understand the smaller brown resistors limiting the voltage for the RGB led's,  but what are the grey resistors doing?  Sorry my newbness drags your guys brilliance down.  :smiley-eek-blue:
LOL. Now there's a blast from the past. That's from a post about my first ever Arduino saber right there. I used a sound board from a toy on that one because I hadn't learned about WT588D yet! Yeah, the mod over there doesn't like Arduino talk for whatever reason.

The fat blue-gray resistors are actually the ones for the LEDs. The smaller ones were probably pull-down resistors for the gate pins, I think.
Title: Re: Arduino Lightsaber
Post by: JakeSoft on Jan 11, 2016, 04:20 am
they are not needed on my 3.7v set up.  have you got a working set up?

have you tried with and with out resistors?
Yes, I tried both ways. It works without the resistors.
Title: Re: Arduino Lightsaber
Post by: billpealer on Jan 11, 2016, 04:37 am
Yes, I tried both ways. It works without the resistors.
I figured.

I was actually asking Canobi?  Or is he just working for you? ;)  he posts a lot of flour and eggs, i was wondering if he had some cake.

i got the bind lock on impact working. .. sort of.


if i orient the sw sensor on a perpendicular axis and wait for a strike,.. it will do it. sometimes.  i used the same code i gave as an example.  it works,..  25% of the time.  so many sensors are trying to step on each other,.  but it works. or has the potential to.

it also got me thinking.  Isn't a clash merely a 1/2 second of lock up, with another half sec of decay?  so, maybe there shouldn't be clash sound.

just swing and lock up.   every clash plays lock up, and it plays till there is a swing to break it up.

i am going to try that out.  it makes too much logical sense.  like adding hum to all the sounds.
Title: Re: Arduino Lightsaber
Post by: stinky1 on Jan 11, 2016, 04:43 am
So then the voltage is controlled through the PWM pins, and the voltage controls in the Arduino programming? With the Mosfets. I'm guessing.   
Title: Re: Arduino Lightsaber
Post by: billpealer on Jan 11, 2016, 04:45 am
Yes, I tried both ways. It works without the resistors.
try PWM with mosfet with a buck booster?  or just direct off hot DC with resistors or a linear regulator?

from what i understand from buck step/up down,. they push power at a frequency.  they talk about ripple, and what not in their cut sheets. i am now savoy in PWM and arduino and LEDs..  yet if I put a mosfet tween the buck and the LED,..  no dice.  i can use the mosfet tween the v+ and the buck to turn it on and off.  i can use the mosfet with pwm direct to the 3.7v batt with effect.  But not with the buck step down.  grrrrr.  

anyone have a story on that?
Title: Re: Arduino Lightsaber
Post by: stinky1 on Jan 11, 2016, 04:50 am
try PWM with mosfet with a buck booster?  or just direct off hot DC with resistors or a linear regulator?

from what i understand from buck step/up down,. they push power at a frequency.  they talk about ripple, and what not in their cut sheets. i am now savoy in PWM and arduino and LEDs..  yet if I put a mosfet tween the buck and the LED,..  no dice.  i can use the mosfet tween the v+ and the buck to turn it on and off.  i can use the mosfet with pwm direct to the 3.7v batt with effect.  But not with the buck step down.  grrrrr.  

anyone have a story on that?
Well don't quote me as Im really newb,  but from what I read the buckboosters are for single color LED's.
At least that is what I have read in my researching of all this,  when I found out I didn't need one i was like
phew cause they aint cheap. I was thinking one for each LED,   3 of them,  OW dollas!  :smiley-money:
Title: Re: Arduino Lightsaber
Post by: billpealer on Jan 11, 2016, 04:51 am
So then the voltage is controlled through the PWM pins, and the voltage controls in the Arduino programming? With the Mosfets. I'm guessing.    
If you test the LEDs controlled with pwm, they will read a varied voltage based on the PWM,.  but in essence the PWM is NOT controlling V or A.  just,..  modulating the signal.  like,..  a wave function. and modulating it via whatever the arduino is shoving out the pin..  like 4.8v and 50ma.  sound right people?
and a mosfet,.  is more or less a switch or relay.  send it a signal and it links the ground. take away the signal, and it breaks the ground.  mosfet.  i didn't know about any of this 3 months ago.  i did know that PWM could drive an led or laser.  my DL44 mauser blaster laser and LED piggy backs off the sound module,..  so it modulates based on the sounds.  kind cool.  RIP.. wife broke it this past halloween. :(  i seriously had a funeral.
Title: Re: Arduino Lightsaber
Post by: billpealer on Jan 11, 2016, 05:14 am
Well don't quote me as Im really newb,  but from what I read the buckboosters are for single color LED's.
At least that is what I have read in my researching of all this,  when I found out I didn't need one i was like
phew cause they aint cheap. I was thinking one for each LED,   3 of them,  OW dollas!  :smiley-money:
sorry, i should have been more specific.
i was asking jake.  he is like the godfather of this stuff, and 4 years of tinkering on this topic.

i am using single LEDs.  and i think a buck will power a tri.
Title: Re: Arduino Lightsaber
Post by: purgedsoul on Jan 11, 2016, 07:01 am
Awesome. Did you have to use DAC on the WT, or were you able to use the differential PWM outputs?
I had to use the DAC on the WT.
Title: Re: Arduino Lightsaber
Post by: billpealer on Jan 11, 2016, 02:53 pm
I had to use the DAC on the WT.
+1
Title: Re: Arduino Lightsaber
Post by: Canobi on Jan 11, 2016, 04:08 pm
Someone say cake?

(http://i1225.photobucket.com/albums/ee395/Can-obi/IMG_20151231_215622.jpg) (http://s1225.photobucket.com/user/Can-obi/media/IMG_20151231_215622.jpg.html)

Shame the routing is off but at least I know they come out ok.
Title: Re: Arduino Lightsaber
Post by: Protonerd on Jan 11, 2016, 04:25 pm
I put the 10k gate resistors on as a precaution but if they're not essential then I'll ditch those as well it'll help to simplify hand soldering.
I would definitely implement that precaution. Arduino PWM capable drivers only have pull-ups, but for low-sides we use n-MOS. If the resistors are not there, as soon as you do not explicitly program L/H (or PWM) levels, the gates start to float. Why it's bad? For one I do not know how the Arduino works when updating the code. Say you program your drivers for low level no keep the MOSFETs calm. Then you start uploading your new code (happens quite often when debugging), and you see the dancing lights on your saber. Same when applying a reset, not to mention that if you want to upload a different code (for whatever reason), your safeguards in the code are not there.
I use 100k, but alas for a LED string saber I have 6 MOSFETs in parallel for practical purposes. Matter of taste, usually in IC's they go not higher than 200k.
Title: Re: Arduino Lightsaber
Post by: billpealer on Jan 11, 2016, 05:10 pm
Someone say cake?

(http://i1225.photobucket.com/albums/ee395/Can-obi/IMG_20151231_215622.jpg) (http://s1225.photobucket.com/user/Can-obi/media/IMG_20151231_215622.jpg.html)

Shame the routing is off but at least I know they come out ok.
tasty.

i had a happy accident last night. 2x CR123A in series.. I epoxied 2 batt holders together, and realized.. For TCSS (not 1"pvc.  maybe 1 1/4" pvc tho)  i can rest the nano and WT on the back side of it. add some 3d printed fins (tie fighter) with and extension platform to hold the Mosfets, and sensors to keep it central, and then epoxy the Speaker holder to the other side,..

3d render coming.

actually, Canobi the board making jedi,..  the batt holders have pcb pins.  you could mount your little board doohicky to the back of the batt holders. i think 7.4v is Jake approved if you are hoping to clone his setup. if you need a compact batt system. it may be the one!

Canobi, can you send, or post me a high-con (high contrast black and white image) of your PCB board and its dimensions.  I'd like to make a 3D model of it, and then create a visualization of how it could be applied directly to a battery system. i think i can make a Hi-Con,.  if you could tell me the lxwxh, that would be sufficient.

image attached.  the white paper would be the cake.
Title: Re: Arduino Lightsaber
Post by: stinky1 on Jan 11, 2016, 06:35 pm
Here is theory on pull up pull down,  which is or was complete greek to me.

Easty to understand
http://www.resistorguide.com/pull-up-resistor_pull-down-resistor/ (http://www.resistorguide.com/pull-up-resistor_pull-down-resistor/)

Longer explanation
http://electronics.stackexchange.com/questions/23645/how-do-i-calculate-the-required-value-for-a-pull-up-resistor (http://electronics.stackexchange.com/questions/23645/how-do-i-calculate-the-required-value-for-a-pull-up-resistor)

Texas Instruments in depth Explanation
http://www.ti.com/lit/an/slva485/slva485.pdf (http://www.ti.com/lit/an/slva485/slva485.pdf)

Title: Re: Arduino Lightsaber
Post by: JakeSoft on Jan 11, 2016, 07:43 pm
I would definitely implement that precaution. Arduino PWM capable drivers only have pull-ups, but for low-sides we use n-MOS. If the resistors are not there, as soon as you do not explicitly program L/H (or PWM) levels, the gates start to float.
Yeah, I'd still go with what I said before. Leave the traces in but it's not a big deal if you don't put the resistors there. My code is tight about ensuring outputs are low when they are supposed to be, but having the resistors there allows you to be more sloppy with your code. I'm a software guy, so I'm always going to look for the software solution. Others my have different inclinations.

Why it's bad? For one I do not know how the Arduino works when updating the code. Say you program your drivers for low level no keep the MOSFETs calm. Then you start uploading your new code (happens quite often when debugging), and you see the dancing lights on your saber.
I'm pretty sure that at least on the Pro-mini, the outputs all go low during programming. At least, I notice that all of my LEDs I have wired to outputs will turn off during SW upload when working on my breadboard. I never see the "dancing lights" because I put my kill key in when doing in-hilt uploads to my MCU anyway.
Title: Re: Arduino Lightsaber
Post by: T_R_O_N on Jan 11, 2016, 09:02 pm
Technically, no you don't need it, but the code is somewhat tricky to get working right. I'd recommend you stick with using the clash sensor if you are new because it's much easier to code for. You can always rework it later if you get good enough to detect clashes with your adxl345.

Best of luck to you.
Thanks I'll definitely use the vibration sensor for clash detection, how difficult is it to detect only swings with the adxl345? Could I use the accelerometer for swing detection then?

Title: Re: Arduino Lightsaber
Post by: Protonerd on Jan 11, 2016, 11:24 pm
Yeah, I'd still go with what I said before. Leave the traces in but it's not a big deal if you don't put the resistors there. My code is tight about ensuring outputs are low when they are supposed to be, but having the resistors there allows you to be more sloppy with your code. I'm a software guy, so I'm always going to look for the software solution. Others my have different inclinations.
I'm pretty sure that at least on the Pro-mini, the outputs all go low during programming. At least, I notice that all of my LEDs I have wired to outputs will turn off during SW upload when working on my breadboard. I never see the "dancing lights" because I put my kill key in when doing in-hilt uploads to my MCU anyway.

Point taken and I agree. If no smd resistors are used, they can take up a lot of space for what they are good for and every inch of space is precious in a saber. Well, I'm no software wizard like you JakeSoft, so I need the precaution. Yeah, I think sloppy might be the right term for the code I write in C, but I keep improving :) but I really enjoy the hardware challenge!
Title: Re: Arduino Lightsaber
Post by: ryang on Jan 12, 2016, 12:17 am
Not to worry, the board stands at 24.42mm which accommodates many different routing options so there's actually no need to make it any wider.
Just wondering about this...  How high is the board ending up after mounting components?  If it's too high, it won't fit in a 1" ID.  Leaving ~1mm clearance doesn't seem like enough.

What are the dimensions of the Arduino being used?
Title: Re: Arduino Lightsaber
Post by: billpealer on Jan 12, 2016, 12:40 am
Just wondering about this...  How high is the board ending up after mounting components?  If it's too high, it won't fit in a 1" ID.  Leaving ~1mm clearance doesn't seem like enough.

What are the dimensions of the Arduino being used?
absolutely,  plus every mm or so up, you loose a mm in width, as is the nature of a dome or 1/2 cylindrical enclosure.  i had to abandon a buck boost module due to the chunkyness of its caps and induction coil.. all mounted at the board's edge.  now i use a smaller,..  flatter model.  i have gotten better at soldering since,. i suppose i could relocate those bits.

The dimensions of the Pro Mini PCB are approximately 0.7" x 1.3" and maybe an .125" thick. more with headers.
Title: Re: Arduino Lightsaber
Post by: jshaw on Jan 12, 2016, 04:32 am
I finally received my WT588D-U-32M and wow is it big!  I might need to order the one that requires the USB programmer in order to save some space in my hilt.   But I'm happy that it finally arrived.  Now to try and get it to play some sounds!
Title: Re: Arduino Lightsaber
Post by: purgedsoul on Jan 12, 2016, 11:49 am
Thanks I'll definitely use the vibration sensor for clash detection, how difficult is it to detect only swings with the adxl345? Could I use the accelerometer for swing detection then?


I've tried it with mine after several experimentation, you can either use the activity/inactivity/tap/double tap special feature of the adxl345 or you can just read the raw XYZ data and do a comparison

if x > swing sensitivity then swing

something like that.
Title: Re: Arduino Lightsaber
Post by: billpealer on Jan 12, 2016, 04:18 pm
Can anyone testify for or against the ADXL335  vs the ADXL345?

I am happy to report that removing Clash sound was a success.  In its place is simply lock up sound. and when you clash, it plays lock up, if you clash and trigger a swing, it ends the lock up sound, and resolves a swing, and of course a swing decays to hum.  I think the rollerball switches are firing too many false positives for swings, and limits the positions that will allow a sustained lock up.  The accelerometer should reduce false positives for swings me thinks.

the cool part is that you now have a fairly reliable lock up, wit no 2nd button.
Title: Re: Arduino Lightsaber
Post by: JakeSoft on Jan 13, 2016, 02:36 am
Can anyone testify for or against the ADXL335  vs the ADXL345?

I am happy to report that removing Clash sound was a success.  In its place is simply lock up sound. and when you clash, it plays lock up, if you clash and trigger a swing, it ends the lock up sound, and resolves a swing, and of course a swing decays to hum.  I think the rollerball switches are firing too many false positives for swings, and limits the positions that will allow a sustained lock up.  The accelerometer should reduce false positives for swings me thinks.

the cool part is that you now have a fairly reliable lock up, wit no 2nd button.
I've only used the 335, but I looked at the 345. 335 seems much more straight forward because you just have to connect it to power and then you can do analog reads of X, Y, Z. Easy-peaszy. 345 seems like a much bigger pain to get into with a two-way 3-line serial interface or SPI and a library that you need. I may experiment with it eventually, but the 335 seems a lot more user friendly to me.
Title: Re: Arduino Lightsaber
Post by: T_R_O_N on Jan 13, 2016, 07:35 am
That's interesting JakeSoft, thanks.

I'm glad that I have not ordered my parts yet, I was under the impression that the adxl345 is just a newer version if the 335. But if the adxl335 is more user friendly, then I think that I will rather use that one.
Title: Re: Arduino Lightsaber
Post by: Protonerd on Jan 13, 2016, 08:47 am
I've only used the 335, but I looked at the 345. 335 seems much more straight forward because you just have to connect it to power and then you can do analog reads of X, Y, Z. Easy-peaszy. 345 seems like a much bigger pain to get into with a two-way 3-line serial interface or SPI and a library that you need. I may experiment with it eventually, but the 335 seems a lot more user friendly to me.
I saw that you connect the ADXL335 X/Y/Z outputs to the Arduino. Do you keep polling these outputs in each loop? How are the data arriving? Do you get a digital value or is it more like an analog value from 0 to rail? Is it possible to scale to different acceleration ranges?

For my build I use the MPU-6050 breakout board, it has a 2-line interface (DO/DI), Vcc and GND, so far I'm happy with the results for both swings and clashes, but I'm looking out for a 2nd option.
Title: Re: Arduino Lightsaber
Post by: Jantje on Jan 13, 2016, 02:45 pm
Hi
I want to do something very similar but for a fake metal sword.
The accelerometer you are using is what I had in mind. I don't understand why you have an extra "impact switch" as this should be visible from the accelerometer as well.
Can you elaborate on this?
Thanks
Jantje
Title: Re: Arduino Lightsaber
Post by: jshaw on Jan 13, 2016, 03:12 pm
Hi
I want to do something very similar but for a fake metal sword.
The accelerometer you are using is what I had in mind. I don't understand why you have an extra "impact switch" as this should be visible from the accelerometer as well.
Can you elaborate on this?
Thanks
Jantje
The impact switch, or as it's otherwise known the Flash-on-Clash switch, is used because until recently, accelerometers were not used in lightsabers. They used two switches, the FoC switch and a swing switch.  Nowadays, accelerometers seem to be gaining traction but are significantly more difficult to program than the two simple switches.
Title: Re: Arduino Lightsaber
Post by: Canobi on Jan 13, 2016, 04:09 pm
tasty.

 i had a happy accident last night. 2x CR123A in series.. I epoxied 2 batt holders together, and realized.. For TCSS (not 1"pvc.  maybe 1 1/4" pvc tho)  i can rest the nano and WT on the back side of it. add some 3d printed fins (tie fighter) with and extension platform to hold the Mosfets, and sensors to keep it central, and then epoxy the Speaker holder to the other side,..


3d render coming.
You can make it even shorter by chopping off the two ends in the centre to make a duel cell holder.

Here's a pic showing one I put together last year for a cosplayer's prop weapon:

(http://i1225.photobucket.com/albums/ee395/Can-obi/IMG_20150122_001800.jpg) (http://s1225.photobucket.com/user/Can-obi/media/IMG_20150122_001800.jpg.html)
(http://i1225.photobucket.com/albums/ee395/Can-obi/IMG_20160112_220826.jpg) (http://s1225.photobucket.com/user/Can-obi/media/IMG_20160112_220826.jpg.html)



actually, Canobi the board making jedi,..  the batt holders have pcb pins.  you could mount your little board doohicky to the back of the batt holders. i think 7.4v is Jake approved if you are hoping to clone his setup. if you need a compact batt system. it may be the one!
I have some of those and tried that but the board width has to be restricted to 20mm wide or the assembly won't fit 1" IDs. There's a pic of my board on page 3 as it was when I first found Jakes thread. The routing is nowhere near as tidy as it is now and the board measured 146mm long without the accelerometer which adds another 15mm to the overall length.

I'm working on ways to bring a cell back into the mix for the smaller hilts somehow but mounting it isnt the way. Not such a problem for the wider fraternity so may look into doing one for those while I look for an answer to the other.

Canobi, can you send, or post me a high-con (high contrast black and white image) of your PCB board and its dimensions.  I'd like to make a 3D model of it, and then create a visualization of how it could be applied directly to a battery system. i think i can make a Hi-Con,.  if you could tell me the lxwxh, that would be sufficient.
I'll send you a high res PDF as soon as the board has been reworked but for now....

PCB substrate:

L= 97.2mm
W=24.42mm
H=1.6mm

Header pin chassis (the plastic bit) :

W = 1.27mm
H = 1.27mm

I think the pro mini and WT PCB is only .9~1.1mm thick but haven't got good enough calipers to get an exact measurement.



image attached.  the white paper would be the cake.
Here's one I mounted on a slightly different kind of cake I made for a stunt saber:

(http://i1225.photobucket.com/albums/ee395/Can-obi/IMG_20160112_222917.jpg) (http://s1225.photobucket.com/user/Can-obi/media/IMG_20160112_222917.jpg.html)

Lithium charging was the first thing on my list to tackle when I decided to make my saber fx system, took me the best part of a year to learn what I needed so I could confidently make and try the circuit without quite so much risk of blowing batteries or myself up. Luckily (though frustratingly) they've been duds and didn't do anything, a much preferable outcome for a failure when dealing with lithuim but I think I've finally worked out where I'm going wrong so making another proto.

The circuit is also now smaller than the cell it charges which makes for some intersting ways to include it. I have three ideas I'm toying with. Two of them were inspired by some S1 flex PCB I bought to play with. It's normally used for making ribbon connectors or 12v flexible LED light strips and is only 4mils (0.1016mm) thick so is super bendy.


1. Battery wrap

(http://i1225.photobucket.com/albums/ee395/Can-obi/IMG_20151205_170105.jpg) (http://s1225.photobucket.com/user/Can-obi/media/IMG_20151205_170105.jpg.html)

Advantages:

•The NTC thermistor that tells the ic how hot the cell is getting during the fast charge cycle will get a much more accurate temp reading sat on the battery.
•No increase in space requirements.

Disadvantages

• it will need to be put in a cradle or supported in some way so the components don't get knocked off.
• ic will run hotter when the battery gets warm during fast charge cycle


2. Hilt lining

This is the reverse to the battery wrap as this time the PCB is fixed to the hilt wall (sorry, no pic for this one)

Advantages:

• the ic will run a lot cooler as the metal of the hilt woll act as a heat sink.
•No increase in space requirements.

Disadvantages

•The NTC thermistor that tells the ic how hot the cell is getting during the fast charge cycle will get a much less accurate temp reading sat on metal hilts.
• the wire leads will need to be longer and the PCB could get a bit complicated to fit properly without risk of damage.


3. The hitchhiker (this is my favorite so far as it's simple and doesn't actually rely on being flexible)

The circuit is just small enough to fit between the pro mini pins so could easily just be glued to the underside of the fx PCB in an open spot and wired to the fx board from there.
Title: Re: Arduino Lightsaber
Post by: JakeSoft on Jan 13, 2016, 05:55 pm
I saw that you connect the ADXL335 X/Y/Z outputs to the Arduino. Do you keep polling these outputs in each loop? How are the data arriving? Do you get a digital value or is it more like an analog value from 0 to rail? Is it possible to scale to different acceleration ranges?

For my build I use the MPU-6050 breakout board, it has a 2-line interface (DO/DI), Vcc and GND, so far I'm happy with the results for both swings and clashes, but I'm looking out for a 2nd option.
Your MPU is more sophisticated (and portly ;-) ) . I do like the reduced I/O required to operate it. That's on my list of things to try as well as the sound module you  used in your project. I like the bulit-in 3W amplifier, but I'm not keen on the SD card because of compatibility issue that always seem to pop up with those.

The short answer to your question is that I'm polling for accelerometer data every 10 ms to detect the swings. You just have to do an analog read of X, Y, and Z. The ADXL335 unit measures a fixed +/-3G. It's supposed to give an analog reading of 0 to 1024 (0V to 3V), but in reality I never see values outside of a much narrower range than that.
Title: Re: Arduino Lightsaber
Post by: Dizzyua on Jan 13, 2016, 06:51 pm
Someone say cake?

(http://i1225.photobucket.com/albums/ee395/Can-obi/IMG_20151231_215622.jpg) (http://s1225.photobucket.com/user/Can-obi/media/IMG_20151231_215622.jpg.html)

Shame the routing is off but at least I know they come out ok.
Do you have pcb project file for any software? :)
Title: Re: Arduino Lightsaber
Post by: Canobi on Jan 13, 2016, 08:41 pm
Do you have pcb project file for any software? :)
Hi Dizzyua, I don't use PCB CAD, just my android phone to make PDFs.
Title: Re: Arduino Lightsaber
Post by: billpealer on Jan 13, 2016, 09:15 pm
You can make it even shorter by chopping off the two ends in the centre to make a duel cell holder.

but then you have to have something now like a sleeve clip or retention clip to hold the center of the 2 batts tight together. No?

that will save a cm or so tho. i thought about it. i also thought about printing a custom holder with retension tabs for both batts, and just rape the metal connections parts from the batt holders to epoxt into the ends. that is a RAD costume by the way! Sweet. plus a good looking lady can sell water in a rain storm!

I understand it will not work in PVC.  i am a 1" PVC hater.  if you are gonna go cheap, then do it all the way and buy a walmart lightsaber $9 clearance, and pull its guts for the speaker, sound and LED button.  add a mosfet, and LED, and 3 1.2v NiMH and your fave LED,..  done.  cheap done cheap, and done cheap right. Cheaper than an arduino and WT buy about $25 me thinks.

All this arduino WT talk for PVC, im my mind is like slamming a Corvette Engine into a Cobalt. sure, you can talk about it, and maybe even do it...  but you could just buy the corvette. Do saber builders really not have the $95 to buy the TCSS parts? If not?  then it is by far cheaper, and VERY VIABLE to use the Hasbro method.

there is also 1 1/4" PVC,  how come no one uses that?  too fat on the OD?
Title: Re: Arduino Lightsaber
Post by: Kamensky on Jan 13, 2016, 10:18 pm
I saw that you connect the ADXL335 X/Y/Z outputs to the Arduino. Do you keep polling these outputs in each loop? How are the data arriving? Do you get a digital value or is it more like an analog value from 0 to rail? Is it possible to scale to different acceleration ranges?

For my build I use the MPU-6050 breakout board, it has a 2-line interface (DO/DI), Vcc and GND, so far I'm happy with the results for both swings and clashes, but I'm looking out for a 2nd option.
OMG, SIR! Excuse me, but i rly need ur help if it's possible ofc. Same as u do - i use MPU-6050, but i'm sooo nooby with code. This model is xtrmly difficult for me. Could you share the code, please?
Title: Re: Arduino Lightsaber
Post by: JakeSoft on Jan 13, 2016, 10:30 pm
I understand it will not work in PVC.  i am a 1" PVC hater.  if you are gonna go cheap, then do it all the way and buy a walmart lightsaber $9 clearance, and pull its guts for the speaker, sound and LED button.  add a mosfet, and LED, and 3 1.2v NiMH and your fave LED,..  done.  cheap done cheap, and done cheap right. Cheaper than an arduino and WT buy about $25 me thinks.

All this arduino WT talk for PVC, im my mind is like slamming a Corvette Engine into a Cobalt. sure, you can talk about it, and maybe even do it...  but you could just buy the corvette. Do saber builders really not have the $95 to buy the TCSS parts? If not?  then it is by far cheaper, and VERY VIABLE to use the Hasbro method.

there is also 1 1/4" PVC,  how come no one uses that?  too fat on the OD?
I get what you're saying, but in my mind anyone who has put in the time to build their own board can put it in whatever they want. They've earned the right. If Canobi provides a viable PCB, you could probably build one of these things in an hour, once your WT and Arduino programming are done anyway. Still, probably not many will do pure PVC with this setup. The 1" PVC and Poly pipe is great for make-shift chassis and sleds though, so probably lots of people will do that.

I do find the 1 ¼" PVC to be to thick for comfort.
Title: Re: Arduino Lightsaber
Post by: Dizzyua on Jan 13, 2016, 10:52 pm
Hi Dizzyua, I don't use PCB CAD, just my android phone to make PDFs.
You are design board on android phone? :) I thinks what you create design project in some software and after create real board :)
Title: Re: Arduino Lightsaber
Post by: billpealer on Jan 14, 2016, 01:07 am
I get what you're saying, but in my mind anyone who has put in the time to build their own board can put it in whatever they want. They've earned the right.
dude of course.

  if you bought the filet with your own money, you can eat it well done, cold, with ranch dressing,  on paper plates with plastic silverware. that's your prerogative.   but i will still shake my head, not understanding.

The 1" PVC and Poly pipe is great for make-shift chassis and sleds though, so probably lots of people will do that.
educate me.  what is this?
Title: Re: Arduino Lightsaber
Post by: JakeSoft on Jan 14, 2016, 02:28 am
dude of course.

  if you bought the filet with your own money, you can eat it well done, cold, with ranch dressing,  on paper plates with plastic silverware. that's your prerogative.   but i will still shake my head, not understanding.


educate me.  what is this?
Go to your hardware store and find 1" polyurethane pipe. The OD just fits inside of MHS parts. If you look at my Mk. II video, that's what you are seeing when I take it apart to show the internals. I just cut shapes and holes in it as needed to accommodate the parts I was putting into the saber. You can't tap it, but it fits without the need to sand it down at all!

Lots of people, including some of the more prominent sabersmiths out there, use 1" electrical conduit in a similar way, however I have yet to find any that will fit in MHS without sanding. Easy enough if you've got a lathe, tedious if you don't.
Title: Re: Arduino Lightsaber
Post by: Canobi on Jan 14, 2016, 09:02 am
but then you have to have something now like a sleeve clip or retention clip to hold the center of the 2 batts tight together. No?
I was expecting them to "pop" up due to the tab pressure as they do sometimes but the cells stayed in the holder pretty well as it happens.

that will save a cm or so tho. i thought about it. i also thought about printing a custom holder with retension tabs for both batts, and just rape the metal connections parts from the batt holders to epoxt into the ends. that is a RAD costume by the way! Sweet. plus a good looking lady can sell water in a rain storm!
The sled is a neat idea actually but if you have the power to make it any shape you want, why not make holes for the pins to go through and tab retention slots like the holders?

I have the datasheet for these holders which has all the measurements, if it's not too big it should be attached below.

I understand it will not work in PVC.  i am a 1" PVC hater.  if you are gonna go cheap, then do it all the way and buy a walmart lightsaber $9 clearance, and pull its guts for the speaker, sound and LED button.  add a mosfet, and LED, and 3 1.2v NiMH and your fave LED,..  done.  cheap done cheap, and done cheap right. Cheaper than an arduino and WT buy about $25 me thinks.

All this arduino WT talk for PVC, im my mind is like slamming a Corvette Engine into a Cobalt. sure, you can talk about it, and maybe even do it...  but you could just buy the corvette. Do saber builders really not have the $95 to buy the TCSS parts? If not?  then it is by far cheaper, and VERY VIABLE to use the Hasbro method.A
Methinks there has been a slight misunderstanding.

The 1" deal is all down to the stock alu tubing I use to scratch build some of my saber with. To make my life a bit easier in the workshop, I use a 30mm OD x 25mm ID tube for the main body as it's ID is the same size as the poly blades so also doubles as the blade seat. I then sleeve the main body with 30mm ID tubes of varying thickness (usually up to 34mm as its hard to find thicker tubing with the same ID) to make the emitter shrouds and/or other hilt details and other parts.

Having the board fit a 25mm hole also doesn't leave anyone out.

there is also 1 1/4" PVC,  how come no one uses that?  too fat on the OD?
When I started out making sabers, I only ever used 1 1/4" PVC:

(http://i1225.photobucket.com/albums/ee395/Can-obi/Canyons%20Custome%20PVC%20Lightsabers/11CC5EFE-F2D1-46F0-8AA4-56AA71D9499E-256-000000384526ED21.jpg) (http://s1225.photobucket.com/user/Can-obi/media/Canyons%20Custome%20PVC%20Lightsabers/11CC5EFE-F2D1-46F0-8AA4-56AA71D9499E-256-000000384526ED21.jpg.html)
(http://i1225.photobucket.com/albums/ee395/Can-obi/Canyons%20Custome%20PVC%20Lightsabers/33F1E171-959E-4F03-B372-E12FD271432F-1515-00000120F5BDBCF6.jpg) (http://s1225.photobucket.com/user/Can-obi/media/Canyons%20Custome%20PVC%20Lightsabers/33F1E171-959E-4F03-B372-E12FD271432F-1515-00000120F5BDBCF6.jpg.html)

I only have WIP shots of the silver ones but the blue one turned out like this:

(http://i1225.photobucket.com/albums/ee395/Can-obi/Canyons%20Custome%20PVC%20Lightsabers/F8627FC6-539E-4E2E-805F-0AAE8FFE03D2-227-00000014778F2EF7.jpg) (http://s1225.photobucket.com/user/Can-obi/media/Canyons%20Custome%20PVC%20Lightsabers/F8627FC6-539E-4E2E-805F-0AAE8FFE03D2-227-00000014778F2EF7.jpg.html)
Title: Re: Arduino Lightsaber
Post by: Canobi on Jan 14, 2016, 11:02 am
You are design board on android phone? :) I thinks what you create design project in some software and after create real board :)
I use a process called toner transfer where I print the artwork on gloss photo paper, then after cleaning the copper I place the work print side down on the copper and put them through a hot roll laminator set to max temp.

The heat and pressure from the laminator re melts the toner which sticks to the copper a lot better than it does the gloss paper.

It's then put in warm water to remove all the paper (and gloss layer) and put in the etch tank.
Title: Re: Arduino Lightsaber
Post by: JakeSoft on Jan 14, 2016, 02:55 pm
Methinks there has been a slight misunderstanding.

The 1" deal is all down to the stock alu tubing I use to scratch build some of my saber with. To make my life a bit easier in the workshop, I use a 30mm OD x 25mm ID tube for the main body as it's ID is the same size as the poly blades so also doubles as the blade seat. I then sleeve the main body with 30mm ID tubes of varying thickness (usually up to 34mm as its hard to find thicker tubing with the same ID) to make the emitter shrouds and/or other hilt details and other parts.

Having the board fit a 25mm hole also doesn't leave anyone out.

When I started out making sabers, I only ever used 1 1/4" PVC:

I only have WIP shots of the silver ones but the blue one turned out like this:

(http://i1225.photobucket.com/albums/ee395/Can-obi/Canyons%20Custome%20PVC%20Lightsabers/F8627FC6-539E-4E2E-805F-0AAE8FFE03D2-227-00000014778F2EF7.jpg) (http://s1225.photobucket.com/user/Can-obi/media/Canyons%20Custome%20PVC%20Lightsabers/F8627FC6-539E-4E2E-805F-0AAE8FFE03D2-227-00000014778F2EF7.jpg.html)
Cool sabers! I should also amend what I said earlier. I don't like 1¼" thick-walled (schedule 40) PVC for anywhere I might need to wrap my  hand around, but thin-walled is OK. If you look at my WT588D stand-alone video, that's a 1¼" thin-walled PVC pipe extension. In my PVC saber with cheap hasbro board, that's a combination of 1" and 1¼" schedule 40. So, 1¼" is OK as long as it's used somewhere other than where I'll hold it with my dominant hand.

Title: Re: Arduino Lightsaber
Post by: Canobi on Jan 14, 2016, 05:16 pm
OK, the board is finished and I just need to export the PDFs to photoshop for a quick tweak.

I'll attach a high res pic of of the layout later but first I wanted to quickly go over the new power rail system.

I had to put my thinking cap on for this one but a comment made a while back about bridging gave me an idea.

The power rails are now regulated as requested and supports singular, or multi voltage setups for the pro mini and WT in any combination you wish using a new bridging system.

I made this set of pics to show which pads are bridged to achieve the various voltage options:

(http://i1225.photobucket.com/albums/ee395/Can-obi/IMG_20160114_121840.jpg) (http://s1225.photobucket.com/user/Can-obi/media/IMG_20160114_121840.jpg.html)

(http://i1225.photobucket.com/albums/ee395/Can-obi/IMG_20160114_150532.jpg) (http://s1225.photobucket.com/user/Can-obi/media/IMG_20160114_150532.jpg.html)

(http://i1225.photobucket.com/albums/ee395/Can-obi/IMG_20160114_154155.jpg) (http://s1225.photobucket.com/user/Can-obi/media/IMG_20160114_154155.jpg.html)

(http://i1225.photobucket.com/albums/ee395/Can-obi/IMG_20160114_154718.jpg) (http://s1225.photobucket.com/user/Can-obi/media/IMG_20160114_154718.jpg.html)
Title: Re: Arduino Lightsaber
Post by: JakeSoft on Jan 14, 2016, 07:07 pm
OK, the board is finished and I just need to export the PDFs to photoshop for a quick tweak.

I'll attach a high res pic of of the layout later but first I wanted to quickly go over the new power rail system.

I had to put my thinking cap on for this one but a comment made a while back about bridging gave me an idea.

The power rails are now regulated as requested and supports singular, or multi voltage setups for the pro mini and WT in any combination you wish using a new bridging system.

I made this set of pics to show which pads are bridged to achieve the various voltage options:

(http://i1225.photobucket.com/albums/ee395/Can-obi/IMG_20160114_121840.jpg) (http://s1225.photobucket.com/user/Can-obi/media/IMG_20160114_121840.jpg.html)

(http://i1225.photobucket.com/albums/ee395/Can-obi/IMG_20160114_150532.jpg) (http://s1225.photobucket.com/user/Can-obi/media/IMG_20160114_150532.jpg.html)

(http://i1225.photobucket.com/albums/ee395/Can-obi/IMG_20160114_154155.jpg) (http://s1225.photobucket.com/user/Can-obi/media/IMG_20160114_154155.jpg.html)

(http://i1225.photobucket.com/albums/ee395/Can-obi/IMG_20160114_154718.jpg) (http://s1225.photobucket.com/user/Can-obi/media/IMG_20160114_154718.jpg.html)
I like the concept.

A few notes (I know you love these):

1) You'll need to move the arduino power off of the RAW pin and move it to VCC. Giving 3.3V to the raw pin will never power any type of pro mini. It won't work because you''ll be feeding 3.3V into the 3.3V regulator on the board. Since the power rails are all regulated now, you should be putting it to the VCC pin anyway because it doesn't make sense to regulate the voltage twice.

2) I like the bridge concept, however I suggest spacing them out a little and using through-hold vias instead of closely spaced solder pads. This makes it easy for  ham-fisted solder novices to put a jumper wire through and solder it more easily. I can see folks accidentally bridging 3.3V to 5V and the chaos that will cause.

3) The VCC pin on the WT588D needs to be connected to the 3.3V rail. Always, no exceptions.
Title: Re: Arduino Lightsaber
Post by: Canobi on Jan 14, 2016, 09:33 pm
I like the concept.

A few notes (I know you love these):

1) You'll need to move the arduino power off of the RAW pin and move it to VCC. Giving 3.3V to the raw pin will never power any type of pro mini. It won't work because you''ll be feeding 3.3V into the 3.3V regulator on the board. Since the power rails are all regulated now, you should be putting it to the VCC pin anyway because it doesn't make sense to regulate the voltage twice.

2) I like the bridge concept, however I suggest spacing them out a little and using through-hold vias instead of closely spaced solder pads. This makes it easy for  ham-fisted solder novices to put a jumper wire through and solder it more easily. I can see folks accidentally bridging 3.3V to 5V and the chaos that will cause.

3) The VCC pin on the WT588D needs to be connected to the 3.3V rail. Always, no exceptions.
1. I'm a bit confused, I keep seeing people using Vcc to power stuff, is it an input, output or both?

2. Through hole vias may be too big for this to work and if I did use them, they would probably be very small anyway but I will look into it.

Spacing the pads out any further will make them hard to bridge so I might just pre bridge them and have the end user tell me which setup they want to go with when ordering.

3. When I talk about the WT voltage I do mean it's main power, mem voltage stays at 3v3.
Title: Re: Arduino Lightsaber
Post by: JakeSoft on Jan 14, 2016, 11:11 pm
1. I'm a bit confused, I keep seeing people using Vcc to power stuff, is it an input, output or both?
It's both. If you put battery power to the RAW pin then you are supplying power to the Arduino's on-board voltage regulator, which then regulates the voltage to the 3.3V rail on the Arduino itself (in the case of a 3.3V pro mini, it's 5V for a Nano or 5V pro mini).

The VCC pin on the Arduino is tied directly to the Arduino's 3.3V rail, so if you have a regulated supply at the right voltage then you can go right to that pin. By putting power to the VCC pin you are *bypassing* the voltage regulator on the Arduino board.

Now here's where it gets tricky. If you put power to the RAW pin, that will cause the voltage to be regulated to 3.3V (or 5V, depending on the flavor of Arduino). That VCC pin is still tied directly to the Arduino's regulated power rail, so it now becomes a source of regulated voltage!

So, if you power the arduino with regulated voltage, the VCC pin is an input. If you power the Arduino with the RAW pin, the VCC pin is an output. Neat, huh?


2. Through hole vias may be too big for this to work and if I did use them, they would probably be very small anyway but I will look into it.

Spacing the pads out any further will make them hard to bridge so I might just pre bridge them and have the end user tell me which setup they want to go with when ordering.
That sounds like an excellent idea.

3. When I talk about the WT voltage I do mean it's main power, mem voltage stays at 3v3.
Ok, I was just noticing on the diagrams that you posted that the 3.3v pin on the WT588D had nothing attached to it.
Title: Re: Arduino Lightsaber
Post by: MegaCorsair on Jan 14, 2016, 11:12 pm
Dude, I Love your job!
I Came here thanks to your last video on youtube (Arduino Lightsaber Mk IV Breadboard (https://www.youtube.com/watch?v=cLFOHKq9bLE)) and i have this Things:

- Arduino Pro Mini (3.3V & 5V version 8) )
- 2 ADXL335 Accelerometer (Sparkfun & Analog Devices)
- Wt588d-28p & WT588D Usb Interface -32MBits
- 16-pin DIP socket  :smiley-mr-green:
- 1w Red Led
- A Library of lightsaber sounds.wav  :P

Like I see, I Have all to build the Lightsaber but... I an a Arduino Noob  :smiley-sad-blue:
And I dont found a Assemble Schematic and Code to use assemble and test  :'( ... You can do One like tutorial?  I just want to make a bladebuilders modified Lightsaber with the standart sounds things like On/Off , Swing, Shock and "Wnnnnnnn" (Yeah, Sounds crazy Hahaha :smiley-cry: ) Like this:
Lightsaber sound effects (https://www.youtube.com/watch?v=__sDEWIjQ_g)
And like i say, Good Work on every Mark Haha  :smiley-mr-green:
Title: Re: Arduino Lightsaber
Post by: Canobi on Jan 15, 2016, 12:09 am
It's both. If you put battery power to the RAW pin then you are supplying power to the Arduino's on-board voltage regulator, which then regulates the voltage to the 3.3V rail on the Arduino itself (in the case of a 3.3V pro mini, it's 5V for a Nano or 5V pro mini).

The VCC pin on the Arduino is tied directly to the Arduino's 3.3V rail, so if you have a regulated supply at the right voltage then you can go right to that pin. By putting power to the VCC pin you are *bypassing* the voltage regulator on the Arduino board.

Now here's where it gets tricky. If you put power to the RAW pin, that will cause the voltage to be regulated to 3.3V (or 5V, depending on the flavor of Arduino). That VCC pin is still tied directly to the Arduino's regulated power rail, so it now becomes a source of regulated voltage!

So, if you power the arduino with regulated voltage, the VCC pin is an input. If you power the Arduino with the RAW pin, the VCC pin is an output. Neat, huh?
Well that explains it then, very neat :)

Ok, I was just noticing on the diagrams that you posted that the 3.3v pin on the WT588D had nothing attached to it.
Ah yes, I hadn't reconnected it when I took the screen grabs, done now.

Sorry about this but I've had to reverse order the XYZ pin designation as I realised the ADXL was facing the wrong way round which would make it impossible to mount the 5v micro boost buck.
Title: Re: Arduino Lightsaber
Post by: JakeSoft on Jan 15, 2016, 03:20 am
Sorry about this but I've had to reverse order the XYZ pin designation as I realised the ADXL was facing the wrong way round which would make it impossible to mount the 5v micro boost buck.

That's not a big deal, actually as my software doesn't currently care which axis is which anyway. ;-)

I updated the code in post #366 to reflect this.
Title: Re: Arduino Lightsaber
Post by: JakeSoft on Jan 15, 2016, 03:32 am
Dude, I Love your job!
I Came here thanks to your last video on youtube (Arduino Lightsaber Mk IV Breadboard (https://www.youtube.com/watch?v=cLFOHKq9bLE)) and i have this Things:

- Arduino Pro Mini (3.3V & 5V version 8) )
- 2 ADXL335 Accelerometer (Sparkfun & Analog Devices)
- Wt588d-28p & WT588D Usb Interface -32MBits
- 16-pin DIP socket  :smiley-mr-green:
- 1w Red Led
- A Library of lightsaber sounds.wav  :P

Like I see, I Have all to build the Lightsaber but... I an a Arduino Noob  :smiley-sad-blue:
And I dont found a Assemble Schematic and Code to use assemble and test  :'( ... You can do One like tutorial?  I just want to make a bladebuilders modified Lightsaber with the standart sounds things like On/Off , Swing, Shock and "Wnnnnnnn" (Yeah, Sounds crazy Hahaha :smiley-cry: ) Like this:
Lightsaber sound effects (https://www.youtube.com/watch?v=__sDEWIjQ_g)
And like i say, Good Work on every Mark Haha  :smiley-mr-green:
Hello, and welcome to the discussion! It looks like you've got what you need to get started. My best advice is to read this entire thread, although now that you mention it, I never did really post up a schematic for the Mk. III/IV systems that use the accelerometer. Oh well, maybe when I have time I'll create one. But if you're just starting out, you've got a while before you need to worry about that.

Step 1 is to get your Arduino talking to your WT588D. Once you get that, you're ready to move on to some buttons and sensors.
Title: Re: Arduino Lightsaber
Post by: MegaCorsair on Jan 15, 2016, 03:56 am
Hello, and welcome to the discussion! It looks like you've got what you need to get started. My best advice is to read this entire thread, although now that you mention it, I never did really post up a schematic for the Mk. III/IV systems that use the accelerometer. Oh well, maybe when I have time I'll create one. But if you're just starting out, you've got a while before you need to worry about that.

Step 1 is to get your Arduino talking to your WT588D. Once you get that, you're ready to move on to some buttons and sensors.

Thanks for the Response! I'm gonna try that meamwhile I wait for your tutorial dude :)
Title: Re: Arduino Lightsaber
Post by: billpealer on Jan 15, 2016, 05:16 pm
http://www.ebay.com/itm/Mini-Pro-Micro-ATmega32U4-5V-16MHz-Replace-ATmega328-Arduino-Pro-/191756162028?hash=item2ca58ed3ec:g:eWYAAOSwnH1WZ8IF (http://www.ebay.com/itm/Mini-Pro-Micro-ATmega32U4-5V-16MHz-Replace-ATmega328-Arduino-Pro-/191756162028?hash=item2ca58ed3ec:g:eWYAAOSwnH1WZ8IF)

1cm shorter than the Nano.
a bit more "ready-to-run" than the Pro Mini

the 5v version is 16mhz
Title: Re: Arduino Lightsaber
Post by: Canobi on Jan 15, 2016, 06:36 pm
All finished :)

(http://i1225.photobucket.com/albums/ee395/Can-obi/IMG_20160115_173251.jpg) (http://s1225.photobucket.com/user/Can-obi/media/IMG_20160115_173251.jpg.html)

And here's a link to the high res pic as promised:

https://www.dropbox.com/s/e79t2a7bo8ggo4w/Spectrum%20saber%20board%20-%20ADXL%20varient.jpg?dl=0 (https://www.dropbox.com/s/e79t2a7bo8ggo4w/Spectrum%20saber%20board%20-%20ADXL%20varient.jpg?dl=0)
Title: Re: Arduino Lightsaber
Post by: JakeSoft on Jan 15, 2016, 07:35 pm
http://www.ebay.com/itm/Mini-Pro-Micro-ATmega32U4-5V-16MHz-Replace-ATmega328-Arduino-Pro-/191756162028?hash=item2ca58ed3ec:g:eWYAAOSwnH1WZ8IF (http://www.ebay.com/itm/Mini-Pro-Micro-ATmega32U4-5V-16MHz-Replace-ATmega328-Arduino-Pro-/191756162028?hash=item2ca58ed3ec:g:eWYAAOSwnH1WZ8IF)

1cm shorter than the Nano.
a bit more "ready-to-run" than the Pro Mini

the 5v version is 16mhz
Ooo, and it comes in 3.3V flavor as well.

http://www.ebay.com/itm/New-Pro-Micro-ATmega32U4-3-3V-8MHz-Replace-ATmega328-Arduino-Pro-Mini-M94-/351493857244?hash=item51d6aa9fdc:g:ZNYAAOSw8cNUNjmE (http://www.ebay.com/itm/New-Pro-Micro-ATmega32U4-3-3V-8MHz-Replace-ATmega328-Arduino-Pro-Mini-M94-/351493857244?hash=item51d6aa9fdc:g:ZNYAAOSw8cNUNjmE)

It's actually smaller than the Pro Mini if you take into account the programming headers on the mini either add additional height (straight pins) or length (90-degree pins).

Title: Re: Arduino Lightsaber
Post by: billpealer on Jan 15, 2016, 07:49 pm
Anyone want to sell me an ADXL335? They are wicked cheap from China, but i don't want to wait 3 weeks.

the cheapest i can find on ebay US location is $4.78

anyone have an extra?  i'll pay $4.50 :)
Title: Re: Arduino Lightsaber
Post by: billpealer on Jan 15, 2016, 07:58 pm
Ooo, and it comes in 3.3V flavor as well.

http://www.ebay.com/itm/New-Pro-Micro-ATmega32U4-3-3V-8MHz-Replace-ATmega328-Arduino-Pro-Mini-M94-/351493857244?hash=item51d6aa9fdc:g:ZNYAAOSw8cNUNjmE (http://www.ebay.com/itm/New-Pro-Micro-ATmega32U4-3-3V-8MHz-Replace-ATmega328-Arduino-Pro-Mini-M94-/351493857244?hash=item51d6aa9fdc:g:ZNYAAOSw8cNUNjmE)

It's actually smaller than the Pro Mini if you take into account the programming headers on the mini either add additional height (straight pins) or length (90-degree pins).
dazwadimzayin!  wait? what?  why do you WANT to go 3v? now you can use the WT588D_U  guilt free.  you get less wiring, and a faster cpu by double. all devices can be 5v and USB.  no need for a 5v regulator,.. no need for 2 V+ going into the  WT..   so many pluses.
Title: Re: Arduino Lightsaber
Post by: CrossRoads on Jan 15, 2016, 08:17 pm
Have you tried a legit distributor?
http://www.digikey.com/product-search/en/sensors-transducers/accelerometers/1966355?k=ADXL335 (http://www.digikey.com/product-search/en/sensors-transducers/accelerometers/1966355?k=ADXL335)
http://www.mouser.com/Sensors/Motion-Position-Sensors/_/N-6g7q6?Keyword=ADXL335&FS=True (http://www.mouser.com/Sensors/Motion-Position-Sensors/_/N-6g7q6?Keyword=ADXL335&FS=True)
Title: Re: Arduino Lightsaber
Post by: JakeSoft on Jan 15, 2016, 08:47 pm
dazwadimzayin!  wait? what?  why do you WANT to go 3v? now you can use the WT588D_U  guilt free.  you get less wiring, and a faster cpu by double. all devices can be 5v and USB.  no need for a 5v regulator,.. no need for 2 V+ going into the  WT..   so many pluses.
Yeah, there are a lot of pluses to be sure. I have been building these for quite a while now and tried lots of different things. I just like the 3.3V setup because it offers the greatest flexibility and ease for the particular way that I do things. Remember that the parts I use (WT588D 16p and GY-61 ADXL335) both require a 3.3V source.

Title: Re: Arduino Lightsaber
Post by: JakeSoft on Jan 15, 2016, 08:54 pm
Have you tried a legit distributor?
http://www.digikey.com/product-search/en/sensors-transducers/accelerometers/1966355?k=ADXL335 (http://www.digikey.com/product-search/en/sensors-transducers/accelerometers/1966355?k=ADXL335)
http://www.mouser.com/Sensors/Motion-Position-Sensors/_/N-6g7q6?Keyword=ADXL335&FS=True (http://www.mouser.com/Sensors/Motion-Position-Sensors/_/N-6g7q6?Keyword=ADXL335&FS=True)
Good suggestion, but I think he needs a breakout board.

Look what I found from Sears of all places!
http://www.sears.com/unique-bargains-2pcs-gy-61-adxl335-module-3/p-SPM7928239123?hlSellerId=29267&sid=IDx20110310x00001i&kpid=SPM7928239123&kispla=SPM7928239123 (http://www.sears.com/unique-bargains-2pcs-gy-61-adxl335-module-3/p-SPM7928239123?hlSellerId=29267&sid=IDx20110310x00001i&kpid=SPM7928239123&kispla=SPM7928239123)

Must be some appliances they sell use them for something; it's under replacement parts.
Title: Re: Arduino Lightsaber
Post by: billpealer on Jan 15, 2016, 09:06 pm
Have you tried a legit distributor?
http://www.digikey.com/product-search/en/sensors-transducers/accelerometers/1966355?k=ADXL335 (http://www.digikey.com/product-search/en/sensors-transducers/accelerometers/1966355?k=ADXL335)
http://www.mouser.com/Sensors/Motion-Position-Sensors/_/N-6g7q6?Keyword=ADXL335&FS=True (http://www.mouser.com/Sensors/Motion-Position-Sensors/_/N-6g7q6?Keyword=ADXL335&FS=True)
WHAT?!
Is this some kind of CS joke?  That's a terrible suggestion! LOL.

If I asked you where to buy a fish sandwich, and you showed me a picture of a lake and said "try here",..  i'd either laugh or be insulted.   So i'll just laugh.

And the people here are pretty dang legit.

I need the module, not the chip.  as 99.99999999999999997651%  of everyone else would too.

plus DigiKey sells the Chip for $6.00!!!!????  you can get the whole module for $5 on the bay and apparently at Sears!  LOL
Title: Re: Arduino Lightsaber
Post by: billpealer on Jan 15, 2016, 09:19 pm
Yeah, there are a lot of pluses to be sure. I have been building these for quite a while now and tried lots of different things. I just like the 3.3V setup because it offers the greatest flexibility and ease for the particular way that I do things. Remember that the parts I use (WT588D 16p and GY-61 ADXL335) both require a 3.3V source.

and the Nano is too big? it has 3.3v output pin. don't you want to 86 the linear regulator?
Title: Re: Arduino Lightsaber
Post by: JakeSoft on Jan 15, 2016, 09:22 pm

All finished :)

(http://i1225.photobucket.com/albums/ee395/Can-obi/IMG_20160115_173251.jpg) (http://s1225.photobucket.com/user/Can-obi/media/IMG_20160115_173251.jpg.html)

And here's a link to the high res pic as promised:

https://www.dropbox.com/s/e79t2a7bo8ggo4w/Spectrum%20saber%20board%20-%20ADXL%20varient.jpg?dl=0 (https://www.dropbox.com/s/e79t2a7bo8ggo4w/Spectrum%20saber%20board%20-%20ADXL%20varient.jpg?dl=0)
It keeps getting better and better! I like the placement of the switch vias a lot better now.

Still a few issues.

1) The ADXL335 doesn't appear to have a positive power source linked in directly from any rail. The silkscreen seems to suggest that you intend to bridge it to raw battery power with a jumper maybe? If so, that will blow it up; the GY-61 ADXL335 is a 3.3V device. It needs to be attached to the 3.3V rail somehow and only fed regulated voltage.
2) This will work perfectly for a 3.3V Arduino variant, but will be incompatable with 5V Pro Mini or Nano. That's fine if that's what you intended, but 5V to the RAW pin will not power any standard arduino board. 5V will be under the dropout voltage of the arduino's on-board 5V regulator and it won't work. To compensate for this, you could
A) Bring out the raw pin to a via at the edge of the board and allow for direct battery power to be fed to the Arduino
B) Feed the 5V rail to the VCC pin via jumper as was done with the 3.3v rail.
3) [nit]The silk screen on pin 13 should be "SDA" as it is the one-line serial data, not a serial clock. Same with the "CLK" on the WT588D.

Just as a general comment, I've noticed that the power rail design meant to widen compatibility is adding some complexity that might be avoided if you simply made two distinct versions of the board.
Title: Re: Arduino Lightsaber
Post by: billpealer on Jan 15, 2016, 09:29 pm
It needs to be attached to the 3.3V rail somehow and only fed regulated voltage.
2) This will work perfectly for a 3.3V Arduino variant, but will be incompatable with 5V Pro Mini or Nano.
the Nano has a 3.3v rail.  3v3pin..

"The 3.3V regulated output is able to supply 150 mA"
Title: Re: Arduino Lightsaber
Post by: CrossRoads on Jan 15, 2016, 09:35 pm
I believe the 3.3V on a Nano comes from the FTDI chip, and is only capable of 50mA.
Title: Re: Arduino Lightsaber
Post by: JakeSoft on Jan 15, 2016, 09:48 pm
I believe the 3.3V on a Nano comes from the FTDI chip, and is only capable of 50mA.
Oh? Good info. I don't think I've ever actually tried to use it on my Nano.

I once tried to power my WT588D purely from the on-board regulator of my 3.3V pro Mini (an official Arduino board too, not a cheap clone) and I don't think it can source enough current to operate it properly either. It did work, but the sound would crackle and cut out once in a while. I got the feeling I was pushing the limits.

I wonder how much current those pro-micro boards that were posted earlier can source.
Title: Re: Arduino Lightsaber
Post by: CrossRoads on Jan 15, 2016, 09:58 pm
"I need the module, not the chip.  as 99.99999999999999997651%  of everyone else would too."
So I guess it's just me that mounts chips on boards. Module was not mentioned in the request.  And I provided a specific link to a fish sandwich, not a lake.
Modules are also available http://www.digikey.com/product-search/en/programmers-development-systems/evaluation-boards-sensors/2622557?k=ADXL335 (http://www.digikey.com/product-search/en/programmers-development-systems/evaluation-boards-sensors/2622557?k=ADXL335)
 I don't buy raw chips on ebay, too many questionable sources, counterfeits, fakes, repeatability is a problem, plus the long lead time. If I'm going to the effort of soldering down a minuscule sized part, I want to know I have a good part to start with.

Title: Re: Arduino Lightsaber
Post by: stinky1 on Jan 15, 2016, 10:14 pm
QUOTE FROM CANOBI: "Here's one I mounted on a slightly different kind of cake I made for a stunt saber:

(http://i1225.photobucket.com/albums/ee395/Can-obi/IMG_20160112_222917.jpg) (http://s1225.photobucket.com/user/Can-obi/media/IMG_20160112_222917.jpg.html)

Lithium charging was the first thing on my list to tackle when I decided to make my saber fx system, took me the best part of a year to learn what I needed so I could confidently make and try the circuit without quite so much risk of blowing batteries or myself up. Luckily (though frustratingly) they've been duds and didn't do anything, a much preferable outcome for a failure when dealing with lithuim but I think I've finally worked out where I'm going wrong so making another proto.

The circuit is also now smaller than the cell it charges which makes for some intersting ways to include it. I have three ideas I'm toying with. Two of them were inspired by some S1 flex PCB I bought to play with. It's normally used for making ribbon connectors or 12v flexible LED light strips and is only 4mils (0.1016mm) thick so is super bendy."

How about one of these charge controllers?  Double 7.4 v http://www.ebay.com/sch/i.html?_from=R40&_sacat=0&_nkw=PCB++7.4V++18650&_sop=15 (http://www.ebay.com/sch/i.html?_from=R40&_sacat=0&_nkw=PCB++7.4V++18650&_sop=15)
(http://i.ebayimg.com/images/i/151300771040-0-1/s-l1000.jpg)


                                                           Single, double, triple:Y 1, 2 or 3 cells 1-2A Lithium ion Battery Charger Module PCB 18650 iphone 14450 (http://www.ebay.com/itm/Y-1-2-or-3-cells-1-2A-Lithium-ion-Battery-Charger-Module-PCB-18650-iphone-14450-/262208098412?hash=item3d0cd2106c:g:xlAAAOSwymxVK6qy)

(http://www.ebay.com/itm/Y-1-2-or-3-cells-1-2A-Lithium-ion-Battery-Charger-Module-PCB-18650-iphone-14450-/262208098412?hash=item3d0cd2106c:g:xlAAAOSwymxVK6qy)



                                                           Single:PCB for 1S 3.7V Li-ion Battery Pack (1.5A cut-off) (http://www.ebay.com/itm/PCB-for-1S-3-7V-Li-ion-Battery-Pack-1-5A-cut-off-32088-/330726006763)  


Title: Re: Arduino Lightsaber
Post by: billpealer on Jan 15, 2016, 10:16 pm
I believe the 3.3V on a Nano comes from the FTDI chip, and is only capable of 50mA.
that actually may be the case.
But the ADXL335 has a low min operating current of...  350 μA.
50ma would do it. right?

I like the nano. i love the ease of USB connectivity and sending the 8.2v direct to the RAWpin, and 5v RIGHT to the WT via VCC.  i hate soldering.  we are a good match :)
Title: Re: Arduino Lightsaber
Post by: JakeSoft on Jan 15, 2016, 11:01 pm
that actually may be the case.
But the ADXL335 has a low min operating current of...  350 μA.
50ma would do it. right?

I like the nano. i love the ease of USB connectivity and sending the 8.2v direct to the RAWpin, and 5v RIGHT to the WT via VCC.  i hate soldering.  we are a good match :)
I'm sure you'll be very happy together.  :D 
Title: Re: Arduino Lightsaber
Post by: billpealer on Jan 16, 2016, 01:23 am
Ha!
(http://cdn.meme.am/instances/500x/43641494.jpg)

i tried to make that smaller.
Title: Re: Arduino Lightsaber
Post by: jonnieZG on Jan 16, 2016, 09:00 pm
Just wanted to give something back to this great community:

Well, here's my LED driver, in fact 3 of them, one for each RGB channel. Each one will get its own thermal-shrinking insulation sleeve.

(http://oi64.tinypic.com/2mflxqb.jpg)
Red and black wires above are LED outputs, red and black wires below are power in, naked wire is the PWM switch input

This is a current source based on one N-MOSFET (T1) and one NPN transistor (T2):

(http://i63.tinypic.com/2j5famr.png)

The principle is very simple: the current that comes out from the Source pin of the T2 (S) must be the same as the one as enters the Drain pin (D), since current that enters the Gate (G) is zero. Therefore, by controlling the Source current we control the current through the LED, no matter the voltage on the LED. Setting the source current is fairly easy, since the BE voltage on a transistor is always around 0.5 V and the current that enters the T1 Base pin is also around zero. Therefore, the current through the R2 is Is=Ube/R2, that is R2=Ube/Is

So, if we want the current to be 700 mA, then the R2 has to be 0.5V/0.7A~0.7 Ohm! No matter the battery voltage, as long as it is above some 3.5 V, depending on the voltage on the LED. In practice, the current slightly depends on the input voltage, but does not depend at all on the diode voltage (or any consumer connected between Vcc and the Drain, for that matter), which is exactly what we need, since the diode voltage dramatically changes with the temperature. This way we completely override the problem with the changing voltage on the diode.

This is the Vcc-Current chart of the driver, driving one blue LED:
(http://i65.tinypic.com/htip06.png)

I used two 0,6 W resistors - 1 Ohm and 1.5 Ohm, resulting in 0.6 Ohm. Even though I used the same components in all the 3 drivers, the current varies from one to another from 0.70A to 0.73A - so you can see how it is hard to tweak. Fortunately enough, that does not affect the light intensity that much and it is still in the safe zone.

Now about switching the LED on and off: when the Gate pin is pulled up to Vcc, the Gate opens and the current flows. When the Gate is pulled down to 0V, the Gate closes and the current through the LED stops. That is done through a 100 kOhm resistor to minimize the pull-up current. By connecting it to a PWM signal from your controller, you can regulate the resulting current and the intensity of the light.

But, there is a caveat here - resistors that small are a pretty tricky thing to work with, because the very contact resistance between two wires ranges from 0.2 Ohm when not welded together (depending on the pressure used to hold them together and the properties of the wire) to around 0.05 Ohm when welded. And that's on each contact! So forget about testing it on a prototype board - you will just have to weld them directly on the other components as I did on the photo above, and tweak the resistors to get the right current.

Don't forget to insulate the pins with thermal-shrinking insulation sleeves to prevent wires from breaking off and short circuiting!

Components:

Power dissipation considerations: Bare in mind that all the voltage difference between the input voltage and the voltage on the diode, minus 0.5 V on the R2, remains on the T1 FET, producing possibly significant heat (P = U * I). For example, if you power it with a 7V input and the voltage drop on the LED is 3.2V, then the remaining voltage on the T2 is 3.3V, producing 3.3*0.7 = 2,3 W which is quite much. If you keep it at 4.5V, then the power dissipation on T2 would be only about 0.5W. Therefore, keep the driver input voltage as low as possible!

Important note on pinout: The black output line is the floating one, while the red output is the same point as the power input! Therefore, when using several drivers in parallel, you must connect all the anodes of the LEDs to Vcc, and cathodes to the driver's black output line!

Important note on handling FETs: FETs (MOSFETs) are very sensitive components and are very easy to damage if you are not properly grounded. It is also likely that you'll burn it (electrically, not thermally) with your soldering iron. You'll now you did it if you notice that you cannot properly fade your LED: with a healthy MOSFET the light goes linearly up from 0 to 100%, while on a burnt one the LED will start lighting up at about 75% of PWM input level. Therefore, it is necessary to wrap all 3 pins with a piece of naked wire short-circuiting all pins, while you are soldering it. Once all the components are in place, you can wrap-off the short-circuiting wire.
Title: Re: Arduino Lightsaber
Post by: billpealer on Jan 17, 2016, 12:17 am
Johnnie, could you show a current (amps) read on a multi meter showing the 700ma for that set up?
Title: Re: Arduino Lightsaber
Post by: jonnieZG on Jan 17, 2016, 01:12 am
"I find your lack of faith disturbing..." ;)

(http://i63.tinypic.com/ekkhao.jpg)
Title: Re: Arduino Lightsaber
Post by: billpealer on Jan 17, 2016, 02:15 am
is that a 4x AA ? alkaline?
Title: Re: Arduino Lightsaber
Post by: JakeSoft on Jan 17, 2016, 05:36 am
This is something I hacked together in PhotoShop using Canobi's drawings as a reference. It's only meant to express concepts, but maybe someone more savvy could turn this into a real board by drawing it in PCB design tools that I don't know how to use.

This is intended to be the easy button; the most accessible, simple to build PCB that I can think of for an end user to assemble and still get full functionality. Anything that makes it complicated got tossed out in favor of simplicity. It's not the highest performing or the most flexible. It won't please everyone or accommodate every combination of parts. It's not the loudest. It's not supposed to be any of those things. It is what it is and nothing more. Simple.

(http://i67.tinypic.com/1z1hf80.jpg)

Click here for high-res image (http://tinypic.com/view.php?pic=1z1hf80&s=9#.VpsKWlLFqj8)

Key Features:
- 100% through-hole components.
- Minimalist design: Everything you need, nothing you don't
- Should be pretty easy to produce; only one jumper that could be end user installed
- Uses Canobi's pinout
- LDO regulator mounted under the WT588D to save space
- WT588D assumed to be mounted on pin-headers or a socket interface to facilitate removal for reprogramming without any non-standard hardware
- Arduino right-angle pin headers assumed to be available for reprogramming at the edge of the board over the FETs
- Pure 3.3V design eliminates dual-voltage power distribution complexities
- Narrow parts list removes parts selection ambiguity
- Only easy-to-find, commonly available parts are required
- Compatible with both ADXL335 accelerometer or SW-200D swing sensors

Parts:
- Arduino Pro Mini 3.3V
- 3.3V LDO Voltage Regulator (up to TO-220 size, >= 500 mA output)
- WT588D 16p
- GY-61 ADXL335 Accelerometer (Or SW-200D Swing Sensors)
- I-PAK style N-channel MOSFETs (1 to 3, depending on how many channels you want)
- SW-18020P impact sensor (mounted off the board)

I know I am probably off on the dimensions a few places. Like the holes for the main LED negative vias at the end of the board probably need to be moved left a bit to clear the FETs, but I think something like this would be good. It doesn't require any advanced soldering skills and could be built with a cheap iron without an especially fine tip. A decent high school student could probably build the board in an afternoon. A skilled person could do it in an hour or less.

With some modifications to the power distribution, a separate version could be made 5V capable to support Nanos and 5V Pro-Minis.

Feedback welcome. (Please read the second paragraph of this post before posting feedback, please.)
Title: Re: Arduino Lightsaber
Post by: jonnieZG on Jan 17, 2016, 03:16 pm
is that a 4x AA ? alkaline?
No, that's 4xAA NiMH, resulting in 5,1 V. I added a current-vs-voltage chart in my original post (#455), which you might find useful.

I have not yet decided how I will power the driver, since I want the voltage to be around 5V. I will probably use a 3.3V Arduino with one down-switching buck stabilizer for the Arduino and another one down to 5V for the LED drivers.

The idea is to use switching-stabilizers rather than the semi-conductor based ones, since power dissipation is significantly lower.
Title: Re: Arduino Lightsaber
Post by: Kamensky on Jan 17, 2016, 06:16 pm
Dear Jedi (or almost Jedi), i rly need some help with writing code. I'm using MPU-6050 accelerometer+gyro, so i'm incredibly dumb at this thing. I would appreciate any help with at least building an algorithm for triggering sound. And it would be sooo amazing, if someone here already has worked with MPU-6050 or just can share the code for it. Prayin' for your help :)
Title: Re: Arduino Lightsaber
Post by: stinky1 on Jan 18, 2016, 04:02 am
I have this saved as PROTONERD LED STRING CODE (ARDUINO NANO, MP3-TF-16P, MPU6050 GYRO)
I believe that this is just the MPU6050 gyro code, but don't quote me as I have like 0 so far work done with arduino,  parts on the way........ link is in post #53 and is ryang's not Protonerds.

Arduino Lightsaber for/with LED string blade (https://forum.arduino.cc/index.php?topic=361566.0)





#include <SoftwareSerial.h>
#include <DFPlayer_Mini_Mp3.h>
#include <Wire.h>
#include <I2Cdev.h>
#include <MPU6050.h>

MPU6050 accelgyro;
int16_t ax, ay, az;    // define accel as ax,ay,az
int16_t gx, gy, gz;    // define gyro as gx,gy,gz
int16_t px, py, pz;    // previous accel settings
long x, y, z;
long accel;         // calc accel

int inPin = 9;         // the number of the input pin
int outPin = 10;       // the number of the output pin
int ledPin = 11;

int reading;           // the current reading from the input pin
int previous = LOW;    // the previous reading from the input pin

int brightness = 0;    // how bright the LED is
int fadeAmount = 5;    // how many points to fade the LED by

int track = 20;
int prev = 20;

boolean state = false; // the current state of the circuit

// the follow variables are long's because the time, measured in miliseconds,
// will quickly become a bigger number than can be stored in an int.
long time = 0;         // the last time the output pin was toggled
long debounce = 500;   // the debounce time, increase if the output flickers
long looptime = 0;     // the last time the loop was played
long gtime = 0;

SoftwareSerial mySerial(0, 1); // RX, TX

void setup()
{
  Wire.begin();              // join I2C bus
  //Serial.begin(38400);       // initialize serial communication
  //while (!Serial);           // wait for Leonardo enumeration, others continue immediately
  Serial.println("INIT");
  accelgyro.initialize();

  Serial.println(accelgyro.testConnection() ? "MPU6050 connection successful" : "MPU6050 connection failed");
 
  mySerial.begin(9600);
  mp3_set_serial(mySerial);  //set Serial for DFPlayer-mini mp3 module

  pinMode(inPin, INPUT);
  pinMode(outPin, OUTPUT);
  pinMode(ledPin, OUTPUT);
}

void loop()
{
  reading = digitalRead(inPin);
  accelgyro.getMotion6(&ax, &ay, &az, &gx, &gy, &gz);   // read measurements from device

  if(millis() - gtime > 500) {
    x=px-ax; y=py-ay; z=pz-az;
    x=abs(x); y=abs(y); z=abs(z);
    accel = (x+y+z);
    px = ax; py = ay; pz = az;

    if(state && accel > 15000) {
      mp3_play(random(31,34));
        //analogWrite(outPin, 255); delay(100);
        //analogWrite(outPin, 50); delay(100);
        //analogWrite(outPin, 255); delay(100);
        //analogWrite(outPin, 200); delay(100);
      looptime = millis()-2000;
    }

    Serial.print(gx);Serial.print(" ");Serial.print(gy);Serial.print(" ");Serial.println(gz);
    Serial.println(accel);

    gtime = millis();
  }
 
  if (reading == HIGH && previous == LOW && millis() - time > debounce) {
    if (!state) {
      digitalWrite(ledPin, HIGH);
      looptime = millis();
      mp3_play(1);
      for(brightness = 0; brightness < 200; brightness++) {
        analogWrite(outPin, brightness);
        delay(16);
      }
      state = true;
    } else {
      mp3_play(2);
      for(brightness = 200; brightness > -1; brightness--) {
        analogWrite(outPin, brightness);
        delay(7); 
      }
      digitalWrite(ledPin, LOW);
      state = false;
    }
    time = millis();   
  }

//  if (state && millis() - looptime > 4000) {
//    while (track == prev) {
//      track = random(21,24);     
//    }
//    mp3_play(track);
//    prev = track;
//    looptime = millis();
//  }
 
  previous = reading;
}
Title: Re: Arduino Lightsaber
Post by: JakeSoft on Jan 18, 2016, 04:49 am
I have this saved as PROTONERD LED STRING CODE (ARDUINO NANO, MP3-TF-16P, MPU6050 GYRO)
I believe that this is just the MPU6050 gyro code, but don't quote me as I have like 0 so far work done with arduino,  parts on the way........ link is in post #53 and is ryang's not Protonerds.

Arduino Lightsaber for/with LED string blade (https://forum.arduino.cc/index.php?topic=361566.0)

This is clearly more than the gyro code. This looks like an entire sketch which won't work without the MPU6050.h header file. Provided you had that, then maybe some examples could be gleaned from this code.
Title: Re: Arduino Lightsaber
Post by: ryang on Jan 18, 2016, 06:50 am
This is clearly more than the gyro code. This looks like an entire sketch which won't work without the MPU6050.h header file. Provided you had that, then maybe some examples could be gleaned from this code.
Yeh, it's the complete code - including unused parts... :P

MPU6050.h can be found here;
https://github.com/jrowberg/i2cdevlib/blob/master/Arduino/MPU6050/MPU6050.h

And more details here;
http://playground.arduino.cc/Main/MPU-6050

Also needs the DFPlayer code from here;
http://www.dfrobot.com/wiki/index.php/DFPlayer_Mini_SKU:DFR0299
Title: Re: Arduino Lightsaber
Post by: iamearlgrey on Jan 18, 2016, 08:22 am
(http://i67.tinypic.com/1z1hf80.jpg)

Click here for high-res image (http://tinypic.com/view.php?pic=1z1hf80&s=9#.VpsKWlLFqj8)


This is fantastic. I understand the connections much more now. I've been trying to rebuild the schematic to make a gerber file for production, but I am still learning the tools. Are the resistors off the board and connected between the led and the board? I'm also trying to figure out all of this code on my own with only a virtual arduino. Anyway, great job.
Title: Re: Arduino Lightsaber
Post by: Protonerd on Jan 18, 2016, 10:58 am
that actually may be the case.
But the ADXL335 has a low min operating current of...  350 μA.
50ma would do it. right?

I like the nano. i love the ease of USB connectivity and sending the 8.2v direct to the RAWpin, and 5v RIGHT to the WT via VCC.  i hate soldering.  we are a good match :)
I supply the MPU6050 using the 3V3 output from the FTDI and no issue, although the MPU should be more power hungry. So it's a match.
Title: Re: Arduino Lightsaber
Post by: Canobi on Jan 18, 2016, 01:42 pm
It keeps getting better and better! I like the placement of the switch vias a lot better now.

Still a few issues.

1) The ADXL335 doesn't appear to have a positive power source linked in directly from any rail. The silkscreen seems to suggest that you intend to bridge it to raw battery power with a jumper maybe? If so, that will blow it up; the GY-61 ADXL335 is a 3.3V device. It needs to be attached to the 3.3V rail somehow and only fed regulated voltage.
Sorry, my bad. I accidently used an older grab section to compile the new high res pic and the ADXL pin wasn't connected in that section.

Your almost correct about the link wire but actually the ADXL is attached to the regulated 3v3 rail as it should be, not the input terminal. It does look like it at a glance though.

In this grab I've traced over the ADXL's rail to show the tracks route from the 3v3 regulator:

(http://i1225.photobucket.com/albums/ee395/Can-obi/IMG_20160116_004320.jpg) (http://s1225.photobucket.com/user/Can-obi/media/IMG_20160116_004320.jpg.html)



2) This will work perfectly for a 3.3V Arduino variant, but will be incompatable with 5V Pro Mini or Nano. That's fine if that's what you intended, but 5V to the RAW pin will not power any standard arduino board. 5V will be under the dropout voltage of the arduino's on-board 5V regulator and it won't work.
Ah, I thought the 5v referred to the RAW pin's input voltage.

I made some more changes, lets see if I've nailed it this time....

The WT still retains a boosted 5v rail and regulated 3v3 power rail option as before and while the mini shares the latter 3v3 rail, a third rail has been added which is connected directly from the power input port to RAW for use with 7.4v supplies. It does have solder bridge pads like the others but they're bigger to make them easier to bridge using standard iron tips.

(http://i1225.photobucket.com/albums/ee395/Can-obi/IMG_20160116_235801_1.jpg) (http://s1225.photobucket.com/user/Can-obi/media/IMG_20160116_235801_1.jpg.html)



3) [nit]The silk screen on pin 13 should be "SDA" as it is the one-line serial data, not a serial clock. Same with the "CLK" on the WT588D.
No probs, that will only take a sec.



Just as a general comment, I've noticed that the power rail design meant to widen compatibility is adding some complexity that might be avoided if you simply made two distinct versions of the board.
This board is just one of four versions that support 1~4 LEDs, times that by the possible voltage combinations and the numbers of board variations suddenly get a bit unwieldy.

In reality, there's only two or three extra solder points involved which are seconds worth of work to do. The slight increase in complexity is in the layout which is neither here nor there as far as soldering goes.
Title: Re: Arduino Lightsaber
Post by: Protonerd on Jan 18, 2016, 03:57 pm
It looks perfect.

On the silk screen I see "5V micro boost/buck", what IC do you use for the DC/DC? Did you find one which does not need extensive external components (coil, diode, cap etc.?).
Title: Re: Arduino Lightsaber
Post by: JakeSoft on Jan 18, 2016, 04:42 pm
Sorry, my bad. I accidently used an older grab section to compile the new high res pic and the ADXL pin wasn't connected in that section.

Your almost correct about the link wire but actually the ADXL is attached to the regulated 3v3 rail as it should be, not the input terminal. It does look like it at a glance though.

In this grab I've traced over the ADXL's rail to show the tracks route from the 3v3 regulator:

(http://i1225.photobucket.com/albums/ee395/Can-obi/IMG_20160116_004320.jpg) (http://s1225.photobucket.com/user/Can-obi/media/IMG_20160116_004320.jpg.html)



Ah, I thought the 5v referred to the RAW pin's input voltage.

I made some more changes, lets see if I've nailed it this time....

The WT still retains a boosted 5v rail and regulated 3v3 power rail option as before and while the mini shares the latter 3v3 rail, a third rail has been added which is connected directly from the power input port to RAW for use with 7.4v supplies. It does have solder bridge pads like the others but they're bigger to make them easier to bridge using standard iron tips.

(http://i1225.photobucket.com/albums/ee395/Can-obi/IMG_20160116_235801_1.jpg) (http://s1225.photobucket.com/user/Can-obi/media/IMG_20160116_235801_1.jpg.html)



No probs, that will only take a sec.


 

This board is just one of four versions that support 1~4 LEDs, times that by the possible voltage combinations and the numbers of board variations suddenly get a bit unwieldy.

In reality, there's only two or three extra solder points involved which are seconds worth of work to do. The slight increase in complexity is in the layout which is neither here nor there as far as soldering goes.
This is looking pretty good at first glance. I'll give it a more detailed look when I've got more time. Nice job, Canobi!

It looks like the spacing and maps for the buck converter could just as easily be an TO-220 style LDO. Is this the case?

Also, I totally agree that too many versions will become hard to maintain. To help minimize that, why not just make the 4-channel version and leave the other 3 FET slots empty if they are not needed? That way you only have one version to maintain.
Title: Re: Arduino Lightsaber
Post by: MegaCorsair on Jan 18, 2016, 09:09 pm
Hi Jake, I'm still trying to Communicate one of the Wt588d to the arduino but i'm still failing... But I have one Question! I Found this:

https://github.com/ACDCLabs/WT588D (https://github.com/ACDCLabs/WT588D)

It's a Simple library for the WT588D soundchip breakout board. And there's a Thing called "Playsabersounds"

https://github.com/ACDCLabs/WT588D/blob/master/PlaySaberSounds/PlaySaberSounds.ino (https://github.com/ACDCLabs/WT588D/blob/master/PlaySaberSounds/PlaySaberSounds.ino)

How is this works? I Read the code but its confuses me this part:

Quote
void loopOnAllSounds(void)
By the way, I get a Dfplayer Mini and I have read a little ago a code for that and the MPU6050 for stinky1... That Code is Work perfectly? Because if it works , I'll try to get one MPU6050

Code: [Select]
#include <SoftwareSerial.h>
#include <DFPlayer_Mini_Mp3.h>
#include <Wire.h>
#include <I2Cdev.h>
#include <MPU6050.h>

MPU6050 accelgyro;
int16_t ax, ay, az;    // define accel as ax,ay,az
int16_t gx, gy, gz;    // define gyro as gx,gy,gz
int16_t px, py, pz;    // previous accel settings
long x, y, z;
long accel;         // calc accel

int inPin = 9;         // the number of the input pin
int outPin = 10;       // the number of the output pin
int ledPin = 11;

int reading;           // the current reading from the input pin
int previous = LOW;    // the previous reading from the input pin

int brightness = 0;    // how bright the LED is
int fadeAmount = 5;    // how many points to fade the LED by

int track = 20;
int prev = 20;

boolean state = false; // the current state of the circuit

// the follow variables are long's because the time, measured in miliseconds,
// will quickly become a bigger number than can be stored in an int.
long time = 0;         // the last time the output pin was toggled
long debounce = 500;   // the debounce time, increase if the output flickers
long looptime = 0;     // the last time the loop was played
long gtime = 0;

SoftwareSerial mySerial(0, 1); // RX, TX

void setup()
{
  Wire.begin();              // join I2C bus
  //Serial.begin(38400);       // initialize serial communication
  //while (!Serial);           // wait for Leonardo enumeration, others continue immediately
  Serial.println("INIT");
  accelgyro.initialize();

  Serial.println(accelgyro.testConnection() ? "MPU6050 connection successful" : "MPU6050 connection failed");
 
  mySerial.begin(9600);
  mp3_set_serial(mySerial);  //set Serial for DFPlayer-mini mp3 module

  pinMode(inPin, INPUT);
  pinMode(outPin, OUTPUT);
  pinMode(ledPin, OUTPUT);
}

void loop()
{
  reading = digitalRead(inPin);
  accelgyro.getMotion6(&ax, &ay, &az, &gx, &gy, &gz);   // read measurements from device

  if(millis() - gtime > 500) {
    x=px-ax; y=py-ay; z=pz-az;
    x=abs(x); y=abs(y); z=abs(z);
    accel = (x+y+z);
    px = ax; py = ay; pz = az;

    if(state && accel > 15000) {
      mp3_play(random(31,34));
        //analogWrite(outPin, 255); delay(100);
        //analogWrite(outPin, 50); delay(100);
        //analogWrite(outPin, 255); delay(100);
        //analogWrite(outPin, 200); delay(100);
      looptime = millis()-2000;
    }

    Serial.print(gx);Serial.print(" ");Serial.print(gy);Serial.print(" ");Serial.println(gz);
    Serial.println(accel);

    gtime = millis();
  }
 
  if (reading == HIGH && previous == LOW && millis() - time > debounce) {
    if (!state) {
      digitalWrite(ledPin, HIGH);
      looptime = millis();
      mp3_play(1);
      for(brightness = 0; brightness < 200; brightness++) {
        analogWrite(outPin, brightness);
        delay(16);
      }
      state = true;
    } else {
      mp3_play(2);
      for(brightness = 200; brightness > -1; brightness--) {
        analogWrite(outPin, brightness);
        delay(7);
      }
      digitalWrite(ledPin, LOW);
      state = false;
    }
    time = millis();   
  }

//  if (state && millis() - looptime > 4000) {
//    while (track == prev) {
//      track = random(21,24);     
//    }
//    mp3_play(track);
//    prev = track;
//    looptime = millis();
//  }
 
  previous = reading;
}
Title: Re: Arduino Lightsaber
Post by: Protonerd on Jan 18, 2016, 11:01 pm
If interested how to program the MPU6050, I copied parts of my code dealing with that module in this thread: https://forum.arduino.cc/index.php?topic=361566.0

From the above post it looks like my code leaks anyway. It's nothing magic, probably very similar to JakeSoft's code with the ADXL335, using different thresholds to detect saber movement types like swing, clash etc.

Remaining challenge is to code a Clash sensor, using thresholds works well, but you have to extremely bring down the loop time to avoid a lag between clash event and start of corresponding FX. There is also a motion interrupt feature, but it's not straightforward, I work on it and give an update when ready.
Title: Re: Arduino Lightsaber
Post by: Canobi on Jan 19, 2016, 01:04 am
It looks perfect.

On the silk screen I see "5V micro boost/buck", what IC do you use for the DC/DC? Did you find one which does not need extensive external components (coil, diode, cap etc.?).
If only..

I use micro buck modules. This one is 5v .5A and is approx 10.8mm x 10.8mm square:

(http://i1225.photobucket.com/albums/ee395/Can-obi/IMG_20160118_233831.jpg) (http://s1225.photobucket.com/user/Can-obi/media/IMG_20160118_233831.jpg.html)

Once the mono amps have arrived I'll move on to the 1A version as the amp will use about 600mA on its own:

(http://i1225.photobucket.com/albums/ee395/Can-obi/IMG_20151023_173410.jpg) (http://s1225.photobucket.com/user/Can-obi/media/IMG_20151023_173410.jpg.html)
Title: Re: Arduino Lightsaber
Post by: MegaCorsair on Jan 19, 2016, 02:19 am
Too Many Codes and things  :smiley-roll-blue:
I think I gonna just wait for your tutorial with all step :'(
Title: Re: Arduino Lightsaber
Post by: Canobi on Jan 19, 2016, 02:27 am
This is looking pretty good at first glance. I'll give it a more detailed look when I've got more time. Nice job, Canobi!
Thanks Jake :)



It looks like the spacing and maps for the buck converter could just as easily be an TO-220 style LDO. Is this the case?
Not quite, the map would need to be changed for it to fit. TO-220 pins are 2.75mm pitch and the buck pin spacing is 1.27mm pitch.

What did you have in mind?



Also, I totally agree that too many versions will become hard to maintain. To help minimize that, why not just make the 4-channel version and leave the other 3 FET slots empty if they are not needed? That way you only have one version to maintain.
I agree, it would be the easiest way to do things.
Title: Re: Arduino Lightsaber
Post by: billpealer on Jan 19, 2016, 02:53 am
This is clearly more than the gyro code. This looks like an entire sketch which won't work without the MPU6050.h header file. Provided you had that, then maybe some examples could be gleaned from this code.
"it's an older code, but it check out."
Title: Re: Arduino Lightsaber
Post by: billpealer on Jan 19, 2016, 03:04 am
Important note on handling FETs: FETs (MOSFETs) are very sensitive components and are very easy to damage if you are not properly grounded. It is also likely that you'll burn it (electrically, not thermally) with your soldering iron. You'll now you did it if you notice that you cannot properly fade your LED: with a healthy MOSFET the light goes linearly up from 0 to 100%, while on a burnt one the LED will start lighting up at about 75% of PWM input level. Therefore, it is necessary to wrap all 3 pins with a piece of naked wire short-circuiting all pins, while you are soldering it. Once all the components are in place, you can wrap-off the short-circuiting wire.
yo is this true?

soldering irons have voltage? not just heat?   
Title: Re: Arduino Lightsaber
Post by: Canobi on Jan 19, 2016, 03:13 am
Last one before I hit the sack:

(http://i1225.photobucket.com/albums/ee395/Can-obi/IMG_20160119_015731.jpg) (http://s1225.photobucket.com/user/Can-obi/media/IMG_20160119_015731.jpg.html)

Note: Obsolete
Title: Re: Arduino Lightsaber
Post by: JakeSoft on Jan 19, 2016, 03:25 am
Thanks Jake :)



Not quite, the map would need to be changed for it to fit. TO-220 pins are 2.75mm pitch and the buck pin spacing is 1.27mm pitch.

What did you have in mind?
I'm just thinking about where to source those buck converters. I don't know where to find them and I'm probably not alone. However, TO-220 LDO regulators are sold by just about every electronics site known to man and are therefore easy to find and cheap. The buck converter has a lot of advantages, such as better efficiency, so I'm not saying to ditch it entirely, but it's not as approachable for a novice shopping for parts. Do you plan to pre-install them or offer them as part of a kit? I'm only suggesting that the option to add an LDO might make it more user friendly. Space looks kind of tight in that area of the board... not really much room to add three new vias. Hmm... well, just a thought. Maybe for another revision or version.

A few questions:

Q1: Also, are you planning to re-solder the pins on the second buck unit you posted such that it will lie flat instead of sticking up lengthwise on the pins? It looks like standing up like that might cause clearance issues.

Q2: How much current can you get out of a buck that size? I mean, how high do they go? I've been working with LDOs that can source 4 or 5 amps as long as your battery is strong enough. How does it compare? As I said earlier, I'm not that familiar with them. Please educate me.
Title: Re: Arduino Lightsaber
Post by: JakeSoft on Jan 19, 2016, 03:28 am
Last one before I hit the sack:

(http://i1225.photobucket.com/albums/ee395/Can-obi/IMG_20160119_015731.jpg) (http://s1225.photobucket.com/user/Can-obi/media/IMG_20160119_015731.jpg.html)

High res:

https://www.dropbox.com/s/7fhcxav892ohgw3/IMG_20160119_015658.jpg?dl=0 (https://www.dropbox.com/s/7fhcxav892ohgw3/IMG_20160119_015658.jpg?dl=0)
I like it!

How are you planning to test it?
Title: Re: Arduino Lightsaber
Post by: Kwissus on Jan 19, 2016, 10:57 am
Thanks everyone for putting together this threadzilla of evolving information!

No really, I mean it.

Registered to share what I've spent too many hours last night on compiling while going through this thread:

Googe Sheet Link (https://docs.google.com/spreadsheets/d/1eE83aOqzd3jCWHFmOq58BUduTJxIuGBRkd-dL8d7hM4/edit?usp=sharing)

Completely untested, sourced as cheap as possible for building 10 lightsabers.
It is missing some compontents that every budding sabersmith should have lying around anyway (resistors, npn transistors if you want the constant current solution that was posted on the last page).

Cost is $10.43 for each lightsaber, but you would need to pony up for a programmer for the arduino pro mini, and possibly for the WT588D.
Title: Re: Arduino Lightsaber
Post by: Canobi on Jan 19, 2016, 02:13 pm
I'm just thinking about where to source those buck converters. I don't know where to find them and I'm probably not alone. However, TO-220 LDO regulators are sold by just about every electronics site known to man and are therefore easy to find and cheap. The buck converter has a lot of advantages, such as better efficiency, so I'm not saying to ditch it entirely, but it's not as approachable for a novice shopping for parts. Do you plan to pre-install them or offer them as part of a kit? I'm only suggesting that the option to add an LDO might make it more user friendly. Space looks kind of tight in that area of the board... not really much room to add three new vias. Hmm... well, just a thought. Maybe for another revision or version.
As the design uses them to drive the WT at 5v (and eventually the mono amp) with a single 3.7v cell, I was planning on supplying them with the board.

Hmm, if planning on using a 7.4v system though, then a 5v LDO would be a good alternative for supplying 5v to the wt.


A few questions:

Q1: Also, are you planning to re-solder the pins on the second buck unit you posted such that it will lie flat instead of sticking up lengthwise on the pins? It looks like standing up like that might cause clearance issues.

Q2: How much current can you get out of a buck that size? I mean, how high do they go? I've been working with LDOs that can source 4 or 5 amps as long as your battery is strong enough. How does it compare? As I said earlier, I'm not that familiar with them. Please educate me.
A1: I looked at that the other day as I had the same concerns. Turns out it's not actually necessary as it fits a 25mm ID hole mounted on its side but if I get enough of them, the manufacturer said they will ship them to me without the headers.

A2: The most I've seen is about 2A but they don't work the same as LDOs.

LDOs take a min/max voltage and output a fixed or adjustable regulated voltage lower than that received (due to the voltage drop).

A boost modules will take a min/max voltage in the same manner but the output voltage is usually always the same or higher than the input voltage. The current is also regulated but it's not clamped like an LDO, in this case the current any given boost converter can output is dictated by the input voltage.

Heres what the bumph says about the 5v .5A modules:

Input voltage 0.9 ~ 5V, output 5V
Maximum output current: 500 MA,
 
Start Voltage 0.9V, Output Current 10MA
 
INPUT 1-1.5V,      OUTPUT 5V 50-110MA;
INPUT 1.5-2V,      OUTPUT 5V 110-160MA;
INPUT 2-3V,         OUTPUT 5V 160-400MA;
INPUT above 3V,  OUTPUT 5V 400-500MA;

Title: Re: Arduino Lightsaber
Post by: jonnieZG on Jan 19, 2016, 02:44 pm
yo is this true?

soldering irons have voltage? not just heat?  
*Anything* has voltage - either static, and/or noise picking up from the power line. When you walk around the room, pick a door-knob and a spark comes out - that's static electricity, thousands of volts. Enough to make your hand twitch and more than enough to burn a FET. Soldering iron, blenders, anything that you plug in a wall socket may and usually does pick a fraction of the 50/60Hz voltage from the power line. That's different than the static electricity, but also kills FETs. Modern FETs have a built-in protection, but nevertheless, I killed one recently because I forgot to short-circuit the pins before soldering...
Title: Re: Arduino Lightsaber
Post by: Canobi on Jan 19, 2016, 02:59 pm
I like it!

How are you planning to test it?
I would like to discuss that with you as the one thing I distinctly lack is code of any kind, though I'm thinking more aling the lines af a test sequence that lets me know everything is connected and working rather than use saber code.
Title: Re: Arduino Lightsaber
Post by: JakeSoft on Jan 19, 2016, 03:35 pm
I would like to discuss that with you as the one thing I distinctly lack is code of any kind, though I'm thinking more aling the lines af a test sequence that lets me know everything is connected and working rather than use saber code.
Ah, you need a "test pattern" program. I might be able to whip something up, I just need to find time to do it.
Title: Re: Arduino Lightsaber
Post by: billpealer on Jan 19, 2016, 08:07 pm
How do you plan to test it?

Canobi--
"I would like to discuss that with you as the one thing I distinctly lack is code of any kind, though I'm thinking more aling the lines af a test sequence that lets me know everything is connected and working rather than use saber code."
you could just send me one.  :) :)

l'll be glad to test it. :) see? you need cake.  cake=sumofparts, what you've been making is the pan. or maybe the oven. :p

between Illuis's One Line Serial Mode, code,..  Jake's code posted for ON/Off Bool AND WT programming videos (thanks again best tute on youtube btw)  and the Debounce Code i posted to trigger SW-200 sensors, with the actual WT code associated with it..  it's all here.

try it out Obiwan dude.  if you can make a circuit board you can copy/paste.

Actually we need some ADXL335 code posted.  jake?  you got a stepping stone?  there is only a 1000 Arduinio posts about the ADXL335 online, and not only that, it looks like any good analogRead Potentiometer code can migrate over with some testing and tweaks as well.  Just wondering if you had a scaled down "breadcrumb" like you tossed me for the Bool on/off code. yah?

i think from what i can tell, the only real trick with the ADXL is resting state.  at any given position, one or a blend of the axis will trigger 1g of data,.  so,..  what is that around 1g= analogRead(500);  ish?

so,..   if you mount the thing z axis flat, and y axis north (what i like to call NORMAL), then you hold your saber 100% vertical..  you'll pull XYZ of roughly, 390,500,390? because the Y axis is receiving 1 pure G of force,. AKA gravity. and Z and X are getting very little.  And from I am reading very little or ZERO, is actually closer to an analogRead of less than or =to 395. i don't have one in hand so i can't be sure.  when i get it, i will post the results, and like i did for the SW-200, post the WT trigger code. or at least my flavor of it. but other have posted the results of raw analogReads of the ADXL335 and i think my numbers are close. 

the trick is CHANGE. the analogRead just needs to change, on any axis by about +/-150, and if over 600, just repeat the swing sound because, that means you are spinning the blade, or figure-8-ing it etc. general grievous style   the ADXL335 is sensitive up to.. 3 Gs right?  i know i can swing harder than 3 g's.

ergo the importance of the clash spring sensor (button)

 i could of course be wrong about the above, my memory is no longer photogenic PinMode(3kids). in 3 weeks when my adxl comes in i will have more.

oh,..  update on lock up with no button.  it sounded wrong.  interrupting lock up with a swing worked..  but a single clash needs to decay or fizzle to hum. that was missing.  i think with some creative code you could still do it. you would need 2 sounds.  lock up, and a fizzle to hum sound.  so a single hit would trigger the clash sensor, then the ADXL would be pulling numbers over 500 on at least one axis, that would trigger a fizzle to hum,..  and if the the g's are substantial after 300ms or so- play more swing sounds.

i can make the gapless sounds if someone want to test this.  waiting for parts sucks.

anyone else have a working saber video to post? i am curious to who else has made some cake?




Title: Re: Arduino Lightsaber
Post by: jshaw on Jan 19, 2016, 10:48 pm
The last of my electronic parts (swing and clash sensors, and speakers) arrived yesterday, but I still don't have my blade holder from The Graflex Shop, so I'm stuck not able to assemble things completely.   

I've toyed a bit with the code, but I also have the 32 pin USB programmable WTD module, so it's pinout is different from the one that everyone else is using, so I'm fighting with that. 

I did figure out the issue w/ my LEDs not being very bright.  It's because I was just driving them from my 3.3V Arduino directly, so they were only getting the minuscule amperage that it provides instead of 700Ma they want.  A simple 5V booster made it much brighter, but I need to use smaller boosters because the off-the-shelf model I grabbed is too large to fit 3 of them in my hilt for my tri-rebel.
Title: Re: Arduino Lightsaber
Post by: billpealer on Jan 20, 2016, 01:52 am
I've toyed a bit with the code, but I also have the 32 pin USB programmable WTD module, so it's pinout is different from the one that everyone else is using, so I'm fighting with that. 
can you send a link to this or the full model number? I use the 28p version. I posted a wiring diagram a while back.
Title: Re: Arduino Lightsaber
Post by: billpealer on Jan 20, 2016, 03:53 am
Jshaw- you have to mean the 28pin 32m USB version.  Which I use.  See my diagram on like. Page 10 or was it 12? It has the chip diagram and how to wire it. I have looked and looked.  I can't find a 32 pin ver .... Anywhere ever.  Not waytronic.
Title: Re: Arduino Lightsaber
Post by: jshaw on Jan 20, 2016, 03:55 am
Jshaw- you have to mean the 28pin 32m USB version.  Which I use.  See my diagram on like. Page 10 or was it 12? It has the chip diagram and how to wire it. I have looked and looked.  I can't find a 32 pin ver .... Anywhere ever.  Not waytronic.
My bad, you are absolutely right! I'll look at your writing when I get a chance. Thanks for catching that, which explains why the manuals I read made no sense.
Title: Re: Arduino Lightsaber
Post by: billpealer on Jan 20, 2016, 04:03 am
Again... Anyone using an LED buck down driver for their LED with MOSFET PWM control?  I am buying another buck. Maybe mine is bad.  PWM with MOSFET + buck driver no workey. I have succeeded in getting PWM off raw power + MOSFET.   My driver... Not so much.    I suppose I fried my 2 MOSFETs with ambient voltage from the universe like warned about.  Doubt it.  Purgedsoul? Protonerd?  Bueller?
Title: Re: Arduino Lightsaber
Post by: JakeSoft on Jan 20, 2016, 04:06 am
I would like to discuss that with you as the one thing I distinctly lack is code of any kind, though I'm thinking more aling the lines af a test sequence that lets me know everything is connected and working rather than use saber code.
Here is some basic test code for you, Canobi. It'll test all the I/O except for the accelerometer inputs. I couldn't think of an easy way to do that except maybe putting out the raw read values via serial.

This code will ramp up all 6 possible LEDs to full power and then ramp them down one at a time. See code for the order they go in, but it's more or less right around the pins on the Arduino in ascending order.

Then, once all the LEDs have been tested, it'll go into "button test mode". You can press the Activation switch, Aux switch, or bang the clash sensor to play three different sounds on the WT. Just program your WT588D in one-line serial mode to have three different sounds at 0x00, 0x01, and 0x02 so you'll know if the right sound is playing when you hit the switches.

All while this is happening, the main LED light will light up or go out to indicate the status of the BUSY signal from the WT588D. If you hear sound, but the light does not change state then probably something wrong with the busy signal on the WT.

Code: [Select]

/*
 * Pins_Canobi.h : Defines pinout for Canobi's 3-channel PCB.
 *
 *  Created on: Jan 8, 2016
 *      Author: JakeSoft
 */

#ifndef PINS_CANOBI_H_
#define PINS_CANOBI_H_

//General I/O Pins
#define CLASH_PIN 2 //Clash sensor interrupt pin
#define LED_RED_PIN 3 //PWM output for RED LED
#define LED_GREEN_PIN 5 //PWM output for GREEN LED
#define LED_BLUE_PIN 6 //PWM output for BLUE LED
#define ACTIVATE_PIN 7 //Activation switch
#define AUX_PIN 8 //Aux switch
#define LED_FOC_PIN 9 //Flash-on-clash LED (not implemented by JakeSoft SW)
#define ACCENT1_PIN 10 //Accent LED
#define ACCENT2_PIN 11 //Secondary Accent LED (not implemented by JakeSoft SW)

//Serial pins for WT588d Sound board
#define WT588D_BUSY 12 //Module pin "LED/BUSY"
#define WT588D_SDA 13 //Module pin for DATA

//Accelerometer Pins
#define AXDL335_X_PIN A0 //X axis
#define AXDL335_Y_PIN A1 //Y axis
#define AXDL335_Z_PIN A2 //Z axis
#define AXDL335_VCC_PIN A3 //Accel power (not used by Canobi's PCB)
#define AXDL335_GND_PIN A4 //Accel ground (not used by Canobi's PCB)

#endif /* PINS_CANOBI_H_ */

 

Code: [Select]

/*
 * SaberTest.ino : Tests saber I/O
 *
 *  Created on: Jan 19, 2016
 *      Author: JakeSoft
 */
 
#include "Pins_Canobi.h"

//Routine to send WT588D one-line serial commands
void WT588D_Send1(byte addr) {
    digitalWrite(WT588D_SDA, LOW);
    delay(5);

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

    digitalWrite(WT588D_SDA, HIGH);
    delay(10);
}

//Ramp up the LED then ramp it down
void TestLED(int PinNumber)
{
  //Ramp up the LED
  for(int LedPower = 0; LedPower < 255; LedPower++)
  {
    analogWrite(PinNumber, LedPower);
    delay(10);
  }
  
  //Ramp down the LED
  for(int LedPower = 255; LedPower > 0; LedPower--)
  {
    analogWrite(PinNumber, LedPower);
    delay(10);
  }
  
  //Ensure the the LED is fully off
  digitalWrite(PinNumber, LOW);
}

void setup()
{
  pinMode(LED_RED_PIN, OUTPUT);
  pinMode(LED_GREEN_PIN, OUTPUT);
  pinMode(LED_BLUE_PIN, OUTPUT);
  pinMode(LED_FOC_PIN, OUTPUT);
  pinMode(ACCENT1_PIN, OUTPUT);
  pinMode(ACCENT2_PIN, OUTPUT);
  
  pinMode(CLASH_PIN, INPUT);
  pinMode(ACTIVATE_PIN, INPUT);
  pinMode(AUX_PIN, INPUT);
  
  pinMode(WT588D_BUSY, INPUT);
  pinMode(WT588D_SDA, OUTPUT);
  
  pinMode(AXDL335_X_PIN, INPUT);
  pinMode(AXDL335_Y_PIN, INPUT);
  pinMode(AXDL335_Z_PIN, INPUT);
  
  //Set pull-up resistors for switches
  digitalWrite(CLASH_PIN, HIGH);
  digitalWrite(AUX_PIN, HIGH);
  digitalWrite(ACTIVATE_PIN, HIGH);
  
  //Run LED tests
  TestLED(LED_RED_PIN);
  TestLED(LED_GREEN_PIN);
  TestLED(LED_BLUE_PIN);
  TestLED(LED_FOC_PIN);
  TestLED(ACCENT1_PIN);
  TestLED(ACCENT2_PIN);

}

void loop()
{
  if(LOW == digitalRead(CLASH_PIN))
  {
    //Play a sound
    WT588D_Send1(0x00);
    
    delay(100);
    //Wait for user to let off the button
    while(LOW == digitalRead(CLASH_PIN)) {}
    
  }
  
  if(LOW == digitalRead(AUX_PIN))
  {
    //Play a sound
    WT588D_Send1(0x01);

    delay(100);    
    //Wait for user to let off the button
    while(LOW == digitalRead(AUX_PIN)) {}
  }
  
  if(LOW == digitalRead(ACTIVATE_PIN))
  {
    //Play a sound
    WT588D_Send1(0x02);
    
     delay(100);
    //Wait for user to let off the button
    while(LOW == digitalRead(ACTIVATE_PIN)) {}
  }
  
  //Use the primary blade LED to indicate the status of the BUSY pin
  if(HIGH == digitalRead(WT588D_BUSY))
  {
    //Dimmly light the primary blade LED
    analogWrite(LED_RED_PIN, 64);
  }
  else
  {
    //Turn the primary blade LED off
    digitalWrite(LED_RED_PIN, LOW);
  }

}
Title: Re: Arduino Lightsaber
Post by: iamearlgrey on Jan 20, 2016, 04:08 am
Not sure if I am adding anything or not. I've missed several pages since I began reading this thread.
I was looking at the pcb layout and messing around with it then i realized i need to cram into 1" i.d. pvc tube and the current design is still to big. This got me to think about alternate parts for the build.

Would the pololu step down regulator work for this. It is fairly inexpensive. Also, I first discovered arduino through building a multi rotor. Today I had the idea that maybe a flight controller could work for a saber board. It has an mpu6050 built right in as well as onboard 3.3v and 5v regulators and usb so no need for ftdi. not bad for $12 still too big for 1" i.d. but not for 1.25".
http://www.readytoflyquads.com/flip-mwc-flight-controller

and an alternative to the wt588d could be the dfrobot mp3 mini.
http://www.dfrobot.com/index.php?route=product/product&product_id=1121#.Vp75rrTtKQE

anyway, I still need to go through all of the posted code and see if I can cobble something. I'm still just using a virtual arduino to learn the basics.
Title: Re: Arduino Lightsaber
Post by: Protonerd on Jan 20, 2016, 11:14 am
Not sure if I am adding anything or not. I've missed several pages since I began reading this thread.
I was looking at the pcb layout and messing around with it then i realized i need to cram into 1" i.d. pvc tube and the current design is still to big. This got me to think about alternate parts for the build.

Would the pololu step down regulator work for this. It is fairly inexpensive. Also, I first discovered arduino through building a multi rotor. Today I had the idea that maybe a flight controller could work for a saber board. It has an mpu6050 built right in as well as onboard 3.3v and 5v regulators and usb so no need for ftdi. not bad for $12 still too big for 1" i.d. but not for 1.25".
http://www.readytoflyquads.com/flip-mwc-flight-controller

and an alternative to the wt588d could be the dfrobot mp3 mini.
http://www.dfrobot.com/index.php?route=product/product&product_id=1121#.Vp75rrTtKQE

anyway, I still need to go through all of the posted code and see if I can cobble something. I'm still just using a virtual arduino to learn the basics.
The dfrobot MP3 player is in fact the DFPlayer mini, the other MP3 player used in Arduino sabers beside the WT588d. BTW, the IC of the DFPlayer also has a 3.3V LDO, too bad it's not on the pinout.
Title: Re: Arduino Lightsaber
Post by: Protonerd on Jan 20, 2016, 01:52 pm
As the design uses them to drive the WT at 5v (and eventually the mono amp) with a single 3.7v cell, I was planning on supplying them with the board.

Hmm, if planning on using a 7.4v system though, then a 5v LDO would be a good alternative for supplying 5v to the wt.


A1: I looked at that the other day as I had the same concerns. Turns out it's not actually necessary as it fits a 25mm ID hole mounted on its side but if I get enough of them, the manufacturer said they will ship them to me without the headers.

A2: The most I've seen is about 2A but they don't work the same as LDOs.

LDOs take a min/max voltage and output a fixed or adjustable regulated voltage lower than that received (due to the voltage drop).

A boost modules will take a min/max voltage in the same manner but the output voltage is usually always the same or higher than the input voltage. The current is also regulated but it's not clamped like an LDO, in this case the current any given boost converter can output is dictated by the input voltage.

Heres what the bumph says about the 5v .5A modules:

Input voltage 0.9 ~ 5V, output 5V
Maximum output current: 500 MA,
 
Start Voltage 0.9V, Output Current 10MA
 
INPUT 1-1.5V,      OUTPUT 5V 50-110MA;
INPUT 1.5-2V,      OUTPUT 5V 110-160MA;
INPUT 2-3V,         OUTPUT 5V 160-400MA;
INPUT above 3V,  OUTPUT 5V 400-500MA;


To the question of whether an LDO or a buck/boost (just my opinion).
- an LDO (low drop-out) is a type of voltage regulator where the input voltage can get close to the regulated output voltage with only a low drop of the regulated output voltage (i.e. even if the battery voltage comes close to 5V, the LDO is still outputting a voltage close to 5V). I prefer to use voltage regulator, but LDO somehow stuck. Huge advantage is that it's simple and for a few hundreds of mA you can even monolithically integrate it into IC's. That is why many IC's (FTDI for instance) have embedded LDO's you can use to supply other IC's. Yes, it may not be as efficient as a swicthed mode power supply (DC/DC, also called buck/boost), but you win more than what you loose due to the size and no switching noise. The lower efficiency comes from the fact that the power coming from the voltage difference between the input and output multiplied by the supplied current is wasted over the pass transistor (i.e. 7.4V input, 5V output, 200mA -> 2.4V*0.2=0.48W wasted).
- a buck/boost is a switched power supply, and relies on quite big external components (coil, diode, cap) to store the energy. Is more efficient, but BIG. It only makes sense if you really need juice, >1A let's say OR if you have a lower input voltage than the one you need. I'm also thinking about a hybrid circuit, where I use one single 3.7V cell type 18650 and "boost" it up to 5V only for the saber electronics, but supply the LED's still from the 3.7V directly. For that a small boost would suffice with max 500mA.
BTW, a boost does not regulate current, it just outputs (nearly) the same power as the input. It has less loss, but say if you want to boost 1V to 5V and get out 1A, you need to input a bit more than 5A (1V*5A*(1/efficiency) to reach 5V*1A). AFAIK the LDO also does not clamp, the current is limited by the pass transistor only.

So the only scenario I would consider a buck/boost over LDO is when the voltage has to be stepped up (for lack of an alternative), but that only for the less power hungry parts (MP3 player, movement sensors, uC). It would be nice to find one which could be integrated onto the board with minimal impact on the dimensions.
Title: Re: Arduino Lightsaber
Post by: Canobi on Jan 20, 2016, 02:12 pm
The micro boost module is to power the WT at 5v using 3v7 as it doesn't seem to require a great deal of current and would have a bit of overhead and the PCB is routed to supply the LEDs directly from the battery.

I'm looking into boost iCs but there are a lot of datasheets to go through to find one suitable.
Title: Re: Arduino Lightsaber
Post by: Canobi on Jan 20, 2016, 02:18 pm
Your most gratious Jake, thank you so much for taking the time to do that for me :D

I'll try and find time to make a few this w/e along with the MMA versions for DJWing79 for the purpose of field testing.

Since the new layout is based on your diagram Jake, it seems only fitting you should have one.

Bill, you have dibs on #2 since you had the initiative and guts to ask outright ;)

First person to post "I'll take one" has #3.


Drop me a PM with board setup preferences and addresses and I'll get them sent as soon as they're done.

Shipping is 5~7 days standard international and on lthe house, if you would prefer another method let me know in the PM and we can work out the details.
Title: Re: Arduino Lightsaber
Post by: sercancitil5150 on Jan 20, 2016, 03:17 pm
hı  ı need code and bread board please help me :( ı using ardunio nano and wtv020m01
Title: Re: Arduino Lightsaber
Post by: jshaw on Jan 20, 2016, 04:08 pm
Your most gratious Jake, thank you so much for taking the time to do that for me :D

I'll try and find time to make a few this w/e along with the MMA versions for DJWing79 for the purpose of field testing.

Since the new layout is based on your diagram Jake, it seems only fitting you should have one.

Bill, you have dibs on #2 since you had the initiative and guts to ask outright ;)

First person to post "I'll take one" has #3.


Drop me a PM with board setup preferences and addresses and I'll get them sent as soon as they're done.

Shipping is 5~7 days standard international and on lthe house, if you would prefer another method let me know in the PM and we can work out the details.
I'll take it :)
Title: Re: Arduino Lightsaber
Post by: billpealer on Jan 20, 2016, 04:20 pm
Your most gratious Jake, thank you so much for taking the time to do that for me :D



Bill, you have dibs on #2 since you had the initiative and guts to ask outright ;)

First person to post "I'll take one" has #3.


Drop me a PM with board setup preferences and addresses and I'll get them sent as soon as they're done.

Whooo Hoo!  i'll do more than test it.  i'll rig it with my flave of saber software. i will also use 2 sw-200 swing sensors in parallel. and positioned in a cross for "2axis" swings. i will need a 16p WT pre loaded with software.  Anyone want to donate one to me? I don't have the WT loader box. :( Can you do that part Canobi?

please load it with On sound, Hum, a few clashes, a few swings, and Off sound.  then make these playlists.

I can also send you the gap-less .wav files for this too.

Off sound
On sound with a few hums
Clash sound 1 with a few hums
Clash sound 2 with a few hums
swing sound 1 with a few hums
Swing sound 2 with a few hums

Then tell me the playlist number associated with each one. 0 thru 5.

i finished your button box last night. i'll post a rendering later when i get out of work.  You said you'd PM me and never did. What i wanted to discuss was, would 4 be a good first print run?  I will send you my address.  i'll need yours. also. i printed one already and the mm tolerances are tight. for the small holes, i can print your specs exactly, but due to the reality of the prints,.. i had to lightly sand them to fit a jig of the intended OD of the small LEDs thru the hole.  OR i can widen the small holes by .2mm and the print seems to nail the ID of the small holes.  actually increasing your hole diameters by .2mm would be a good idea for all of it.  but i can print it to exact spec and you can work a file or sand paper in the holes to widen them by .1- .2mm if you want super tight fits.

My board prefs are the nano and WT 28p usb, which i successfully stack, (less than 2cm tall) with a header-less nano. So your PCB i am really testing for you and this motley crew. :) Jake and Illuis have given me all the blocks I need to forge my own software. My 3d printer is a real help too. I don't plan to use the Pro Mini, or 16p WT. like,.. ever.  So your nice one PCB to rule them all, does not work for me. But i'll gladly load one up to you, and send it back!  Jake, to answer a question wayyy back, about the stack- i use a dot of hot glue at the USB ins of the nano and WT and stack there, and cut a 8mm x 2cm piece of pcb and hot glue that to the other end of the 2 units, and hot glue it up. it makes a flat little "box" of the boards.  the wires are all very short, and on the WT, i gleaned your method of soldering IN toward the center of the pcb. It never occurred to me to do that. then i shoot the wires out the back and center of the WT's pcb. up and over and solder straight down to the SDA pin and VCC pin of the arduino. I don't use the busy pin, so only 2 wires need to go from the WT to the Nano. the hot glue can be softened, the whole thing can be taken apart, and since only 2 solder points from the Nano to the WT, easily reworked.   i will post a video or photos eventually. i am waiting for ADXL to really get going again on a saber.
Title: Re: Arduino Lightsaber
Post by: billpealer on Jan 20, 2016, 04:37 pm
JShaw...
WT28p set up.  with a nano,  and BTW this schematic DOES NOT CONTROL the BuckBoost with PWM LED fading. but it will turn on the buck boost, and turn it off,   meaning- no FOC and no blade up or down. effect.  just on/off LED
i can't get PWM to work with a mosfet if i move it to the LED Vout side of the Buck Step down.
(https://forum.arduino.cc/index.php?action=dlattach;topic=261980.0;attach=143399)

i have since moved my arduino Pin that goes to the mosfet to Pin 11 for PWM, tho i haven't gotten fading to work with a Buck, and the 2 sensors to non PWM pins. it's arbitrary.  you can do what you want.   also some people put a 1kohm resistor from pin 1 to pin 3 of the MOSFET to crash the PWM signal to 0 (Ground)  for Digital (HIGH/LOW) mosfet switching, you do not need it.
Title: Re: Arduino Lightsaber
Post by: JakeSoft on Jan 20, 2016, 11:09 pm
Your most gratious Jake, thank you so much for taking the time to do that for me :D
No problem. It's for a good cause!

I'll try and find time to make a few this w/e along with the MMA versions for DJWing79 for the purpose of field testing.
I assume you'll do some lab testing with the software I posted first before sending out field test units, yes?

Since the new layout is based on your diagram Jake, it seems only fitting you should have one.
Thanks! Which diagrams, though? The artwork I posted before had the FETs on the other end of the board. Do you have another version that you haven't showed us?

Drop me a PM with board setup preferences and addresses and I'll get them sent as soon as they're done.

Shipping is 5~7 days standard international and on lthe house, if you would prefer another method let me know in the PM and we can work out the details.
Awesome!
Title: Re: Arduino Lightsaber
Post by: Canobi on Jan 21, 2016, 12:22 am
I'll take it :)
[/quote

#3 goes to jshaw.
Title: Re: Arduino Lightsaber
Post by: billpealer on Jan 21, 2016, 01:05 am
<tentatively puts hand up> um, would it be hard to make a switch box like this?

(http://i1225.photobucket.com/albums/ee395/Can-obi/IMG_20151223_172650.jpg) (http://s1225.photobucket.com/user/Can-obi/media/IMG_20151223_172650.jpg.html)

Cake.. batter.
(http://forum.arduino.cc/index.php?action=dlattach;topic=261980.0;attach=151384)
(http://forum.arduino.cc/index.php?action=dlattach;topic=261980.0;attach=151386)

all diameters of holes expanded by .1mm.  The printer has a resolution of .2mm,  but i am seeing a real world Margin or error of .3mm in ACTUALL prints.  BUT  the spacing on center of the 3 -3mm LED posts is still exactly 5mm.  So your led mini lenses will still be spaced right,  but the hole itself is a 10th of a mm wider.  right!?  a 10th of a mm.  LOL.  what is that a grain of salt?
Title: Re: Arduino Lightsaber
Post by: Canobi on Jan 21, 2016, 01:26 am
Whooo Hoo!  i'll do more than test it.  i'll rig it with my flave of saber software. i will also use 2 sw-200 swing sensors in parallel. and positioned in a cross for "2axis" swings. i will need a 16p WT pre loaded with software.  Anyone want to donate one to me? I don't have the WT loader box. :( Can you do that part Canobi?
Awesome :) don't be shy with the feedback. Good, bad or so so, it's all useful.



please load it with On sound, Hum, a few clashes, a few swings, and Off sound.  then make these playlists.

I can also send you the gap-less .wav files for this too.

Off sound
On sound with a few hums
Clash sound 1 with a few hums
Clash sound 2 with a few hums
swing sound 1 with a few hums
Swing sound 2 with a few hums

Then tell me the playlist number associated with each one. 0 thru 5.
Yeh, I can help you out with that WT if you want to send the samples over.


i finished your button box last night. i'll post a rendering later when i get out of work.  You said you'd PM me and never did. What i wanted to discuss was, would 4 be a good first print run?  I will send you my address.  i'll need yours. also. i printed one already and the mm tolerances are tight. for the small holes, i can print your specs exactly, but due to the reality of the prints,.. i had to lightly sand them to fit a jig of the intended OD of the small LEDs thru the hole.  OR i can widen the small holes by .2mm and the print seems to nail the ID of the small holes.  actually increasing your hole diameters by .2mm would be a good idea for all of it.  but i can print it to exact spec and you can work a file or sand paper in the holes to widen them by .1- .2mm if you want super tight fits.
With all the layout reworking and stuff going on at home I clean forgot, my humblest apologies.

If it's possible to widen the little row of three holes to 5.2mm, that would more than suffice. The two small outer holes are for screwing it to the hilt and aren't size critical, the larger ones also as I can thread tap or sand them as you mentioned if they're a bit small.

A run of 4 would more than suffice though, thank you so much :)

Saying that, are your skills for hire?


My board prefs are the nano and WT 28p usb, which i successfully stack, (less than 2cm tall) with a header-less nano. So your PCB i am really testing for you and this motley crew. :) Jake and Illuis have given me all the blocks I need to forge my own software. My 3d printer is a real help too. I don't plan to use the Pro Mini, or 16p WT. like,.. ever.  So your nice one PCB to rule them all, does not work for me. But i'll gladly load one up to you, and send it back!  Jake, to answer a question wayyy back, about the stack- i use a dot of hot glue at the USB ins of the nano and WT and stack there, and cut a 8mm x 2cm piece of pcb and hot glue that to the other end of the 2 units, and hot glue it up. it makes a flat little "box" of the boards.  the wires are all very short, and on the WT, i gleaned your method of soldering IN toward the center of the pcb. It never occurred to me to do that. then i shoot the wires out the back and center of the WT's pcb. up and over and solder straight down to the SDA pin and VCC pin of the arduino. I don't use the busy pin, so only 2 wires need to go from the WT to the Nano. the hot glue can be softened, the whole thing can be taken apart, and since only 2 solder points from the Nano to the WT, easily reworked.   i will post a video or photos eventually. i am waiting for ADXL to really get going again on a saber.
For size, my PCB isn't in the same league as your stack  by a long shot lol. I have been eyeing up the Leonardo 32U4 USB stick though. The mini is damn small but the 7 unused pins is bugging me as they equate to potential size reduction. The Leonardo would only have 4 spare pins left over and is half the size as the mini so could loose another 20~25mm in length.

I did come up with an idea for a stackable PCB system but I really need to finalise this one first before I get into deeper tinkering (I'm far too easily distracted).
Title: Re: Arduino Lightsaber
Post by: billpealer on Jan 21, 2016, 01:49 am
Saying that, are your skills for hire?

after your first velociraptor. everything else,.. is cake.

(http://forum.arduino.cc/index.php?action=dlattach;topic=261980.0;attach=151392)

i can model anything. if only my Blender STL files could be sent to a CNC machine.  i could have anything CNC'd too.

What do you need modeled? PM me.  i can also send you the STL files to have 3d printed locally.
Title: Re: Arduino Lightsaber
Post by: billpealer on Jan 21, 2016, 01:58 am
Or were you talking about my Nun-Chuck skills?
Title: Re: Arduino Lightsaber
Post by: Canobi on Jan 21, 2016, 02:05 am
No problem. It's for a good cause!

I assume you'll do some lab testing with the software I posted first before sending out field test units, yes?
Yep :) I have a few tests in store for the PCB including current tolerances and continuity as well. I've also started looking at making a small test rig as I found some spring loaded pins while out web shopping which could be used in a drop down contact type setup for the PCBs, and there's a good amount of space next to the console on my DIY power supply where it can go too (I've attached a pic this time as my PhotoBucket app isn't working for some reason).



Thanks! Which diagrams, though? The artwork I posted before had the FETs on the other end of the board. Do you have another version that you haven't showed us?
Ah yes, um no.. with so many versions flying around now its getting hard to navigate around here lol. The ADXL version of the PCB is based on your MkIV diagram.
Title: Re: Arduino Lightsaber
Post by: JakeSoft on Jan 21, 2016, 03:15 am
Yep :) I have a few tests in store for the PCB including current tolerances and continuity as well.

Ok, great. PM sent. How exciting!

I've also started looking at making a small test rig as I found some spring loaded pins while out web shopping which could be used in a drop down contact type setup for the PCBs...

Oooh, really? That would be great to have to program the pro-mini without needing to solder the programming pin headers on and thereby save some space. Care to share?
Title: Re: Arduino Lightsaber
Post by: JakeSoft on Jan 21, 2016, 04:52 am
Has anyone found a good reliable supplier for the 16p modules with 16M or 32M of flash? Ordering from eBay, they often don't tell you how much flash in the description and it's a crap shoot. I've ordered from the same suppliers and sometimes I get 8M modules, sometimes I get 16, and once in a while I'm lucky enough to get a 32M module.
Title: Re: Arduino Lightsaber
Post by: Protonerd on Jan 21, 2016, 09:03 am
JShaw...
WT28p set up.  with a nano,  and BTW this schematic DOES NOT CONTROL the BuckBoost with PWM LED fading. but it will turn on the buck boost, and turn it off,   meaning- no FOC and no blade up or down. effect.  just on/off LED
i can't get PWM to work with a mosfet if i move it to the LED Vout side of the Buck Step down.
(https://forum.arduino.cc/index.php?action=dlattach;topic=261980.0;attach=143399)

i have since moved my arduino Pin that goes to the mosfet to Pin 11 for PWM, tho i haven't gotten fading to work with a Buck, and the 2 sensors to non PWM pins. it's arbitrary.  you can do what you want.   also some people put a 1kohm resistor from pin 1 to pin 3 of the MOSFET to crash the PWM signal to 0 (Ground)  for Digital (HIGH/LOW) mosfet switching, you do not need it.
I'm still a bit confused why a buck is needed for LED control...? I thought a MOSFET and a PWM capable signal is the complete stuff you need for it...
Title: Re: Arduino Lightsaber
Post by: billpealer on Jan 21, 2016, 02:20 pm
I'm still a bit confused why a buck is needed for LED control...? I thought a MOSFET and a PWM capable signal is the complete stuff you need for it...
If i send 8.2v and unrestricted current to my LED it will fry it.

PWM does not limit current. it really doesn't limit voltage either,  but when you go from 0 volts to 8.2v 250 times a second,..  it starts to average to lower voltages.  I COULD put 1 ohm / 2-3 watt resistors to my LEDs,..  what is what a lot of (maybe even most) people do here to protect their lights.  That could be wasting 40% of the batt power to heat loss. Bucks waste maybe 10% or less of power in the conversion process. and they can drive other components.

good review of LED control.  I read it for the first time just now,  but have been tossed most of these crumbs via the folks here and old roommates from college who are versed on the topic of Computer Science, Control Systems, and Electrical Engineering.
http://www.digikey.com/en/articles/techzone/2010/apr/how-to-dim-an-led (http://www.digikey.com/en/articles/techzone/2010/apr/how-to-dim-an-led)

Buck up/downs-  or what my smarter electrical engineer pals tell me are called, constant current induction devices- limit current and convert voltage to the desired Max levels,  thru either custom set up, or the ones i use have mini potentiometers for adjustment.

Jake-----
I can't find half of this stuff anywhere ELSE but Ebay. If i do, it is often 10X the cost.  and yeah,..  it is hit or miss with 75% of it. i am tired of getting devices with ratings and specs that after testing prove otherwise.  This is a great question.  i hope someone comes forward with another provider.
Title: Re: Arduino Lightsaber
Post by: JakeSoft on Jan 21, 2016, 03:49 pm
JShaw...
WT28p set up.  with a nano,  and BTW this schematic DOES NOT CONTROL the BuckBoost with PWM LED fading. but it will turn on the buck boost, and turn it off,   meaning- no FOC and no blade up or down. effect.  just on/off LED
i can't get PWM to work with a mosfet if i move it to the LED Vout side of the Buck Step down.
(https://forum.arduino.cc/index.php?action=dlattach;topic=261980.0;attach=143399)

i have since moved my arduino Pin that goes to the mosfet to Pin 11 for PWM, tho i haven't gotten fading to work with a Buck, and the 2 sensors to non PWM pins. it's arbitrary.  you can do what you want.   also some people put a 1kohm resistor from pin 1 to pin 3 of the MOSFET to crash the PWM signal to 0 (Ground)  for Digital (HIGH/LOW) mosfet switching, you do not need it.
You know, it occurs to me that your fading of the LED might work better if you supplied constant power to your Buck converter and moved your transistor to be between the LED and the converter.
Title: Re: Arduino Lightsaber
Post by: Protonerd on Jan 21, 2016, 05:44 pm
If i send 8.2v and unrestricted current to my LED it will fry it.

PWM does not limit current. it really doesn't limit voltage either,  but when you go from 0 volts to 8.2v 250 times a second,..  it starts to average to lower voltages.  I COULD put 1 ohm / 2-3 watt resistors to my LEDs,..  what is what a lot of (maybe even most) people do here to protect their lights.  That could be wasting 40% of the batt power to heat loss. Bucks waste maybe 10% or less of power in the conversion process. and they can drive other components.

good review of LED control.  I read it for the first time just now,  but have been tossed most of these crumbs via the folks here and old roommates from college who are versed on the topic of Computer Science, Control Systems, and Electrical Engineering.
http://www.digikey.com/en/articles/techzone/2010/apr/how-to-dim-an-led (http://www.digikey.com/en/articles/techzone/2010/apr/how-to-dim-an-led)

Buck up/downs-  or what my smarter electrical engineer pals tell me are called, constant current induction devices- limit current and convert voltage to the desired Max levels,  thru either custom set up, or the ones i use have mini potentiometers for adjustment.

Jake-----
I can't find half of this stuff anywhere ELSE but Ebay. If i do, it is often 10X the cost.  and yeah,..  it is hit or miss with 75% of it. i am tired of getting devices with ratings and specs that after testing prove otherwise.  This is a great question.  i hope someone comes forward with another provider.
Sorry, my mistake, I did not pay attention to your supply. But, what about the following: you only use 1x3.7V supply (instead of 2) and use a boost to give 5V to your Arduino. Then connect your single LED to the 3.7V with PWM. Additional advantage: less space eaten up by batteries (they are big or have limited capacity) and a smaller boost, because the "logic" does not eat so much compared to the HP-LED's.
Title: Re: Arduino Lightsaber
Post by: billpealer on Jan 21, 2016, 06:30 pm
You know, it occurs to me that your fading of the LED might work better if you supplied constant power to your Buck converter and moved your transistor to be between the LED and the converter.
yeah,. good eye.
this diagram is for NO PWM fading,. as the mosfet arduino pin isn't even PWM.  i have rearranged things as a told jshaw for pwm.

i do have a new set up with an additional fet tween the vout of the buck and the led. still no good. i orered a new buck. maybe this one is bad.

Sorry, my mistake, I did not pay attention to your supply. But, what about the following: you only use 1x3.7V supply (instead of 2) and use a boost to give 5V to your Arduino. Then connect your single LED to the 3.7V with PWM. Additional advantage: less space eaten up by batteries (they are big or have limited capacity) and a smaller boost, because the "logic" does not eat so much compared to the HP-LED's.
yup. you are correct sir.
i DO that exactly with the saber i posted as my first build with Sw-200 sensors, back in Dec. 5v buck up, and 3.7v DIRECT to the LED, no resistors as i said,.  if you have a 3.3-3.4v LED that can take an Amp,. you don't need resistors at all, due to the internal resistance of the battery. which is about 1 ohm.  I am moving to a higher powered green Cree. so i can do more dramatic FoC. and PWM fading, and only use a buck wth the LED instead of the Arduino. i'll change this diagram to illustrate my new goal, and post a diagram for my working one battery set up.  which by the way,. is easy to make, change batts, and is cheap.
Title: Re: Arduino Lightsaber
Post by: JakeSoft on Jan 21, 2016, 06:37 pm
yeah,. good eye.
this diagram is for NO PWM fading,. as the mosfet arduino pin isn't even PWM.  i have rearranged things as a told jshaw for pwm.

i do have a new set up with an additional fet tween the vout of the buck and the led. still no good. i orered a new buck. maybe this one is bad.
yup. you are correct sir.

Try putting your nFET on the negative side of your LED instead.
Title: Re: Arduino Lightsaber
Post by: billpealer on Jan 21, 2016, 07:11 pm
Try putting your nFET on the negative side of your LED instead.
i have the neg out of the buck,. on the.. uh... source pin. right pin.  i have the neg of the LED on the drain. middle pin.

you think switch that?
Title: Re: Arduino Lightsaber
Post by: JakeSoft on Jan 21, 2016, 08:14 pm
i have the neg out of the buck,. on the.. uh... source pin. right pin.  i have the neg of the LED on the drain. middle pin.

you think switch that?
That sounds right. Not sure why it doesn't work. Sorry, man; I'm stumped too.
Title: Re: Arduino Lightsaber
Post by: billpealer on Jan 21, 2016, 08:27 pm
That sounds right. Not sure why it doesn't work. Sorry, man; I'm stumped too.
i'm buying a new buck.
my original hypotheses was the buck actually uses a pwm or maybe a ripple freq based output,  so the negative OUT of the buck going to the source pin of the Mosfet was not syncing with the PWM on the gate pin.  so the orchestra of pulses and frequencies were out of tune.

the PWM to the buck wasn't doing "nothing". it just wasn't fading like a raw PWM to LED set up. random behavior.  from working once, to not working again, to just plain random LED intensities..  not shutting fully off.  turning off when Foc was supposed to go down.  very frustrating.

i also want to add, i can't find a single HOW To or forum that has this topic discussed. google search = ghost town. i figure because it is so simple that i am the only dolt having issues,.. or that it may be laymen's knowledge that you CANT use digital PWM and MOSFET tween an LED and Buck
Title: Re: Arduino Lightsaber
Post by: DJWing79 on Jan 22, 2016, 12:04 am
So...one step forward, one step back.

I printed a hilt in three pieces using a 3D printer (standard PLA) and had it at 30% infill with triangular structure. the outer wall is at 1.65in and the inner wall is at 1.35in, so a total thickness of .3in, and now the results....

the physical pieces can take a major thrashing without cracking, breaking or compressing. Had my son hit the bladeholder directly at varying degrees of force and nothing. the inner core where the blade rests had no damage either. the metal screw I used as a retention piece was fine and unscrewed and rescrewed without a hiccup (printed the threads in the design).

you may be asking yourself...how do you know what the inside looks like and that there is no damage? well....that's because the hilt snapped....into three pieces...right on the 3-d printed threads. I was using 1.43inx12 ANSI threads and they couldn't take the force of the vibration from the impact. the rest of the body was fine. I am thinking about making the parts slide inside eachother until they catch and holding them together with a couple of machine screws. unless anyone has a different suggestion?
Title: Re: Arduino Lightsaber
Post by: stinky1 on Jan 22, 2016, 12:08 am


Lets see I found this: Wiring a buckpuck to Arduino  (http://www.nano-reef.com/topic/214770-wiring-a-buckpuck-to-arduino/page-2)

Transistor to communicate PWM to Buckpuck LED driv (http://forum.arduino.cc/index.php?topic=16281.0)

Code at the end,  for controlling alot of LEDs in a fish tank light.
LED Unit Blueprint  (http://www.nano-reef.com/topic/174406-led-unit-blueprint/page-2)

Wiring buckpuck to arduino? (http://forum.arduino.cc/index.php?topic=67251.0)

Arduino - Buckpuck interface little issue (https://forum.arduino.cc/index.php?topic=364760.0)
Title: Re: Arduino Lightsaber
Post by: JakeSoft on Jan 22, 2016, 12:13 am
So...one step forward, one step back.

I printed a hilt in three pieces using a 3D printer (standard PLA) and had it at 30% infill with triangular structure. the outer wall is at 1.65in and the inner wall is at 1.35in, so a total thickness of .3in, and now the results....

the physical pieces can take a major thrashing without cracking, breaking or compressing. Had my son hit the bladeholder directly at varying degrees of force and nothing. the inner core where the blade rests had no damage either. the metal screw I used as a retention piece was fine and unscrewed and rescrewed without a hiccup (printed the threads in the design).

you may be asking yourself...how do you know what the inside looks like and that there is no damage? well....that's because the hilt snapped....into three pieces...right on the 3-d printed threads. I was using 1.43inx12 ANSI threads and they couldn't take the force of the vibration from the impact. the rest of the body was fine. I am thinking about making the parts slide inside eachother until they catch and holding them together with a couple of machine screws. unless anyone has a different suggestion?
Have you thought about maybe printing your parts as a sleeve over some cheap brass sink tube or solid PVC pipe to reinforce it? That way, your parts are basically an attractive facade over cheap hardware store parts. Nobody will be able to tell the difference.
Title: Re: Arduino Lightsaber
Post by: DJWing79 on Jan 22, 2016, 12:49 am
I thought about that, but I don't have the tools or know-how to cut the pvc pipe
Title: Re: Arduino Lightsaber
Post by: billpealer on Jan 22, 2016, 12:55 am


a buckpuck is a thing. like a branded product. it has a pwm cable if I recall.  I am not referring to a buckpuck perse . if I did my bad.

thanks for the links stinker
Title: Re: Arduino Lightsaber
Post by: billpealer on Jan 22, 2016, 01:02 am
So...one step forward, one step back.

I printed a hilt in three pieces using a 3D unless anyone has a different suggestion?
print along another axis .  instead of cylindrical.  hemispheres. snap clam shells. your print striation will be perpendicular to the impact of combat. strong like bull.

or model your parts then cast them in polyresin.  Jake is prolly got it nailed. mixed media is where it's at. but if you want 100% pla ,  you will have to be crafty with various jacketed parts and sleeves to connect protect and look cool. maybe some epoxy is in your future. :) or 2 part weld putty

but dude.  throw up some pics.. we have no idea how you modeled or printed? what's your modeling software?  I'm totally guessing that you made cylinder based parts

I had to rotate my TIE sleds 90 degrees on the platter. the flex was snapping the fins.  now it flexes like a bow. like it should.
Title: Re: Arduino Lightsaber
Post by: DJWing79 on Jan 22, 2016, 01:54 am
I am using Fusion 360 to model and Simplify3D to slice and print. I am printing it cylindrically, that's true, so do you think if I printed it on it's side it'd be stronger? I was printing it straight up and down.
Title: Re: Arduino Lightsaber
Post by: billpealer on Jan 22, 2016, 02:09 am
I am using Fusion 360 to model and Simplify3D to slice and print. I am printing it cylindrically, that's true, so do you think if I printed it on it's side it'd be stronger? I was printing it straight up and down.
ok. i'll have to check those apps out.

no,..  not just length wise,.  but split.
this is what i mean. attached. disregard the other parts.
(http://forum.arduino.cc/index.php?action=dlattach;topic=261980.0;attach=151575)

split it in halves.  clam shell. print flat side down. dome UP. No supports, there should be enough to grab on the arc.  you'll need threading and what not.  actually i have heard twist lock is very successful for printing,.  then over parts for added support.
Title: Re: Arduino Lightsaber
Post by: billpealer on Jan 22, 2016, 04:15 am
TIE Sled with speaker holder and battery holder:
(http://forum.arduino.cc/index.php?action=dlattach;topic=261980.0;attach=151587)
30.5mm OD for TCSS hilts.
Uses a 2x 14500 7.4v battery holder that can double as a FET and small bits Chassis.
28mm 8ohm 2w bass speaker (rail master)
The MCU Sled will accommodate 5cm of control devices. like a WT 28p USB on the deep side (1.7cm deep) and a nano with NO headers on the shallow side (1cm deep).  If you need button clearance, the deep side will fit JUST under a short 16mm switch that has been properly spaced with an activation box, and even lengthened on the shallow side so the arduino and WT will fit on the shallow side in a line, ergo Canobi's PCB.  There is enough room in the gutters of the TIE fins to wrangle wires. uses 3.5 meters of filament.. about 75 cents.  if anyone wants to play with one or a variant, PM me. I understand there are saber smiths that use tubing,.. but what holds the speakers and batts?  they must be buying something for that.

I like stack-ability over an "all in a line' parts parade. It allows for both control devices to be easily accessed. And length real estate in a hilt i am finding is harder to come by than girth. bigger batts = better sabers. and over 12" of hilt is,. well-  Blasphemy. :)

If anyone has any suggestions or feedback, i am open.

Due to the 29.5 mm OD of the Speaker holder at one end and the 30.5mm OD of the TIE at the other, their is virtually no movement of the chassis, and unscrewing the hilt extension does not torque the parts.

I have 2 more versions in the kitchen. One for a single CR123A, and one for a Double in series.  I am finding that the 14500 2x pack will NOT fit in anything other than the TCSS large ID hilts.  It will not fit into ribbed extensions of 28.5mm ID, and is VERY tight in the smaller stylized extensions.
Title: Re: Arduino Lightsaber
Post by: billpealer on Jan 22, 2016, 05:58 am
this arrived at my door today.  it's an LDO not an Induction Based Buck.  i will push 4.8v nimh and 7.4 lith ion thru it, and report back on the multimeter's readings. 3.3v and 800ma is still spot on for star rebels.  you'd need 3 for a rebel tri right?  tri people?

(http://i.ebayimg.com/images/g/VzkAAOSw3KFWfi4w/s-l300.jpg)

http://www.ebay.com/itm/New-5x5V-to-3-3V-DC-DC-Step-Down-Power-Supply-Buck-Module-AMS1117-LDO-800MA-CM8-/401048770812?hash=item5d605e98fc:g:VzkAAOSw3KFWfi4w (http://www.ebay.com/itm/New-5x5V-to-3-3V-DC-DC-Step-Down-Power-Supply-Buck-Module-AMS1117-LDO-800MA-CM8-/401048770812?hash=item5d605e98fc:g:VzkAAOSw3KFWfi4w)
Title: Re: Arduino Lightsaber
Post by: CrossRoads on Jan 22, 2016, 06:18 am
That's a linear regulator board -  you can see the AMS1117 regulator on the back side picture. You put 800mA thru that and it's gonna overheat and go into thermal shutdown as it appears to have minimal, or no, heatsinking.
Title: Re: Arduino Lightsaber
Post by: billpealer on Jan 22, 2016, 06:41 am
Ho Lee dookie.
Now, i just read an interesting article that said PWM dimming in a Constant Current Buck/Boost LED driver is inversely proportional. and you CANT use a MOSFET. the buck itself has to have PWM on the chip. and PWM -0 is full volts /amps and the closer you get to 5v..  aka  pwm 255 it turns off.

that is from LuxDrive's product sheets.  the maker of the BuckPuck, and  this cheapie from ebay seems to 100% confirm.

http://www.ebay.com/itm/3W-5-35V-LED-Driver-700mA-PWM-Dimming-DC-to-DC-Step-down-Constant-Current-/251998350085?hash=item3aac45ab05:g:C~gAAOSwrklVgOCT (http://www.ebay.com/itm/3W-5-35V-LED-Driver-700mA-PWM-Dimming-DC-to-DC-Step-down-Constant-Current-/251998350085?hash=item3aac45ab05:g:C~gAAOSwrklVgOCT)

"Supports PWM dimming
High level turn off the output
Low level Open the output"

It also appears for the best PWM Buck PWM dimmers, 7.4v will only get you 3W 700ma.  5W 800ma units require 9v Vin and if you want to push 1000ma, you'll need to step up to 10W units and 11.1v lith. boooooo!   I am REALLY leaning toward What Protonerd also said,.. 1- 18650 Raw to a 3W LED, which i have tested and the LED pulls 3.4v and 800ma, no LDOs or Resistors.  just the Batts internal resistande dropping the batt's open voltage by about .5v
Title: Re: Arduino Lightsaber
Post by: billpealer on Jan 22, 2016, 06:42 am
That's a linear regulator board -  you can see the AMS1117 regulator on the back side picture. You put 800mA thru that and it's gonna overheat and go into thermal shutdown as it appears to have minimal, or no, heatsinking.
yes that's right. LDOs are linear regulators.
i figured i'd cook one for the greater good.  i was meaning to make some ramen noodles anyway. I just read the Data sheet.  i don't know the CM8 version,. but all the other models clearly say 800ma is tolerated.  I emailed the vendor and they said 800ma is the max the unit will push, and is restricted.  I must admint 75% of the data sheet reads like klingon to me.  but the one thing i do understand is 165 degrees c, shuts off the thing. dude that's hot!  maybe the 7.4v liths will cook it.  but the 4.8 nimh may be perfect.

Jake-man, you use a 5v regulator from a 7.4 lith pack, ever melt it?  you don't go direct from the batts to the lights right? you pass thru the LDO?
Title: Re: Arduino Lightsaber
Post by: Protonerd on Jan 22, 2016, 10:25 am
TIE Sled with speaker holder and battery holder:
(http://forum.arduino.cc/index.php?action=dlattach;topic=261980.0;attach=151587)
30.5mm OD for TCSS hilts.
Uses a 2x 14500 7.4v battery holder that can double as a FET and small bits Chassis.
28mm 8ohm 2w bass speaker (rail master)
The MCU Sled will accommodate 5cm of control devices. like a WT 28p USB on the deep side (1.7cm deep) and a nano with NO headers on the shallow side (1cm deep).  If you need button clearance, the deep side will fit JUST under a short 16mm switch that has been properly spaced with an activation box, and even lengthened on the shallow side so the arduino and WT will fit on the shallow side in a line, ergo Canobi's PCB.  There is enough room in the gutters of the TIE fins to wrangle wires. uses 3.5 meters of filament.. about 75 cents.  if anyone wants to play with one or a variant, PM me. I understand there are saber smiths that use tubing,.. but what holds the speakers and batts?  they must be buying something for that.

I like stack-ability over an "all in a line' parts parade. It allows for both control devices to be easily accessed. And length real estate in a hilt i am finding is harder to come by than girth. bigger batts = better sabers. and over 12" of hilt is,. well-  Blasphemy. :)

If anyone has any suggestions or feedback, i am open.

Due to the 29.5 mm OD of the Speaker holder at one end and the 30.5mm OD of the TIE at the other, their is virtually no movement of the chassis, and unscrewing the hilt extension does not torque the parts.

I have 2 more versions in the kitchen. One for a single CR123A, and one for a Double in series.  I am finding that the 14500 2x pack will NOT fit in anything other than the TCSS large ID hilts.  It will not fit into ribbed extensions of 28.5mm ID, and is VERY tight in the smaller stylized extensions.
OMG, that sled looks good! Congrats Sir! I've been dreaming about such a chassis since getting started with lightsabers. I wish I could do something similar...

Or (maybe I missed some earlier posts) do you intend to source the sled as a part of a complete package for the interconnect PCB based design? That would be an amazing offer.
Title: Re: Arduino Lightsaber
Post by: JakeSoft on Jan 22, 2016, 03:49 pm
Jake-man, you use a 5v regulator from a 7.4 lith pack, ever melt it?  you don't go direct from the batts to the lights right? you pass thru the LDO?
I do, but the LDO does get pretty darn hot. I use a TO-220 style LDO and it heats up to the point where you'll burn you fingers pretty quickly if you touch the metal tab on it. I have to leave it a lot of space and be careful that it's not touching anything. I've been running the Mk. II like that for years and it hasn't blown up yet. Still, it does require a great deal of care.
Title: Re: Arduino Lightsaber
Post by: billpealer on Jan 22, 2016, 06:03 pm
OMG, that sled looks good! Congrats Sir! I've been dreaming about such a chassis since getting started with lightsabers. I wish I could do something similar...

Or (maybe I missed some earlier posts) do you intend to source the sled as a part of a complete package for the interconnect PCB based design? That would be an amazing offer.
er.. i don't know what "source it" means,..  but..
PM me your specs and battery prefs. i'll send you a couple.  it is very easily scale-able at this point.
I have been meaning to make one for a 3 or 4x AAA batt holder.  someone have need?
Title: Re: Arduino Lightsaber
Post by: JakeSoft on Jan 22, 2016, 07:54 pm
er.. i don't know what "source it" means,..  but..
PM me your specs and battery prefs. i'll send you a couple.  it is very easily scale-able at this point.
I have been meaning to make one for a 3 or 4x AAA batt holder.  someone have need?
I think he's asking if you intend to package your sled system with Canobi's PCB for a programmable drop-in solution. That would be a pretty cool and unique offering.
Title: Re: Arduino Lightsaber
Post by: billpealer on Jan 22, 2016, 08:24 pm
I think he's asking if you intend to package your sled system with Canobi's PCB for a programmable drop-in solution. That would be a pretty cool and unique offering.
never thought about it. I could. easily.  no one is really talking batts and canobi's platform. big picture, that needs to be hashed out.  or you could have 4 versions, a PVC version, a sink tube, and 2 TCSS versions.  I already have 2 TCSS versions because there are 2 TCSS IDs in play.  1- main parts and extensions, 30.5mm ID, and 2- ribbed, v grooved and other stylized parts with 28.1 mm ID.   those 2 versions alone require completely different battery strategies.   this would be very much simplified if there was a 3.7v only approach.  It would be the 18650 or CR123A batts, or even a small LIPO, and Rebel Star or Tri Rebel LEDs only.  so that no LED Vf of over 3.35v is required. and a simple 5v buck up would power the MCU and Sound Modules.  ProtoNerd style.
Title: Re: Arduino Lightsaber
Post by: JakeSoft on Jan 22, 2016, 09:21 pm
never thought about it. I could. easily.  no one is really talking batts and canobi's platform. big picture, that needs to be hashed out.  or you could have 4 versions, a PVC version, a sink tube, and 2 TCSS versions.  ...   this would be very much simplified if there was a 3.7v only approach.  It would be the 18650 or CR123A batts, or even a small LIPO, and Rebel Star or Tri Rebel LEDs only.  so that no LED Vf of over 3.35v is required. and a simple 5v buck up would power the MCU and Sound Modules.  ProtoNerd style.
I agree that there needs to be a base-case; a "standard" that we can work on collaterally. Otherwise, it's anarchy. Probably 3.7V 18650 and standard MHS parts is a good starting point (ID = 1.25 inches). Do you think Canobi's PCB will fit over top of an 18650 in 1.25? It's a long-ish card and being able to stack it on top of something is really kind of a requirement to avoid obnoxiously long hilts.

Question:
How are you anchoring the PCB so it won't slide around on the chassis? 
Title: Re: Arduino Lightsaber
Post by: billpealer on Jan 22, 2016, 10:21 pm
How are you anchoring the PCB so it won't slide around on the chassis? 
not there yet.  i have 2 plans.  3M velcro or good Old epoxy. i probably could put snap tabs in the model, so things would "snap fit. in. or slide lock.   adding a modeled snap tab would only work if there was,. one ring to rule them all...  i will let you know about the 18650 and ID  and TCSS has 2 IDs...  as i emailed them to confirm. 1.25 for main hilts and extensions.  1.125" for all other accessories. V groove, ribbed, gears,..  and my tests confirmed.
Title: Re: Arduino Lightsaber
Post by: Canobi on Jan 22, 2016, 11:56 pm
PCB over CR123A cell in a 1.25" ID tube:

(http://i1225.photobucket.com/albums/ee395/Can-obi/IMG_20160122_224757.jpg) (http://s1225.photobucket.com/user/Can-obi/media/IMG_20160122_224757.jpg.html)
Title: Re: Arduino Lightsaber
Post by: billpealer on Jan 23, 2016, 12:56 am
so a 18650 will be too big. actually.  any batt will be too big to stack or piggy back on this. they don't make single cr123a wired tabbed bat packs
Title: Re: Arduino Lightsaber
Post by: DJWing79 on Jan 23, 2016, 01:04 am
when I did the 3d print for hilt parts, I used an inner diameter of 1.3 and things barely cleared with electronics and the 18650.

On another note, I printed the hilt pieces again, but oriented the print for them to be on their side and they warped on the bottom (grr)....but am going to try and up the density of the screw portion (the nut portion held fine) since the entirety of the inner diameter doesn't need to be super open, just the part where the sled goes in. I am now attempting 1.5" x12 ANSI screw threads with a wall thickness (of the screw part) at .6" and having it "anchor" further down into it's housing by a good .3". will print tonight and test tomorrow. I didn't take pics because they were garbage after. But I will before and after test this time. I also have another mockup ready to test if this fails which forgoes the screws and slides together and is held in place with retaining bolts. may not be cosmetically what I want (but I can always include it as a design "feature") but may be able to hold up better. wish me luck!
Title: Re: Arduino Lightsaber
Post by: billpealer on Jan 23, 2016, 01:23 am
Quote from: DJWing79
On another note, I printed the hilt pieces again, but oriented the print for them to be on their side and they warped on the bottom (grr)...
pics.  attach pics.  warping could have nothing to do with your fill density. pm me. 3d printing technique is off topic.  there is no garbage when in test phase.  this is a pretty good think tank. don't be embarrassed or afraid to post your strike outs.  you dig?
Title: Re: Arduino Lightsaber
Post by: JakeSoft on Jan 23, 2016, 07:16 am
PCB over CR123A cell in a 1.25" ID tube:

(http://i1225.photobucket.com/albums/ee395/Can-obi/IMG_20160122_224757.jpg) (http://s1225.photobucket.com/user/Can-obi/media/IMG_20160122_224757.jpg.html)
Hmm... I was worried about that. Those pin headers are eating up a lot of space. Were going to have to in-line it with the battery at this rate. I wonder if there would be a way to remove those plastic spacers on the headers so that the component on top lied flatter on the larger PCB. It's that clearance that's killing us.
Title: Re: Arduino Lightsaber
Post by: billpealer on Jan 23, 2016, 07:50 am
Hmm... I was worried about that. Those pin headers are eating up a lot of space. Were going to have to in-line it with the battery at this rate. I wonder if there would be a way to remove those plastic spacers on the headers so that the component on top lied flatter on the larger PCB. It's that clearance that's killing us.

this is the #1 reason i go headerless on the Nanos. and go wire IN from the top of the thing and solder there.  when i made the nano/WT stack in my Saber 1.0, i lost maybe 1 full cm to headers, and plastic stand offs. I have been asking every vendor who sells WTs if i can get them with out headers.  all have said no.
maybe put all non MCU bits on the back of a/the batt holder.
fets, regulators, 5v step up. clash sensor, and i can ( or anyone- it's not rocket science) make fins with slits to epoxy onto the sides of the Canobi's PCB. 

there has to be something i am missing to make it fit neat. can the pro mini sit IN the hilt? like cross section-wise?. horizontal?  if it wasn't for the 3 color fading and the adxl.  you could use a ATTINY85 micro-usb version unit,.. and put it IN the hilt horizontal.  2cm x 17mm.  THAT would fit TCSS main parts. it is 5v and 6 pin. 3 of which are PWM and no analogs. and if you abandon the busy pin on the WT,..  could run 2 SW-200s for 2 axis old school swings. i actually use 2 SW in a cross and going to one pin in parallel. works. this is all for 1.25" ID too.  forget pvc,. nothing fits in there.   WTF do you PVC people use for LED heat sync's anyway?    those 3 color LEDs are pricey too.  who uses's 10$ PVC hilts with $25 of LEDs?
http://www.ebay.com/itm/5X-PCS-Digispark-Kickstarter-Attiny85-USB-Development-Board-for-arduino-/221898923514?hash=item33aa34ddfa:g:W-0AAOSwo6lWJaDh (http://www.ebay.com/itm/5X-PCS-Digispark-Kickstarter-Attiny85-USB-Development-Board-for-arduino-/221898923514?hash=item33aa34ddfa:g:W-0AAOSwo6lWJaDh)
Title: Re: Arduino Lightsaber
Post by: billpealer on Jan 23, 2016, 08:10 am
Lipos may be the solution. Lipos on the back of the PCB Canobi thing. not cylinder batts.
http://www.ebay.com/itm/3-7V-1000mAh-452777-Rechargeable-LiPo-ion-Battery-For-mobile-phone-Tablet-PC-GPS-/111861260537?hash=item1a0b7360f9:g:BxkAAOSwhkRWgk5F (http://www.ebay.com/itm/3-7V-1000mAh-452777-Rechargeable-LiPo-ion-Battery-For-mobile-phone-Tablet-PC-GPS-/111861260537?hash=item1a0b7360f9:g:BxkAAOSwhkRWgk5F)

might fit. 1 amp ain't too bad, for 1 LED. 

or a single 14500..  it would fit in a standard single AA batt holder?  right?


http://www.ebay.com/itm/AKKU-for-Led-Flashlight-3-7v-1500mAh-14500-Rechargeable-LI-ION-battery-CC-/161845361269?hash=item25aebc3a75:g:NFMAAOSw42JWDj15 (http://www.ebay.com/itm/AKKU-for-Led-Flashlight-3-7v-1500mAh-14500-Rechargeable-LI-ION-battery-CC-/161845361269?hash=item25aebc3a75:g:NFMAAOSw42JWDj15)
Title: Re: Arduino Lightsaber
Post by: Canobi on Jan 23, 2016, 04:44 pm
Jake, you mentioned putting the battery inline, thats very close to something I've been contemplating as clearance in 25mm ID is nonexistent.

I made this quick sketch to show what I have in mind:

(http://i1225.photobucket.com/albums/ee395/Can-obi/IMG_20160123_153436.jpg) (http://s1225.photobucket.com/user/Can-obi/media/IMG_20160123_153436.jpg.html)

Tha cell fits in between the two outside extentions but has its own PCB with the holder mounted on it that sits lower down and connects to the main board via headers.
Title: Re: Arduino Lightsaber
Post by: JakeSoft on Jan 23, 2016, 07:06 pm
 
or a single 14500..  it would fit in a standard single AA batt holder?  right?


http://www.ebay.com/itm/AKKU-for-Led-Flashlight-3-7v-1500mAh-14500-Rechargeable-LI-ION-battery-CC-/161845361269?hash=item25aebc3a75:g:NFMAAOSw42JWDj15 (http://www.ebay.com/itm/AKKU-for-Led-Flashlight-3-7v-1500mAh-14500-Rechargeable-LI-ION-battery-CC-/161845361269?hash=item25aebc3a75:g:NFMAAOSw42JWDj15)
That might work. I've experimented and my Mk. IV board and determined it would fit inside 1.25" on top of a 7.4V side-by-side 14500 pack (Example Link (http://www.thecustomsabershop.com/74v-Li-ion-800mAh-14500-Battery-Pack-P698.aspx)) but not for the fact that I mounted the ADXL335 on top of the Pro Mini. That's two layers of headers that eat up the clearance and it just baaarely won't fit. However, Canobi's board is flatter because he doesn't piggy-back the ADXL335, so it's one layer thinner than my Mk. IV prototype.

It would be ideal if we could find a side-by-side 3.7v 14500 (or even better, a 14650 pack) with a load-balancing PCB that would output 3+ amps. That way you'd get excellent battery life and still be able to support full three-channel color change. That's pretty specific, though. Might be hard to find.
Edit: Found one. Never heard of this supplier before, but at least I know they do exist. (Link (http://www.batterysupports.com/36v-37v-aa-2-14500-1500mah-2p-lithium-ion-liion-battery-pack-p-41.html))

The problem with using an AA battery holder for the cells is that the battery holder itself also takes up space. It might still fit, though. It's worth looking into.  

Title: Re: Arduino Lightsaber
Post by: billpealer on Jan 23, 2016, 09:08 pm
The problem with using an AA battery holder for the cells is that the battery holder itself also takes up space. It might still fit, though. It's worth looking into. 

i like the 1500mah. bonus. twice as mush as TCSS
Batt holder-
right.  but with one...  maybe 3mm of girth added, and the plus side is the back is capable of gluing crap too. now you can use removable batts. just saying.  as a 3.7v option for the Canobi Express it maybe the best option. other than a Lipo.

i bought this. it is an 14650 and took the outer wrapper off so i could shoot the cable straight out the top. the 90 degree protruding cable was chafing on the hilt threads.  it is 1.5cm longer than 14500.  but 2 for $15... spoke my language.  but i can't find a twin 18650 over 850mah.  makes no sense.  the single are 2200+

http://www.ebay.com/itm/2PCS-14650-7-4V-850mAH-Rechargeable-Li-ion-Battery-15C-SM-Plug-For-RC-Helicopter-/301730366706?hash=item46408804f2:g:ZKgAAOSw3ydV5rc0 (http://www.ebay.com/itm/2PCS-14650-7-4V-850mAH-Rechargeable-Li-ion-Battery-15C-SM-Plug-For-RC-Helicopter-/301730366706?hash=item46408804f2:g:ZKgAAOSw3ydV5rc0)
Title: Re: Arduino Lightsaber
Post by: billpealer on Jan 23, 2016, 09:32 pm
i think this would work. it would be 2cmx1.2cmx12cm  that would run the whole length of the hilt. what is 12cm 5 inches?

http://www.ebay.com/itm/RC-Turnigy-nano-tech-1200mAh-2S-15-30C-Lipo-AIRSOFT-Pack-T-Connector-/262150710667?hash=item3d0966658b:g:3gYAAOSwiwVWTaCY (http://www.ebay.com/itm/RC-Turnigy-nano-tech-1200mAh-2S-15-30C-Lipo-AIRSOFT-Pack-T-Connector-/262150710667?hash=item3d0966658b:g:3gYAAOSwiwVWTaCY)

swapping it will be,..  inventive.
Title: Re: Arduino Lightsaber
Post by: JakeSoft on Jan 23, 2016, 10:21 pm
i think this would work. it would be 2cmx1.2cmx12cm  that would run the whole length of the hilt. what is 12cm 5 inches?

http://www.ebay.com/itm/RC-Turnigy-nano-tech-1200mAh-2S-15-30C-Lipo-AIRSOFT-Pack-T-Connector-/262150710667?hash=item3d0966658b:g:3gYAAOSwiwVWTaCY (http://www.ebay.com/itm/RC-Turnigy-nano-tech-1200mAh-2S-15-30C-Lipo-AIRSOFT-Pack-T-Connector-/262150710667?hash=item3d0966658b:g:3gYAAOSwiwVWTaCY)

swapping it will be,..  inventive.
I used to play a lot of airsoft. These things scare the hell out of me. lol
Title: Re: Arduino Lightsaber
Post by: jshaw on Jan 23, 2016, 10:39 pm
I've been testing with a 3.7v 1200mah lipo battery ( https://www.creatroninc.com/product/lithium-ion-battery-1200mah/ ) that fits in my hilt. There's no room for a sled on the sides of it, but I've been thinking of grabbing another, but have no idea how to run them together, if that's even possible.
Title: Re: Arduino Lightsaber
Post by: Canobi on Jan 24, 2016, 01:10 am
I've been testing with a 3.7v 1200mah lipo battery ( https://www.creatroninc.com/product/lithium-ion-battery-1200mah/ ) that fits in my hilt. There's no room for a sled on the sides of it, but I've been thinking of grabbing another, but have no idea how to run them together, if that's even possible.
It's definitely possible. You looking to double your voltage or capacity?
Title: Re: Arduino Lightsaber
Post by: jshaw on Jan 24, 2016, 03:38 am
It's definitely possible. You looking to double your voltage or capacity?
Capacity.  Running a tri-rebel w/ 3x700mA LEDs is a bit much for a single 1200mAh battery to handle, unless I completely don't understand capacity (which is entirely possible as this is my first real electronics project). 

I'm mostly concerned w/ how they'd be wired together and how I'd then charge them; as a single unit or each individually.  The latter would be exceptionally annoying. 
Title: Re: Arduino Lightsaber
Post by: JakeSoft on Jan 24, 2016, 03:54 am
I'm mostly concerned w/ how they'd be wired together and how I'd then charge them; as a single unit or each individually.  The latter would be exceptionally annoying. 
I have kind of been wondering that myself. I prefer in-hilt recharge systems and I can find 3.7V PCB-protected cells that are small enough pretty easily, but I'd like to put two of them in parallel for greater capacity. I'm not sure how well that would work out, though.
Title: Re: Arduino Lightsaber
Post by: stinky1 on Jan 24, 2016, 07:11 am
Capacity.  Running a tri-rebel w/ 3x700mA LEDs is a bit much for a single 1200mAh battery to handle, unless I completely don't understand capacity (which is entirely possible as this is my first real electronics project). 

I'm mostly concerned w/ how they'd be wired together and how I'd then charge them; as a single unit or each individually.  The latter would be exceptionally annoying. 
Please refer to post 449,  page 30 as I think these are what you will need.  I have unregulated cells(no pcb board in top) so I need some sort of protection circuit, so why not make it a charger pack with one of these?  At least that's what I think these do. 


http://www.ebay.com/sch/i.html?_odkw=PCB+for+7.4V++18650&_osacat=0&_from=R40&_trksid=p2045573.m570.l1313.TR0.TRC0.H0.XPCB++7.4V++18650.TRS0&_nkw=PCB++7.4V++18650&_sacat=0

Title: Re: Arduino Lightsaber
Post by: Canobi on Jan 24, 2016, 12:19 pm
I took a quick look on the RS website and found the female JST- PH connectors for the those flat cell batteries going for pennies so I took a few minutes to whip together a couple of "in hilt" battery mixer boards, one doubles the voltage the other doubles the capacity.

(http://i1225.photobucket.com/albums/ee395/Can-obi/IMG_20160124_104814.jpg) (http://s1225.photobucket.com/user/Can-obi/media/IMG_20160124_104814.jpg.html)



On the whole it's not recommended to charge multiple Li-Po cells at the same time without proper monitoring and cell balancing circuitry. The short explanation is the cells don't all drain and charge at exactly the same rate and if one cell fills up first, it can cause it to start draining into the emptier one which is a situation to be avoided at all costs.
Title: Re: Arduino Lightsaber
Post by: JakeSoft on Jan 24, 2016, 02:21 pm
On the whole it's not recommended to charge multiple Li-Po cells at the same time without proper monitoring and cell balancing circuitry. The short explanation is the cells don't all drain and charge at exactly the same rate and if one cell fills up first, it can cause it to start draining into the emptier one which is a situation to be avoided at all costs.
This jives with what I have read as well. The pre-made multi-cell high capacity packs  have PCBs that do this load balancing across the cells, so you have to charge the cells individually otherwise.
Title: Re: Arduino Lightsaber
Post by: billpealer on Jan 24, 2016, 07:27 pm
On the whole it's not recommended to charge multiple Li-Po cells at the same time without proper monitoring and cell balancing circuitry. The short explanation is the cells don't all drain and charge at exactly the same rate and if one cell fills up first, it can cause it to start draining into the emptier one which is a situation to be avoided at all costs.
i have/use a balancer for the 14560 packs shown in my post with the 3D printed sled. I am a green horn with arduino, but i have been making my own 2+ cell lipos/lithiums, for the better part of 10 years. i hate doing it.  making packs is a hassle and a half that THAT is something to avoid at all costs :).  and while you don't need balancers, at all. period. you don't.   the real reason to use a balancer is if one of the cells is on its way out, a 7.4v charger will keep pushing voltage till it gets to the right 8.2v smart charger cut off point.  if one of the cells is bad, the good cell will over charge and puff up, and shoot burning hot exposed lithium.  hot enough to melt aluminum. or what ever toy/gizmo you have the pack in. and because each cell is charged independently. it may decrease charge time.  balancers charge faster/safer.  not any better. i wish they made them for my 7.2v packs for my 1:10 cars.  A NiMH pack with a dying cell will get HOT during charging.  if they had balancers, just the cell that was not as good as the others would get hot.  if the cell was dead, the charger wouldn't work.  Same with Lipo. With Lithium, A dead cell is safer than a bad one.  and if you know the order of cell charging in a balancer, you can replace the bad cell. the balancer will simply shut off (maybe with an indicator light) when it gets to the bad cell.
they are for Lipos mainly,
for 14560 and 18650, or any pcb cells,... 99.9 times it's whatever. Unless you're dell computers.  they must buy the worst 18650s. they are always int he news for melting people's laps.   a 7.4v lithium smart charger. read the specs, make sure the auto shut off is somewhere tween 8.2 and 8.4v.  some 7.4v smart chargers only push 7.4v (found that out the hard way) , which will charge your batts to about 30% capacity.
Title: Re: Arduino Lightsaber
Post by: JakeSoft on Jan 24, 2016, 07:36 pm
i have/use a balancer for the 14560 packs shown in my post with the #D printed sled. I am a green horn with arduino, but i have been making my own 2+ cell lipos/lithiums, for the better part of 10 years. i hate doing it.  making packs is a hassle and a half that THAT is something to avoid at all costs :).  ...
Yeah, I agree. It seems like a giant pain to make your own packs and that kind of goes against the approachable nature I was hoping for with this project. You shouldn't need to be an EE to build one of these things. I'm certainly not. Let's keep it as basic as possible.

Thanks for all the info, Bill. I'm so glad you are part of this thread; I've learned a lot from your posts.
Title: Re: Arduino Lightsaber
Post by: billpealer on Jan 25, 2016, 02:21 am
Thanks for all the info, Bill. I'm so glad you are part of this thread; I've learned a lot from your posts.
ok... that's cool.
bool = saberon and MOSFETs changed my life.  :)
Title: Re: Arduino Lightsaber
Post by: JakeSoft on Jan 25, 2016, 03:47 am
ok... that's cool.
bool = saberon and MOSFETs changed my life.  :)
Haha! They'll do that!
Title: Re: Arduino Lightsaber
Post by: JakeSoft on Jan 25, 2016, 03:51 pm
Page 7 Canobi and Jake refer to the USB WT as the 32pin version.  For anyone bouncing around. this may cause confusion when people start parts searching.  i am going to call for a correction of Canobi's post that kicked this off.,..

I should delete this post when post #95 is amended.

There are 3 types of WT

1- 16pin , no usb.
2- 28pin No usb
3- 28pin USB


no 32 pin versions.  and they vary from8mb - 32mb in memory.

I corrected post #97.
Title: Re: Arduino Lightsaber
Post by: Canobi on Jan 25, 2016, 04:12 pm
Post #95 also corrected.
Title: Re: Arduino Lightsaber
Post by: billpealer on Jan 25, 2016, 04:53 pm
anyone hear of /try  these?

Quads?  10W  supper high voltage and uses a single Lens not a tri lens.

http://www.ebay.com/itm/10w-Cree-XLamp-XM-L-RGBW-RGB-White-Color-LED-Emitter-4-Chip-20mm-Star-PCB-Board-/231519043679?hash=item35e79c405f:g:PWYAAOSwPhdVGPkT (http://www.ebay.com/itm/10w-Cree-XLamp-XM-L-RGBW-RGB-White-Color-LED-Emitter-4-Chip-20mm-Star-PCB-Board-/231519043679?hash=item35e79c405f:g:PWYAAOSwPhdVGPkT)

RGB+W  !?

Title: Re: Arduino Lightsaber
Post by: Protonerd on Jan 25, 2016, 05:07 pm
anyone hear of /try  these?

Quads?  10W  supper high voltage and uses a single Lens not a tri lens.

http://www.ebay.com/itm/10w-Cree-XLamp-XM-L-RGBW-RGB-White-Color-LED-Emitter-4-Chip-20mm-Star-PCB-Board-/231519043679?hash=item35e79c405f:g:PWYAAOSwPhdVGPkT (http://www.ebay.com/itm/10w-Cree-XLamp-XM-L-RGBW-RGB-White-Color-LED-Emitter-4-Chip-20mm-Star-PCB-Board-/231519043679?hash=item35e79c405f:g:PWYAAOSwPhdVGPkT)

RGB+W  !?


Yes Sir, one of my TCSS sabers use this. I also intend to use 2 of them in my upcoming saber staff (powered by Arduino of course :) ).
BTW, in the TCSS saber I used only RGB, W was left unconnected, since I did not need it. But with the added fleixibility of Arduino based electronics, I will in future. And only one lens, that is right.
Title: Re: Arduino Lightsaber
Post by: billpealer on Jan 25, 2016, 07:21 pm
Yes Sir, one of my TCSS sabers use this.
how's the brightness? heat? seams like 3500ma in the space where normally one LED lives is,..  cozy. tgtbt.
Title: Re: Arduino Lightsaber
Post by: Canobi on Jan 25, 2016, 08:28 pm
Hi guys

Just a quick update..

I was really busy this w/e as it was my son's 13th and had a whole lot going on and etching didn't get a look in. However, I did spot something I missed which would have been a problem, fixed it, and ended up with two distinct versions of the board in doing so.

There's now a low volt board for 3.7v~5v supplies and a high volt board for 6.5v~12v supplies.

The issue was with the micro boost buck, a 7.4v delivery would just go and let all the magic smoke out of it and there just wasnt room to stick in another component so replaced the boost buck with an LM1117 5v fixed regulator which instantly reclassified the circuit for high volt while retaining it's WT power rail flexibility.

The buck is still present on the original file so that became the low volt board, the only real change on that one was to removed the redundant power rail from the RAW pin.

Talking of which, the little space gained by removing said redundant power rails was used to increase the size of the bridging pads so they're easier to solder.

(http://i1225.photobucket.com/albums/ee395/Can-obi/IMG_20160125_095511.jpg) (http://s1225.photobucket.com/user/Can-obi/media/IMG_20160125_095511.jpg.html)
Title: Re: Arduino Lightsaber
Post by: JakeSoft on Jan 25, 2016, 09:38 pm
Hi guys

Just a quick update..

There's now a low volt board for 3.7v~5v supplies and a high volt board for 6.5v~12v supplies.

(http://i1225.photobucket.com/albums/ee395/Can-obi/IMG_20160125_095511.jpg) (http://s1225.photobucket.com/user/Can-obi/media/IMG_20160125_095511.jpg.html)
I like it and I think this makes more sense.
Title: Re: Arduino Lightsaber
Post by: stinky1 on Jan 25, 2016, 11:37 pm
Just another quick question about momentary switch ratings.

They come in 12v, 9v, 5v, 3v. prolly 6v too.   I plan to use two 18650 batteries.

So for a illuminated momentary switch,  what voltage rating do I use?

I know I need a resitor or a Dyna-Ohm to protect the LED.

Would 12 v be OK because it can handle all lower voltages?

Bought too long of a switch so I gotta get new one,  it was a 5v 16mm.

Neat it seems momentary,  and latching if you press it further.  Too bad it won't fit
in 1  1/4 sink pipe.

For that matter two 18650 are 1  7/16- 36mm wide, so they won't fit side by side in 1 1/4 pipe.
So they would have to be single stacked lengthwise.  Series or Parallel?

Now I see why the discussion on battery size. 
Title: Re: Arduino Lightsaber
Post by: billpealer on Jan 26, 2016, 04:16 am
Stink, are they the 16mm momentary switches?  If so i recomend the short barrel version. not the 32mm one,... The shorter one. And get 12v.  They can handle more than 12v.  They are like 12v 20amp.  That's liket 200 watt. These sabers... The Most will be 10 watt. 

Treat the LEDs on them like stand alone.  Blue/green 3.2v 50ma.  Red 2.5v  50ma.  Resistors for that.

Jake, I'm glad you can look at those pcbs and contribute to it.  It all looks like Tron to me.
Title: Re: Arduino Lightsaber
Post by: stinky1 on Jan 26, 2016, 05:13 am
Hey guys thanks for the fast response,  Ebay cart is awaiting.

Just to let you know I saw the RGB-W's as well,  but check these out!

http:/5x CREE XBD XB-D 9W white+red/red+green/Yello+green/RGB LED Light Emitter 7V/8V/www.ebay.com/itm/5x-CREE-XBD-XB-D-9W-white-red-red-green-Yello-green-RGB-LED-Light-Emitter-7V-8V-/222002233766?var=&hash=item33b05d41a6:m:mUmj13QzPcQeOcGyDw4a_1Q (http://www.ebay.com/itm/5x-CREE-XBD-XB-D-9W-white-red-red-green-Yello-green-RGB-LED-Light-Emitter-7V-8V-/222002233766?var=&hash=item33b05d41a6:m:mUmj13QzPcQeOcGyDw4a_1Q)

(http://i.ebayimg.com/images/g/gOMAAOSwFqJWoc7Z/s-l1600.jpg)

Only problem is its 5 of them minimum.   Nice for you multiple unit pro builders.  Still its like 18 dollas for 5! Not bad :)

And thanks,  you talked me out of making a battery pack,  the thought of them gassing out in a sealed tube,  the blade shooting into the ceiling etc etc... lol!!  2x sled mounted in removable battery holders I already have.   Then I can take them out and store them in steel box.  I always charge batteries in a porcelain sink so if they cook off all I get is gassed,  no fire.  Just don't turn on the tap!

 
Title: Re: Arduino Lightsaber
Post by: Protonerd on Jan 26, 2016, 10:47 am
how's the brightness? heat? seams like 3500ma in the space where normally one LED lives is,..  cozy. tgtbt.
So far no issues, but it sits on a sizable heat sink. As far as the max current is concerned, you probably never ever want to turn on all the LEDS at the same time with max current, anyway the brightness gain at half current and full is not that big.

I only have sporadic problems with the red die, I have a single protected 3.7V 18650 and occasionally my red config with blue FoC leads to a kind of reset, I assume from the protection circuitry, although the current of the red is rated 700mA (out of my head)? Blue and Green based configs do not experience this and the White one I do not use at all.
Title: Re: Arduino Lightsaber
Post by: jshaw on Jan 26, 2016, 08:38 pm
For those of you using clash and swing sensors (not accellerometers), what orientation do you use? Do you use multiple swing sensors? 

In my head, there should be one swing sensor that is vertical, and the clash sensor should be horizontal, facing perpendicular to the user. 
Title: Re: Arduino Lightsaber
Post by: billpealer on Jan 26, 2016, 09:23 pm
For those of you using clash and swing sensors (not accellerometers), what orientation do you use? Do you use multiple swing sensors? 
I found that 2 sensors in a cross and both 45 deg off of the horizontal and vertical axis (tipped forward 45 deg) works best.  when perfect vertical,.. the swing wont trigger till the saber is almost 180 degrees flat.  and a sensor perfectly horizontal, is too hard for the roller ball to rest at a state, so you may be holding the saber perfectly up and down, but the swing sound is going ape $h!t. this will give you triggers on swings, rolls, positions and guard change, and spins.
(http://forum.arduino.cc/index.php?action=dlattach;topic=261980.0;attach=152281)

I also did it like that to keep space tight. they are epoxied together. and then hot glued to the mass of parts in the hilt nerve center.

i have them in parallel on one pin. putting them on 2 pins did very little for sensitivity and accuracy. i use debounce switch code,.. so the roller ball can't fidget for less than 50 ms, and every swing command has a 200 ms delay.
Title: Re: Arduino Lightsaber
Post by: billpealer on Jan 26, 2016, 09:59 pm
Diagram for  1 CR123A batt No LED driver, no PWM, no regulators,. and blue or Green 3W LEDs.  SW-200 swing sensors.  Just a reminder, back in December, this was almost the exact set up being recommended by Jake for first time builds. He was into PWM color mixing/fading.   In all honestly.  FoC is probably cooler when using it.  For show, blade growth and recessions is neat.  when dueling it is ornate at best.  but for marketability, blade emission seems to be pretty important.
(http://forum.arduino.cc/index.php?action=dlattach;topic=261980.0;attach=152409)
Title: Re: Arduino Lightsaber
Post by: Kdot on Jan 28, 2016, 01:26 am
Long time reader, first time poster.

First off want to give a huge thank you to JakeSoft and billpealer, I started reading about all this when i think JakeSoft first posted in thecustomersabersshop. Been reading a lot and finally am getting started. I am using 5V Arduino Mini and 5V WT588D-16p. I have so far it coded to turn on and make turn on sound with a second of hum, and turn off with power down sound, with a momentary switch.

The part im having issues with is getting the Hum to repeat, or even play afterwards.

I can make startup loop with

WT588D_Send_Command(0); //Play sound 0
WT588D_Send_Command(0xF2); //Repeat sound


however if i add anything it doesnt play, nor does the repeat work for said sound.

Not sure what i am doing wrong. it is in the Loop section, using Jakesoft's recommended setup for the button using If, Else, and While.
Title: Re: Arduino Lightsaber
Post by: jshaw on Jan 28, 2016, 01:36 am
Long time reader, first time poster.

First off want to give a huge thank you to JakeSoft and billpealer, I started reading about all this when i think JakeSoft first posted in thecustomersabersshop. Been reading a lot and finally am getting started. I am using 5V Arduino Mini and 5V WT588D-16p. I have so far it coded to turn on and make turn on sound with a second of hum, and turn off with power down sound, with a momentary switch.

The part im having issues with is getting the Hum to repeat, or even play afterwards.

I can make startup loop with

WT588D_Send_Command(0); //Play sound 0
WT588D_Send_Command(0xF2); //Repeat sound


however if i add anything it doesnt play, nor does the repeat work for said sound.

Not sure what i am doing wrong. it is in the Loop section, using Jakesoft's recommended setup for the button using If, Else, and While.
Difficult to diagnose code without seeing it, but my guess would be an include in the wrong spot.
Title: Re: Arduino Lightsaber
Post by: JakeSoft on Jan 28, 2016, 01:49 am
Long time reader, first time poster.

The part im having issues with is getting the Hum to repeat, or even play afterwards.

I can make startup loop with

WT588D_Send_Command(0); //Play sound 0
WT588D_Send_Command(0xF2); //Repeat sound


however if i add anything it doesnt play, nor does the repeat work for said sound.

Not sure what i am doing wrong. it is in the Loop section, using Jakesoft's recommended setup for the button using If, Else, and While.
Hi, Kdot. Welcome to the party!

Try putting some short delays in between your WT588D_Send_Command() calls. Also, you can make the hum sounds repeat for "free" but adding extra hum sounds to the end of your ignition sound. A.K.A. "The lazy Pealer method"  (J/K, Bill!)  :)   :smiley-yell: It won't repeat forever if you do it that way, but if you add enough of them it'll go on long enough for practical purposes until you trigger as swing or a clash or turn it off.

Good luck. Keep us posted on your progress.
Title: Re: Arduino Lightsaber
Post by: Kdot on Jan 28, 2016, 04:01 am
Difficult to diagnose code without seeing it, but my guess would be an include in the wrong spot.

Thanks jshaw, I was figuring I was but tried all kind of spots with deifferent results. Haha thus the post. This is all very new to me but so far it has been successful challenge.
Title: Re: Arduino Lightsaber
Post by: Kdot on Jan 28, 2016, 04:42 am
Hi, Kdot. Welcome to the party!

Try putting some short delays in between your WT588D_Send_Command() calls. Also, you can make the hum sounds repeat for "free" but adding extra hum sounds to the end of your ignition sound. A.K.A. "The lazy Pealer method"  (J/K, Bill!)  :)   :smiley-yell: It won't repeat forever if you do it that way, but if you add enough of them it'll go on long enough for practical purposes until you trigger as swing or a clash or turn it off.

Good luck. Keep us posted on your progress.
Thanks for the welcome! Been great following everyone's progress.

I'll add a few hums at the end of sound on that part is working great.

I tried adding a delay equal to the time of start up sound and added hum, right after start up command.

Maybe wasn't long enough or maybe I'm reading the flow incorrectly.

Either way I'll get that section of code posted for further evaluation.

Title: Re: Arduino Lightsaber
Post by: Protonerd on Jan 28, 2016, 10:24 am
adding extra hum sounds to the end of your ignition sound. A.K.A. "The lazy Pealer method"  (J/K, Bill!)  :)   :smiley-yell: It won't repeat forever if you do it that way, but if you add enough of them it'll go on long enough for practical purposes until you trigger as swing or a clash or turn it off.
Haha, you can add my stamp there also. I'm using the same trick with the DFPlayer, cheers from the club of lazy humming-birds. It could be done cleaner, but this method is so much easier and quite robust!
Title: Re: Arduino Lightsaber
Post by: billpealer on Jan 28, 2016, 03:49 pm
Also, you can make the hum sounds repeat for "free" but adding extra hum sounds to the end of your ignition sound. A.K.A. "The lazy Pealer method"  (J/K, Bill!)  :)   :smiley-yell: It won't repeat forever if you do it that way, but if you add enough of them it'll go on long enough for practical purposes until you trigger as swing or a clash or turn it off.

Good luck. Keep us posted on your progress.
pfffff! i see how it is. i thought it was a brilliant! i would like to know how is the code that turns the on_sound on, then plays the hum sound,- is Different from the swing or clash tiggers, that play those sounds, then go back to hum.  and are we talking sw-200 swings,  or ADLX swings?  i just got my ADL's in too, i am excited to see what this things are about.

I use If/Else with Boolean for on, and off sounds.  Yes,  i don't have hum triggers at all in my saber, but i did try it.  I couldn't get hum to loop with the hex code. only play once. i don't know if I tried separating it with some delay tho...  and my swings and clashes are standard switch code,.. from,..  here.
https://www.arduino.cc/en/tutorial/switch (https://www.arduino.cc/en/tutorial/switch)
 i don't use the int = state.  just the if/else with the debounce time saved.  My variant of this code is posted here. it works pretty ok. i am not smart enough to make more complex code.
Title: Re: Arduino Lightsaber
Post by: Kdot on Jan 28, 2016, 03:59 pm
Here is the part of the code where i thought i should use the Hum Repeat Hex code:

void loop()

{

 if (digitalRead(button) == LOW) //button is pressed
 {
   if (saber_is_on) //Saber is on, so turn it off
   {
     WT588D_Send_Command(0x00); //off sound
     digitalWrite(LED, LOW);

     saber_is_on = false;
   }
   else //Saber is off, so turn it on
   {
    WT588D_Send_Command(0x02); //on sound
    digitalWrite(LED, HIGH);
 delay(4162); //Time is equal to start up sound plus one loop of hum
WT588D_Send_Command(0x01); //Hum Sound
WT588D_Send_Command(0xF2); // Repeat Previous Sound

     saber_is_on = true;
   }




This would just loop the Hum Sound and skip the Start sound.


I also tried after the on/off if statements, outside the void loop, and setting up it's own if statement as well as 'do' but no luck. Im not sure what is wrong, but 100% sure something is lol
Title: Re: Arduino Lightsaber
Post by: billpealer on Jan 28, 2016, 05:27 pm
revisions.


void loop()

{

if (digitalRead(button) == LOW) //button is pressed
{
  if (saber_is_on) //Saber is on, so turn it off
  {
    WT588D_Send_Command(0x00); //off sound
     delay(400);     // ADDED
    digitalWrite(LED, LOW);

    saber_is_on = false;
  }
  else //Saber is off, so turn it on
  {
   delay(80);  // don't ask just try it.  I have found waking up the WT, it needs a second to boot.
   WT588D_Send_Command(0x02); //on sound
    delay(10);
   digitalWrite(LED, HIGH);
delay(this needs to be JUST the time of the "on sound" if you plan to trigger a hum manually. not the total time with integrated hum); //capice?
WT588D_Send_Command(0x01); //Hum Sound
delay(5);  // gives the WT time to play the above command, and be ready to receive the next
WT588D_Send_Command(0xF2); // Repeat Previous Sound

    saber_is_on = true;
   }
 }
}
Title: Re: Arduino Lightsaber
Post by: Kdot on Jan 28, 2016, 05:37 pm
Just got home and going to give this a shot! This looks way more natural.

Im going to try and then report back! Thanks billpealer!
Title: Re: Arduino Lightsaber
Post by: billpealer on Jan 28, 2016, 05:39 pm
Just got home and going to give this a shot! This looks way more natural.

Im going to try and then report back! Thanks billpealer!
hit refresh, made a revision.
Title: Re: Arduino Lightsaber
Post by: Kdot on Jan 28, 2016, 05:57 pm
hit refresh, made a revision.
I am coming back with great success! Works amazing now! Stage 1 complete, now for swing and clash, this is where it looks like it get's fun. Working on a video right now, although excuse my mess.
Title: Re: Arduino Lightsaber
Post by: Kdot on Jan 28, 2016, 06:07 pm
Here is a sample video using low powered LED, will work on using High powered soon. Also a sample of my previous stunt saber, however just a picture.

Arduion Lightsaber V1 (http://www.youtube.com/watch?v=aXNsT2wXQ6Q)





Title: Re: Arduino Lightsaber
Post by: billpealer on Jan 28, 2016, 06:54 pm
I am coming back with great success! Works amazing now! Stage 1 complete, now for swing and clash, this is where it looks like it get's fun. Working on a video right now, although excuse my mess.
I watched the video.  bravo.  i now should ask your help.  I have never gotten my hum to loop.  but i also never added the 5ms delay after the on sound.  hmm..  i also think you may have too much decay in your hum.  you can fix it in Audacity.  the beginning of the hum needs to be on a neutral tone, and the end needs to be on the same neutral tone.  I do video production. (my day job). which also means i can produce audio.  audio clips often play the perfect sound once.  what you need is the sound in mid play, let it do it's cool Doppler like vrming and hrming,. then decay on the same sound it started on, but in middle play. open your clips in audigy and make sure the wave form looks identical at the beginning and end.  NO FLAT lines,..   some times simply copy/pasting the first 1/2 of the file, delete the second 1/2 of the sound,..  then paste the first 1/2 at the end, reverse it,. then cross blend (fade) it by 5 frames. This is also called mirroring.  Then remove the last 1/30th of a second of the end of the sound..- export.  now frame 1 of the audio will be what was deleted when you got rid of the tail 1/30th.  aka- a loop. you won't hear the click or tap at the loop replay.
Title: Re: Arduino Lightsaber
Post by: DJWing79 on Jan 28, 2016, 07:13 pm
A couple of bad prints, but will hopefully have a test soon. I found that Simplify3D allows me to create multiple processes during the print. I already printed one piece of my test...the majority of the handle is at 30% infill, but the screw threads and about 2mm below it are at 100% infill....hope this cinches it!
Title: Re: Arduino Lightsaber
Post by: billpealer on Jan 28, 2016, 07:40 pm
I really can't speak enough about adding hum in the WT to all of your audio triggers except for the off sound.  It is also about combat.
K-dot,  if you turn on your saber,.  you will have a 1/2 second delay till your arduino will accept a hum or clash.  Now you can turn it on, and immediately receive input from your swing or clash.  because your  code whould look like this if your hums were integrated.

  else //Saber is off, so turn it on
  {
   delay(80);  // don't ask just try it.  I have found waking up the WT, it needs a second to boot.
   WT588D_Send_Command(0x02); //on sound
    delay(5);
   digitalWrite(LED, HIGH);
    saber_is_on = true;
   }
You can turn it on and immateriality parry and pull a clash trigger.  LIKE A BOSS!

"You are unwise to lower your defenses." Darth Vader ROTJ

attacks Luke. Luke turns on his saber an in less than 8 frames from the on sound- has parried and is in Lock up.  8 frames is about 285ms.  It implies a light saber can forgo blade grow effect, and just be "ON."
Title: Re: Arduino Lightsaber
Post by: Kdot on Jan 28, 2016, 08:58 pm
I watched the video.  bravo.  i now should ask your help.  I have never gotten my hum to loop.  but i also never added the 5ms delay after the on sound.  hmm..  i also think you may have too much decay in your hum.  you can fix it in Audigy.  the beginning of the hum needs to be on a neutral tone, and the end needs to be on the same neutral tone.  I do video production. (my day job). which also means i can produce audio.  audio clips often play the perfect sound once.  what you need is the sound in mid play, let it do it's cool Doppler like vrming and hrming,. then decay on the same sound it started on, but in middle play. open your clips in audigy and make sure the wave form looks identical at the beginning and end.  NO FLAT lines,..   some times simply copy/pasting the first 1/2 of the file, delete the second 1/2 of the sound,..  then paste the first 1/2 at the end, reverse it,. then cross blend (fade) it by 5 frames. This is also called mirroring.  Then remove the last 1/30th of a second of the end of the sound..- export.  now frame 1 of the audio will be what was deleted when you got rid of the tail 1/30th.  aka- a loop. you won't hear the click or tap at the loop replay.
Thank you! A good portion of this code was provided by you so a huge thank you for that.

In the code you posted I think I ended up having to remove two } to get to to work. Kept telling me wt command want not defined this this scope.

I'll post it when I get in my lunch break!
Title: Re: Arduino Lightsaber
Post by: billpealer on Jan 28, 2016, 10:07 pm
Thank you! A good portion of this code was provided by you so a huge thank you for that.
Ha!  boy, are you in for some disappointment. :) thank jakesoft. seriously.

In the code you posted I think I ended up having to remove two } to get to to work. Kept telling me wt command want not defined this this scope.
i counted those curlies :)  and put the 3 at the end because they were needed.  you obviously have more code in your loop you must have inserted that to. for every open, you need  a close.  in the code you posted you had 4 open curlies.  doesn't that mean you need 4 total closed?  you only had one.  but i digress,..  let arduino debug it
Title: Re: Arduino Lightsaber
Post by: Kdot on Jan 28, 2016, 10:38 pm
Ok finally on lunch, so hear is the code that ended up working for me. I do notice that i cannot turn off the saber until the Hum starts. I think at this point probably would be best to add in Hum at the end, and think about dropping or do something different than looping it. Although definitely works! Probably needs a bit of refining and the //explanations may not always make sense at this point lol.


void loop()

{
 
  if (digitalRead(button) == LOW) //button is pressed
  {
    if (saber_is_on) //Saber is on, so turn it off
    {
      WT588D_Send_Command(0x00); //off sound
      delay(400); //Added
      digitalWrite(LED, LOW);

      saber_is_on = false;
    }
    else //Saber is off, so turn it on
    {
      delay(80);
      WT588D_Send_Command(0x02); //on sound
      delay(10);
      digitalWrite(LED, HIGH);
      delay(4160); //Just long enough for on sound
      WT588D_Send_Command(0x01); // HUM
      delay(5); //gives WT time to play the above
      WT588D_Send_Command(0xF2);

      saber_is_on = true;
    }

  delay(100); //de-bounce it a little
  while (digitalRead(button) == LOW) {} //Wait for them to let off the button
}
if (reading == LOW && previous == HIGH && millis() - time > debounce) {
  if (state == HIGH)
    state = LOW;
  else
    state = HIGH;
  WT588D_Send_Command(0x00);
  time = millis();
}

previous = reading;
}



Title: Re: Arduino Lightsaber
Post by: JakeSoft on Jan 29, 2016, 01:14 am
Here is a sample video using low powered LED, will work on using High powered soon. Also a sample of my previous stunt saber, however just a picture.

Arduion Lightsaber V1 (http://www.youtube.com/watch?v=aXNsT2wXQ6Q)

Looking good! And wow, I think that's the fastest I've seen anyone go from noob to prototype. And in a hilt, no less!
Title: Re: Arduino Lightsaber
Post by: billpealer on Jan 29, 2016, 01:16 am
dude. why the 4000 ms delay?  you cant clean that up?  that is the reason you can't turn it off.  a delay command pauses the whole arduino from further processing, or I/O.

What is the play time in ms of JUST the on sound?  ... that number can be put in the delay after the on sound.  4.1 seconds of delay is,  your prerogative, but......
Title: Re: Arduino Lightsaber
Post by: billpealer on Jan 29, 2016, 04:32 am
Haha, you can add my stamp there also. I'm using the same trick with the DFPlayer, cheers from the club of lazy humming-birds. It could be done cleaner, but this method is so much easier and quite robust!
the only way cleaner is ONE COMPOSED FILE.  which won't work.  if there is a way to have ambient hum follow the trigger sounds,. i am all ears!  get it!? sounds?  ears!?

i am currently composing a new sound.    "clash decay'  i will get lock up with no buttons to work.  my guess is people who have tried it, tried to do it with software, instead of sound composition,

i have a fundamental question,  if one were to parry (clash) and NOT lock up,.  (bouncing parry or a beat)  would every clash sound be followed by a swing?

so,..  clash,swing,hum,..

if you were to hold the saber still, and your opponent would repeatedly smack your blade, and you would not move,. that should be...  clash,.. hum. (normal clash)  i don't think that could be done in active combat,. only choreography or geek foreplay.
Title: Re: Arduino Lightsaber
Post by: JakeSoft on Jan 29, 2016, 05:08 am
the only way cleaner is ONE COMPOSED FILE.  which won't work.  if there is a way to have ambient hum follow the trigger sounds,. i am all ears!  get it!? sounds?  ears!?

i am currently composing a new sound.    "clash decay'  i will get lock up with no buttons to work.  my guess is people who have tried it, tried to do it with software, instead of sound composition,

i have a fundamental question,  if one were to parry (clash) and NOT lock up,.  (bouncing parry or a beat)  would every clash sound be followed by a swing?

so,..  clash,swing,hum,..

if you were to hold the saber still, and your opponent would repeatedly smack your blade, and you would not move,. that should be...  clash,.. hum. (normal clash)  i don't think that could be done in active combat,. only choreography or geek foreplay.
I'm sure there are schools of thought on this. (Or maybe not... who except us would spend so much time thinking about this?! haha!) Personally, I don't like my clash sounds being interrupted by anything, so I let them play out fully before allowing swing sounds to happen again. I think the toy lightsabers and MR boards work the same way.

But hey, that's the joy of building your own board. You can make it work the way YOU want it to.
Title: Re: Arduino Lightsaber
Post by: Kdot on Jan 29, 2016, 05:12 am
Looking good! And wow, I think that's the fastest I've seen anyone go from noob to prototype. And in a hilt, no less!
Thanks! You really motivated me! Never would have thought this to be possible
Title: Re: Arduino Lightsaber
Post by: Kdot on Jan 29, 2016, 05:44 am
dude. why the 4000 ms delay?  you cant clean that up?  that is the reason you can't turn it off.  a delay command pauses the whole arduino from further processing, or I/O.

What is the play time in ms of JUST the on sound?  ... that number can be put in the delay after the on sound.  4.1 seconds of delay is,  your prerogative, but......
Ha yeah about that, i reprogrammed my WT with some new sounds and last minute i realized the start up sound was like 19xx ms and the hum was a little over 2000ms. Working find a sound i like, so i can spend a little more time with the audio files themselves.

I also removed the Hum from the start up sound, it wasnt terrible, however there was a slight click between the Startup to Hum, reduced delay and it got smaller, but wondering if that could be cleaned up in the audio side for slightly smoother transition like you mentioned before.

Title: Re: Arduino Lightsaber
Post by: billpealer on Jan 29, 2016, 02:55 pm
, but wondering if that could be cleaned up in the audio side for slightly smoother transition like you mentioned before.
if you don't want to marry sounds in the the WT playlist,..
one way to cheat seamless playback (this is old school) with arduino commands is fades to near silence. (but i think if you use the WT-28pin-U and a 16mhz arduino, the gaps for commands to the WT are ... 2ms?  I think i read that back on like page 7 or 9.  Back there somewhere. Jake and Illuis were talking about it. Jake?  2ms?  do you actually trigger hum? or do you marry it too in your MKIII+ versions?  What ever happened to Illuis?  He is the 1 Line Serial Mode Guy! He must be a coder and not a saber builder.
anyway...
have all sounds fade DOWN to almost silence at the end,  make your own hum cycle in audigy, (maybe a 6 second total file) then a fade to near silence at the end. export. when the sound loops,.  or really plays after your ON, SWING, OR CLASH,.. it will have little to no "taps" tween sound files.  Just make sure your ON, SWING, and CLASH, all fade down at the end of the clip. a 10-15 frame fade is all that is needed. if need be i can post an audacity tute on how to do this. or if anyone has adobe premier, or elements, or sony vegas, imove, final cut,.. PM me, i will talk u thru it. if you sound edit in pro software, you will have to master in Audigy, for the 22khz audio.  in the audio world there really is only 22,050 Hz sample rate.  but the WT can't use that rate. It needs 22,000 hz exactly.  the 50 throws it off.  That set me back a week actually. I was like,.  "i don't need BS hackware Audacity.  I'll just use my $4,000 Adobe Suite."  Nope.  All my pro audio packages won't let me make audio to that sample rate.  Because it is a junk rate- 22,050 is 1/2 CD PWM audio sample.  44.1khz.  20,000hz is,..  well..  nothing. it's just an arbitrary rate the WT accepts. Most likely a goof up in the firmware code.  it should be taking 20,050hz.
Also, all this sound triggering that we do with the WT from what i am learning this is the difference tween "sound fonts" and "sound files". A sound font is one file with all the sounds in it.  The MCU just tells the player module WHERE to play and end (like a vinyl record).  where as in the WT which plays files not fonts,...  just triggers the uploaded file or playlists to play (like a CD).  You can't in the WT tell it to play clip 1 ( a 20 second clip)  from second 3-7 and loop it. If you download a sound font file, you have to chop it up in Audacity.  make sure you slice where it loops :)

Jake did you buy your audio?
Title: Re: Arduino Lightsaber
Post by: Protonerd on Jan 29, 2016, 03:40 pm
I for one buy my audio, if you mean the sound fonts. BTW, sound font is the "saber world" seems to be the term used for all the sound files associated with saber sounds (swings, clahes, pon, poff etc.), but each of these sounds is in a different file.

http://www.saberfont.com/

Some of the sound fonts I bought from this site, some of them I inherited from my non-DIY saber electronics.
Title: Re: Arduino Lightsaber
Post by: JakeSoft on Jan 29, 2016, 03:44 pm
I for one buy my audio, if you mean the sound fonts. BTW, sound font is the "saber world" seems to be the term used for all the sound files associated with saber sounds (swings, clahes, pon, poff etc.), but each of these sounds is in a different file.

http://www.saberfont.com/

Some of the sound fonts I bought from this site, some of them I inherited from my non-DIY saber electronics.

Also checkout fan film sites. They often provide sound effects for free. I composed a sound font from several unlicenced, free-to-use sources. For example: http://theforce.net/fanfilms/postproduction/soundfx/saberfx_fergo.asp (http://theforce.net/fanfilms/postproduction/soundfx/saberfx_fergo.asp).
Title: Re: Arduino Lightsaber
Post by: jshaw on Jan 29, 2016, 03:46 pm
I found a decent set of lightsaber sound fonts here: https://www.freesound.org/people/joe93barlow/packs/5968/?page=2#sound

Need to edit them to the right sampling rate in Audacity, but they work ok.  I'm still playing w/ them to get rid of the tap sound though.
Title: Re: Arduino Lightsaber
Post by: JakeSoft on Jan 29, 2016, 03:50 pm
I found a decent set of lightsaber sound fonts here: https://www.freesound.org/people/joe93barlow/packs/5968/?page=2#sound

Need to edit them to the right sampling rate in Audacity, but they work ok.  I'm still playing w/ them to get rid of the tap sound though.
I found these while searching once a while back. They seem good, but I don't want to create an account just to download something that is supposed to be free. I hate it when sites do that.
Title: Re: Arduino Lightsaber
Post by: marconchr on Jan 29, 2016, 04:00 pm
As someone who is totally new to arduino, would you be willing to share some of your code to help me with making the sounds, I don't think I will have any problems with the LED's but it would be nice to get some more info on the sound code.
Title: Re: Arduino Lightsaber
Post by: Kdot on Jan 29, 2016, 07:55 pm
As someone who is totally new to arduino, would you be willing to share some of your code to help me with making the sounds, I don't think I will have any problems with the LED's but it would be nice to get some more info on the sound code.
I just spent the last week or so on the code. Its all in the forum thanks to some great people on here. This is not a copy paste kind of project, the code typically has why you doing something and what it is for. But it always depends on what you are using hard ware wise.
Title: Re: Arduino Lightsaber
Post by: billpealer on Jan 29, 2016, 08:00 pm
As someone who is totally new to arduino, would you be willing to share some of your code to help me with making the sounds, I don't think I will have any problems with the LED's but it would be nice to get some more info on the sound code.
read pages 1-13. it's covered.  if you want to synth your own sounds,...  grab a mic, get some samples,. download Audacity and play.  ah crud, i been saying audigy all this time.  wonderful.  Audacity! why did that just come to me?
Title: Re: Arduino Lightsaber
Post by: Kdot on Jan 29, 2016, 08:03 pm
@billpealer and JakeSoft

Managed to work out out the very noticeable click sound. I ended up purchasing sound fonts from saberfonts last night as the other fonts from ultrasaber where 1 not what i was wanting and 2 not clean sounding to me. Still ended up having a click, but found it was in the font itself so just removed it and much smoother.

Personal tip: Dont forget to re compile the BIN file in the WT program LOL

Also changed the code a little bit to reduce delay time. Right now it is right around 1.7 of delay before it will accept any new trigger, but im ok with that for now as i want to always make it through the power on sound before power off. I used the do...while code, so i can start the delay for the hum upon saber_is_on

Only thing im still trying to get through but may just add a swing sound on power up, but you can hear a noticable pause before the startup and hum triggers. Adjust the delay gets it closer so might have to spend an hour just adjusting it by 0001 ms lol. Although i think what you mentioned before billpealer about tail end will need to be adjusted

http://www.youtube.com/watch?v=GhXbPnGdQCkNew Setup (http://www.youtube.com/watch?v=GhXbPnGdQCk)
Title: Re: Arduino Lightsaber
Post by: billpealer on Jan 29, 2016, 08:03 pm
I found these while searching once a while back. They seem good, but I don't want to create an account just to download something that is supposed to be free. I hate it when sites do that.
amen,
Title: Re: Arduino Lightsaber
Post by: billpealer on Jan 29, 2016, 08:14 pm
@billpealer and JakeSoft

Managed to work out out the very noticeable click sound. I ended up purchasing sound fonts from saberfonts last night as the other fonts from ultrasaber where 1 not what i was wanting and 2 not clean sounding to me. Still ended up having a click, but found it was in the font itself so just removed it and much smoother.


http://www.youtube.com/watch?v=GhXbPnGdQCkNew Setup (http://www.youtube.com/watch?v=GhXbPnGdQCk)
I LIKE IT!!!!
Title: Re: Arduino Lightsaber
Post by: Kdot on Jan 29, 2016, 08:43 pm
I LIKE IT!!!!
Thanks!

This is just spit balling here, but my plan is to be able to use the some other command TBD lol for clash and swing, and then be able to just continue with the hum and if it repeat, that way it will always repeat hum, unless it picks up the other sensors.
Title: Re: Arduino Lightsaber
Post by: billpealer on Jan 29, 2016, 09:52 pm
Thanks!

This is just spit balling here, but my plan is to be able to use the some other command TBD lol for clash and swing, and then be able to just continue with the hum and if it repeat, that way it will always repeat hum, unless it picks up the other sensors.
fuggin- A.  try it!
Title: Re: Arduino Lightsaber
Post by: JakeSoft on Jan 30, 2016, 12:23 am
@billpealer and JakeSoft

http://www.youtube.com/watch?v=GhXbPnGdQCkNew Setup (http://www.youtube.com/watch?v=GhXbPnGdQCk)
Nice! It looks like you've worked out the basics. And thank you for sharing video! I wish more would take video of their progress. It's satisfying to watch how the process plays out for others.
Title: Re: Arduino Lightsaber
Post by: Kdot on Jan 30, 2016, 04:02 am
Nice! It looks like you've worked out the basics. And thank you for sharing video! I wish more would take video of their progress. It's satisfying to watch how the process plays out for others.
Wel thank you guys again for paving the way!

Final video will be better quality but I figure just something for referenced. Hopefully it motivates someone else to get started. Knew nothing about programming although had some prior knowledge of LEDs and resistors.

I got the rest of the parts in last week for swing and clash. Also bought an Axcelerametor to play with
Title: Re: Arduino Lightsaber
Post by: grey3Dx on Jan 31, 2016, 04:06 am
Hello everyone, ive been following the adventures of Jakesoft and the inexpensive lightsaber for a year now, and have also been attempting to construct my own based on this forum. I am generally just a lurker and dont usually participate in the conversation, but this forum is very educational for me, and I wanted to thank everybody for their input.


Here is the saber I have been working on.


(http://forum.arduino.cc/index.php?action=dlattach;topic=261980.0;attach=152930)

I am using a chinese Arduino Pro Micro, a WT588D, and an MPU6050 accelerometer mounted to a piece of solderable perfboard. The Pro Micro and WT are mounted to headers for easy removal and so the connections can run under them. I have a Luxeon TriRebel and 3 flashlight style constant current LED drivers. I got a small piece of copperclad and using my dremel i cut the traces for the surface mount mosfets i had. It will be powered by 2 18650s that i scrounged from an old laptop battery.
(http://forum.arduino.cc/index.php?action=dlattach;topic=261980.0;attach=152932)
(http://forum.arduino.cc/index.php?action=dlattach;topic=261980.0;attach=152934)
I am currently still trying to get the code sorted out but its working to some degree. I am an artist by trade and its been quite a challenge to teach myself how to code, even with the supposed simplicity of the arduino language.
Title: Re: Arduino Lightsaber
Post by: Canobi on Jan 31, 2016, 02:57 pm
I came across this intersting variant of the WT588D-16p while sourcing more stable and direct suppies for my boards:

(http://i1225.photobucket.com/albums/ee395/Can-obi/IMG_20160131_121830.jpg) (http://s1225.photobucket.com/user/Can-obi/media/IMG_20160131_121830.jpg.html)

The details page link was broken so dont know mem size but I did send a query about it and now waiting for the reply.

I've not seen a match from any other vendor so it must be manufacturers own take on it.

I like the pin labelling, would make them easy to work with for the absolute novice and would be handy for prototyping purposes. However, not sure why it deserves an $11 price tag though.
Title: Re: Arduino Lightsaber
Post by: billpealer on Jan 31, 2016, 03:51 pm
Hello everyone, ive been following the adventures of Jakesoft and the inexpensive lightsaber for a year now, and have also been attempting to construct my own based on this forum.
I am currently still trying to get the code sorted out but its working to some degree. I am an artist by trade and its been quite a challenge to teach myself how to code, even with the supposed simplicity of the arduino language.
Looks rad. let me know how you make out pwm color mixing with MOSFET and the drivers.  that  jammed me up.
Title: Re: Arduino Lightsaber
Post by: JakeSoft on Jan 31, 2016, 07:07 pm
Hello everyone, ive been following the adventures of Jakesoft and the inexpensive lightsaber for a year now, and have also been attempting to construct my own based on this forum. I am generally just a lurker and dont usually participate in the conversation, but this forum is very educational for me, and I wanted to thank everybody for their input.
...
Welcome and thanks for sharing! Intentional or not, your design looks like a unique blend of my design and that of Protonerd. Keep us posted on your progress. It looks like you are well on your way.
Title: Re: Arduino Lightsaber
Post by: JakeSoft on Jan 31, 2016, 07:14 pm
I came across this intersting variant of the WT588D-16p while sourcing more stable and direct suppies for my boards:

(http://i1225.photobucket.com/albums/ee395/Can-obi/IMG_20160131_121830.jpg) (http://s1225.photobucket.com/user/Can-obi/media/IMG_20160131_121830.jpg.html)

The details page link was broken so dont know mem size but I did send a query about it and now waiting for the reply.

I've not seen a match from any other vendor so it must be manufacturers own take on it.

I like the pin labelling, would make them easy to work with for the absolute novice and would be handy for prototyping purposes. However, not sure why it deserves an $11 price tag though.
Hey, that is nice. Probably the price tag is because it's a custom PCB or something and only they sell it that way.

I actually e-mailed Waytronic (the China-based OEM of the WT588D chips) about a year ago to ask some questions and much to my surprise they actually responded. Throughout our discourse, they made it known that they are willing to sell direct. I didn't pursue that avenue, as I can find them dirt cheap on Ebay already, but if you had a sizable order I wonder if they would be willing to ship some modules without the pins. I also don't know what kind of payment they except or any of those logistical details.
Title: Re: Arduino Lightsaber
Post by: Protonerd on Jan 31, 2016, 10:04 pm
Just wondering: anyone ever used the Timer(s) of the Atmega for his/her saber project? It occurred to me the other day while wondering how I could reduce the number of variables used in my code (I'm living on the edge, one false move and the code collapses...) that these uCs have Timers, maybe they could be used to track events and/or enable for instance new swing/clash triggers only if a certain time has passed since the last such event.
Title: Re: Arduino Lightsaber
Post by: stinky1 on Feb 01, 2016, 09:35 am
Ohh bam found this,  somewhere in Step 15 I believe it shows the commands
for switch triggering PWM color changes.  Please note,  its the last step,  so understanding
what is before it would help your comprehension!!!


Beginner Arduino Primer (http://www.instructables.com/id/Beginner-Arduino/?ALLSTEPS)

I have already picked out the colors I want from playing around with this site:

RGB Color Codes Chart (http://rapidtables.com/web/color/RGB_Color.htm)


Nice DFPlayer Mini MP3-TF-16P tutorial

Arduino - Test DFPlayer Mini MP3 Module (http://stonez56.blogspot.tw/search?updated-max=2015-04-06T07:13:00-07:00&max-results=3&start=3&by-date=false)

Note he also he has a remote  phone control colors primer too.
Title: Re: Arduino Lightsaber
Post by: billpealer on Feb 02, 2016, 04:33 pm
Battery replacement in V1 Predates TIE Chassis concept.

https://youtu.be/eZC2iCyDKdg (https://youtu.be/eZC2iCyDKdg)
Title: Re: Arduino Lightsaber
Post by: JakeSoft on Feb 03, 2016, 02:03 am
Battery replacement in V1 Predates TIE Chassis concept.

https://youtu.be/eZC2iCyDKdg (https://youtu.be/eZC2iCyDKdg)
Selling it, Bill? Looks like a how-to for an end user.
Title: Re: Arduino Lightsaber
Post by: grey3Dx on Feb 03, 2016, 05:14 am
Im having issues with controlling the playback of sounds on the WT588D. Is there a code solution that would allow a sound to play and keep playing as long as a button was HIGH but stopped that sound as soon as the button went LOW? (or vise versa). I guess what i really need to know is how to trigger a sound from outside the main loop.

currently my AUX button (the one for the 'lockup') constantly restarts the sound over and over.
im running  the WT in one-line serial mode. Do i need to have the WTs BUSY pin wired to make that work?

here is the code im using for the button.

const int WT588D_SDA = 9; //Module pin "P03" or pin # 10
const int AUX_BUTTON = 1;
const int BLADE_LED_AUX = 5; // led for flashes


int aux = 0;         // variable for reading the pushbutton status

void setup() {
  Serial.begin(9600);
  // initialize the LED pin as an output:
  pinMode(BLADE_LED_AUX, OUTPUT);
  // initialize the pushbutton pin as an input:
  pinMode(AUX_BUTTON, INPUT_PULLUP);
  pinMode(WT588D_SDA, OUTPUT);
  digitalWrite(WT588D_SDA, HIGH);
}

void loop() {
  // read the state of the pushbutton value:
  aux = digitalRead(AUX_BUTTON);

  // check if the pushbutton is pressed.
  // if it is, the state of the button is LOW:
  if (aux == LOW) {
    // turn LED on:
    digitalWrite(BLADE_LED_AUX, HIGH);
    WT588D_SendAudio (0x07);
    Serial.println("LED_ON");
  } else {
    // turn LED off:
    digitalWrite(BLADE_LED_AUX, LOW);
    Serial.println ("LED_OFF");
  }
}


void WT588D_SendAudio(byte addr){
 
    digitalWrite(WT588D_SDA, LOW);
    delay(5);
    for(int i = 0; i < 8; i++)  {
        digitalWrite(WT588D_SDA, HIGH);
        if bitRead(addr,i)   {
            delayMicroseconds(600);
            digitalWrite(WT588D_SDA, LOW);
            delayMicroseconds(200);
        }
        else {
            delayMicroseconds(200);
            digitalWrite(WT588D_SDA, LOW);
            delayMicroseconds(600);
       }
    }
    digitalWrite(WT588D_SDA, HIGH);
    delay(10);
   
   
}

Anybody have suggestions?
Title: Re: Arduino Lightsaber
Post by: billpealer on Feb 03, 2016, 03:13 pm
Selling it, Bill? Looks like a how-to for an end user.
nope.  not selling it. syntax error. I  sold it. if you love it, let it go. After I made my first TCSS with a Hasbro sound board, i discovered this thread days later. So i sold that saber.  It was on ebay for 17 hours before being picked up.  Now the goal was to sell the first couple..  to break even on the main 2 that i keep for myself.  The real difficulty was to get the V1 to a point were it was durable, reliable, and sexy enough for sale. took a couple tear downs, re-soldering, re epoxying.  But i got it.  A major hurdle was figuring out how to take it apart and put it back together with out twisting the wires to oblivion. it finally occurred to me,. start with the blade holder, and work down.  perfect.  I did the same for my vintage BMX's.  Refurb a couple..  sell em.  pay for the good ones. Hobbyists often say things like "it's an expensive hobby, you get what you pay for."  Or "It's a Hobby, no one ever said it would be cheap." I say,..  you gotta invest to make money. Do it right and you'll never have to pay a cent for a hobby again.  or pay waaaaaay less than most.  Helps to be a bit of a MacGyver. My next set will be a semi matching sith / jedi dueling pair.  then no more selling. Just my Brass super saber.  anyone have a chunk of brass tube with an ID of 1.5"?

My next obsession will most likely be a light sensing optic with relay, to toggle tween my grid tied solar panels and my battery back up.  Right now it is on a 220v Jacuzzi timer, and if it was light based instead of time based, it would be more efficient.
Title: Re: Arduino Lightsaber
Post by: billpealer on Feb 03, 2016, 03:19 pm
Im having issues with controlling the playback of sounds on the WT588D. Is there a code solution that would allow a sound to play and keep playing as long as a button was HIGH but stopped that sound as soon as the button went LOW? (or vise versa). I guess what i really need to know is how to trigger a sound from outside the main loop.

currently my AUX button (the one for the 'lockup') constantly restarts the sound over and over.
im running  the WT in one-line serial mode. Do i need to have the WTs BUSY pin wired to make that work?

Anybody have suggestions?
i would change the code to use a bool (love that Jake). and push the button for Send_Sound_Command followed b a loop command,..

second button push for turn off.

The only reason i rec that, is because i know how to do it, and know that it would work.  not because it is better.
Title: Re: Arduino Lightsaber
Post by: DJWing79 on Feb 04, 2016, 02:07 am
Hey Jakesoft, have you ever tried using buckpucks with an arduino for your lightsaber? I am thinking about going to the 7.4V battery so I can power the DFPlayer and didn't want to fry my leds
Title: Re: Arduino Lightsaber
Post by: JakeSoft on Feb 04, 2016, 02:53 am
Hey Jakesoft, have you ever tried using buckpucks with an arduino for your lightsaber? I am thinking about going to the 7.4V battery so I can power the DFPlayer and didn't want to fry my leds
Nope, never tried it. I always thought they were too expensive for what they are, but I'd think you are more likely to fry your LEDs using direct drive with a FET the way I do it than you would with a buck-puck that will limit current on it's own.
Title: Re: Arduino Lightsaber
Post by: DJWing79 on Feb 04, 2016, 06:29 am
I have a 700 ma buckpuck that I am going to test this weekend. it has a pin for control, which I believe goes to the arduino pin so it's a regulator and fet....I think....
Title: Re: Arduino Lightsaber
Post by: Protonerd on Feb 04, 2016, 10:14 am
I have a 700 ma buckpuck that I am going to test this weekend. it has a pin for control, which I believe goes to the arduino pin so it's a regulator and fet....I think....
The higher-end Plecter Lab boards also have a current regulator for the main LED drive, but it's all integrated on their quite small boards, so I guess current regulation can be done with a smaller form factor than a buckpack, but alas I do not know how this feature on them boards work...
I'm now going into the direction of using a single 3.7V supply and try to supply the Arduino board with a DC-DC pushing up the voltage from 3.7V to 5V.

As to the DFPlayer, I still did not give up to make it work from 3.7V battery, but I need a couple of days more to try it out. But in the meantime, please do try the buckpuck, it's one more piece of HW this community evaluates and that enriches the work of us all!
Title: Re: Arduino Lightsaber
Post by: billpealer on Feb 04, 2016, 03:02 pm
I have a 700 ma buckpuck that I am going to test this weekend. it has a pin for control, which I believe goes to the arduino pin so it's a regulator and fet....I think....
i don't think it works like that. be carefull.  the default way this thing works is a Vin = Vout.  as the cut sheet states AND TCSS explains,  7v in would drive 1 Luxeon 3.4v LED at 700ma.  more Vin would bring it up.  7.4 ,..  8.2v.  most fully charged liths push 4.1 or 4.2v when the charger cuts out.  that would be 8.4v.  i think that would make the buck push 5v to the LED at 700ma.  you may not fry the LED off the bat, but it will die sooner than it should.  i think some buckpucks have PWM control. make sure you got that one.  Some have analog (potentiometer) some have digital control for strobe, and on/off. i think by trade it is called "PWM dimming".  Google "PWM dimming Luxdrive" . you know,... or not.  i often need to bench test, because reading has proven just wrong.  hence driving a blue luxeon from a single lith with NO RESISTOR whatsoever. and it looks fine, works perfect.  no where on the googles did it say that was a thing.  but it is.
Title: Re: Arduino Lightsaber
Post by: JakeSoft on Feb 04, 2016, 06:13 pm
i don't think it works like that. be carefull.  the default way this thing works is a Vin = Vout.  as the cut sheet states AND TCSS explains,  7v in would drive 1 Luxeon 3.4v LED at 700ma.  more Vin would bring it up.  7.4 ,..  8.2v.  most fully charged liths push 4.1 or 4.2v when the charger cuts out.  that would be 8.4v.  i think that would make the buck push 5v to the LED at 700ma.  you may not fry the LED off the bat, but it will die sooner than it should.  i think some buckpucks have PWM control. make sure you got that one.  Some have analog (potentiometer) some have digital control for strobe, and on/off. i think by trade it is called "PWM dimming".  Google "PWM dimming Luxdrive" . you know,... or not.  i often need to bench test, because reading has proven just wrong.  hence driving a blue luxeon from a single lith with NO RESISTOR whatsoever. and it looks fine, works perfect.  no where on the googles did it say that was a thing.  but it is.
He might be OK insofar as he won't cook anything. I seem to remember from an electronics course I took some years ago that it's not voltage that fries things, it's current. If the buck puck is limiting current to be within spec of the LED then the input voltage doesn't really matter as long as he is keeping it within the spec of what the buck puck can handle.

If the buck-puck says it can take 5V to 12V and will regulate current to 700ma, then you should be able to supply anything in that range and it'll still put out exactly 700ma and not fry the LED.
Title: Re: Arduino Lightsaber
Post by: billpealer on Feb 04, 2016, 07:53 pm
He might be OK insofar as he won't cook anything. I seem to remember from an electronics course I took some years ago that it's not voltage that fries things, it's current. If the buck puck is limiting current to be within spec of the LED then the input voltage doesn't really matter as long as he is keeping it within the spec of what the buck puck can handle.
If the buck-puck says it can take 5V to 12V and will regulate current to 700ma, then you should be able to supply anything in that range and it'll still put out exactly 700ma and not fry the LED.
Tho i  must admit i have no class to fall back on... (i'll just softball that one in)
I think it's BOTH man. Power... ie. heat,.. 100 watts is 100watts no matter if its the V or A that gets you there.

Pretty sure Watts will fry it.  which is why LEDs are rated in watts.  3.4v and 900ma LED is a 3W LED.  5.1v and 900ma -a 5W LED (they make em)  3.4v and 700ma is under powered for a Blue Rebel, by a tad,..  5+v and 700ma is 3.6 Watts,..  yeah it may not fry it,. but it will almost surely reduce its life cycle, and maybe even REDUCE its lumens due to temp.  more temp = more resistance.  more resistance = less current drawn. less current = less lumens.. viscous cycle.   I think diodes fry on watts,..  BUT still need the min voltage to traverse the diode (i think).  so a 3w blue rebel 2.5v and 10 amp,..  will not fry it. And i may be wrong.  there is prolly more than one "type" of damage.  3v and 2 amp will,.  or soon will.  or will cut the life by half,..  Anyone willing to cook an LED to find out?

 i for one like to ruin stuff just to know what the real deal is. anyone want to donate an LED?  for example..  i know 3.65v and 750ma is darn bright on the Blue Rebel, and had it going to 5 min with no damage to report.  but i could not get PWM control with said LED buck driver.  i got one coming in the mail tho! 3.65v and .75A is well under the 3W rating of the blue rebel.
Title: Re: Arduino Lightsaber
Post by: wailer on Feb 04, 2016, 11:22 pm
Hello fellow builders,

I have been following this thread with great interest and decided to equip my homebuild saber with sound (finaly).
Received parts yesterday so i can start building...

My question to JakeSoft, have you ever posted your your completed arduino code (with 335 swing sensor)?
Title: Re: Arduino Lightsaber
Post by: DJWing79 on Feb 05, 2016, 12:01 am
I saw a video where with a specific model of buck-puck ( 3023-D-E-1000) you can drive an LED at 1000 ma and use the PWM pin from arduino connected to its control pin (on the buck) to dim the LED up and down. I need to find my second 3.7v battery to test...will let you know. btw, the blade test on the 3D printed holder worked! It was just the holder and a small handle piece, but with 100% infill around the threads (and a little before and after to absorb shock) and 35% infill for the rest of the unit, it held up to many many hard hits..i'd post pics but the problem I had was I made the diameter of where the blade goes in too loose so I had a little bit of a wobble and I forgot to grease the threads so I can't unscrew it now...dang it's tight!  Once I have the electronics dimensions set, I will know how big to make my sled and then from there how big my minimums need to be for the saber and then will print out a true test saber and will take lots of pics and maybe a video for you guys. Simplify3D for the win....just make sure you turn off retraction....found that out the hard way.
Title: Re: Arduino Lightsaber
Post by: billpealer on Feb 05, 2016, 12:44 am
Hello fellow builders,

I have been following this thread with great interest and decided to equip my homebuild saber with sound (finaly).
Received parts yesterday so i can start building...

My question to JakeSoft, have you ever posted your your completed arduino code (with 335 swing sensor)?

LOL.  spoiler alert.
Title: Re: Arduino Lightsaber
Post by: billpealer on Feb 05, 2016, 12:53 am
I saw a video where with a specific model of buck-puck ( 3023-D-E-1000) you can drive an LED at 1000 ma and use the PWM pin from arduino connected to its control pin (on the buck) to dim the LED up and down. I need to find my second 3.7v battery to test...will let you know.
word.  thanks.  pwm will surely drop the vf. if that is the same model I read on.  pwm 100% = full off 0 volts.  make sure you don't think it's the opposite like a MOSFET.
Title: Re: Arduino Lightsaber
Post by: JakeSoft on Feb 05, 2016, 01:10 am
Hello fellow builders,

I have been following this thread with great interest and decided to equip my homebuild saber with sound (finaly).
Received parts yesterday so i can start building...

My question to JakeSoft, have you ever posted your your completed arduino code (with 335 swing sensor)?

I prefer to teach people how to fish.
Title: Re: Arduino Lightsaber
Post by: billpealer on Feb 05, 2016, 02:16 am
I prefer to teach people how to fish.
all fainess.  this is a gallery thread.  you never had to do anything after you dropped the mic.  all the stuff you got going on with your led color mixing, menus, and audio is insane.  I almost went all in and tried the mkIII clone.  then I thought... Obiwan never changed colors, all clash is yellow or white flash in the films and sound is not tunable on these mystical weapons .   good enough for me.  and my expectations got managed just right. 

still waiting for you (anyone) to teach me what the hell the WT int i++  code means. my arduino book says it is some progressing increment of some sort.  maybe or can you at least translate it to English?.  is the 8 arbitrary?  etc...  does it run just once? I am thinking it does. just whats in the loop runs over and over. right? or is every Wtsendcommand() running that bit? can the arduino really send data in micro seconds?
Title: Re: Arduino Lightsaber
Post by: wailer on Feb 05, 2016, 07:27 am
Dutch proverb: Better steal something that is good than create something that is bad. ;)

My local fish shop sells better fish than i could ever catch...
Title: Re: Arduino Lightsaber
Post by: wailer on Feb 05, 2016, 07:41 am
One more thing....

If ObiWan would not have given annakin's lightsaber to Luke, would Luke have become a Jedi or not...

Nobody can refuse a good lightsaber...
Title: Re: Arduino Lightsaber
Post by: wailer on Feb 05, 2016, 09:04 am
all fainess.  this is a gallery thread.  you never had to do anything after you dropped the mic.  all the stuff you got going on with your led color mixing, menus, and audio is insane.  I almost went all in and tried the mkIII clone.  then I thought... Obiwan never changed colors, all clash is yellow or white flash in the films and sound is not tunable on these mystical weapons .   good enough for me.  and my expectations got managed just right. 

still waiting for you (anyone) to teach me what the hell the WT int i++  code means. my arduino book says it is some progressing increment of some sort.  maybe or can you at least translate it to English?.  is the 8 arbitrary?  etc...  does it run just once? I am thinking it does. just whats in the loop runs over and over. right? or is every Wtsendcommand() running that bit? can the arduino really send data in micro seconds?
For (i = 0; i < 8; i++){
}

I is a variable so the arduino replaces it with the number it has on the moment it passes in the code.

I starts with 0 and i++ adds 1 (to i) every time the  the loop passes until it reaches 8 then it ends or starts over again.
So if i reaches 8 you could put i back to 0 to run another loop or else the loop will end.
So the i used in the code changes every time the loop passes (first loop 0 second 1 next 2....)

The 8 is arbitrary if the loop has to run 8 times it could be any number....

In every arduino (or any other software) code there is a loop if not it would run the code once and then stop working

And "int" tells the arduino its a number.

https://www.arduino.cc/en/Reference/For
Title: Re: Arduino Lightsaber
Post by: Protonerd on Feb 05, 2016, 01:25 pm
He might be OK insofar as he won't cook anything. I seem to remember from an electronics course I took some years ago that it's not voltage that fries things, it's current. If the buck puck is limiting current to be within spec of the LED then the input voltage doesn't really matter as long as he is keeping it within the spec of what the buck puck can handle.

If the buck-puck says it can take 5V to 12V and will regulate current to 700ma, then you should be able to supply anything in that range and it'll still put out exactly 700ma and not fry the LED.
Completely right.
I would only add, that most current control circuitry actually varies the voltage to make sure the current is constant. Reason is, it's easy to play with voltage. Usually then there is a shunt resistance to sense the current (convert the current to voltage again), and based on that sensed current (which is a voltage, lol), adjust the voltage to ensure the current is stable.
Title: Re: Arduino Lightsaber
Post by: wailer on Feb 05, 2016, 02:27 pm
Here is some basic test code for you, Canobi. It'll test all the I/O except for the accelerometer inputs. I couldn't think of an easy way to do that except maybe putting out the raw read values via serial.

This code will ramp up all 6 possible LEDs to full power and then ramp them down one at a time. See code for the order they go in, but it's more or less right around the pins on the Arduino in ascending order.

Then, once all the LEDs have been tested, it'll go into "button test mode". You can press the Activation switch, Aux switch, or bang the clash sensor to play three different sounds on the WT. Just program your WT588D in one-line serial mode to have three different sounds at 0x00, 0x01, and 0x02 so you'll know if the right sound is playing when you hit the switches.

All while this is happening, the main LED light will light up or go out to indicate the status of the BUSY signal from the WT588D. If you hear sound, but the light does not change state then probably something wrong with the busy signal on the WT.

Code: [Select]

/*
 * Pins_Canobi.h : Defines pinout for Canobi's 3-channel PCB.
 *
 *  Created on: Jan 8, 2016
 *      Author: JakeSoft
 */

#ifndef PINS_CANOBI_H_
#define PINS_CANOBI_H_

//General I/O Pins
#define CLASH_PIN 2 //Clash sensor interrupt pin
#define LED_RED_PIN 3 //PWM output for RED LED
#define LED_GREEN_PIN 5 //PWM output for GREEN LED
#define LED_BLUE_PIN 6 //PWM output for BLUE LED
#define ACTIVATE_PIN 7 //Activation switch
#define AUX_PIN 8 //Aux switch
#define LED_FOC_PIN 9 //Flash-on-clash LED (not implemented by JakeSoft SW)
#define ACCENT1_PIN 10 //Accent LED
#define ACCENT2_PIN 11 //Secondary Accent LED (not implemented by JakeSoft SW)

//Serial pins for WT588d Sound board
#define WT588D_BUSY 12 //Module pin "LED/BUSY"
#define WT588D_SDA 13 //Module pin for DATA

//Accelerometer Pins
#define AXDL335_X_PIN A0 //X axis
#define AXDL335_Y_PIN A1 //Y axis
#define AXDL335_Z_PIN A2 //Z axis
#define AXDL335_VCC_PIN A3 //Accel power (not used by Canobi's PCB)
#define AXDL335_GND_PIN A4 //Accel ground (not used by Canobi's PCB)

#endif /* PINS_CANOBI_H_ */

 

Code: [Select]

/*
 * SaberTest.ino : Tests saber I/O
 *
 *  Created on: Jan 19, 2016
 *      Author: JakeSoft
 */
 
#include "Pins_Canobi.h"

//Routine to send WT588D one-line serial commands
void WT588D_Send1(byte addr) {
    digitalWrite(WT588D_SDA, LOW);
    delay(5);

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

    digitalWrite(WT588D_SDA, HIGH);
    delay(10);
}

//Ramp up the LED then ramp it down
void TestLED(int PinNumber)
{
  //Ramp up the LED
  for(int LedPower = 0; LedPower < 255; LedPower++)
  {
    analogWrite(PinNumber, LedPower);
    delay(10);
  }
 
  //Ramp down the LED
  for(int LedPower = 255; LedPower > 0; LedPower--)
  {
    analogWrite(PinNumber, LedPower);
    delay(10);
  }
 
  //Ensure the the LED is fully off
  digitalWrite(PinNumber, LOW);
}

void setup()
{
  pinMode(LED_RED_PIN, OUTPUT);
  pinMode(LED_GREEN_PIN, OUTPUT);
  pinMode(LED_BLUE_PIN, OUTPUT);
  pinMode(LED_FOC_PIN, OUTPUT);
  pinMode(ACCENT1_PIN, OUTPUT);
  pinMode(ACCENT2_PIN, OUTPUT);
 
  pinMode(CLASH_PIN, INPUT);
  pinMode(ACTIVATE_PIN, INPUT);
  pinMode(AUX_PIN, INPUT);
 
  pinMode(WT588D_BUSY, INPUT);
  pinMode(WT588D_SDA, OUTPUT);
 
  pinMode(AXDL335_X_PIN, INPUT);
  pinMode(AXDL335_Y_PIN, INPUT);
  pinMode(AXDL335_Z_PIN, INPUT);
 
  //Set pull-up resistors for switches
  digitalWrite(CLASH_PIN, HIGH);
  digitalWrite(AUX_PIN, HIGH);
  digitalWrite(ACTIVATE_PIN, HIGH);
 
  //Run LED tests
  TestLED(LED_RED_PIN);
  TestLED(LED_GREEN_PIN);
  TestLED(LED_BLUE_PIN);
  TestLED(LED_FOC_PIN);
  TestLED(ACCENT1_PIN);
  TestLED(ACCENT2_PIN);

}

void loop()
{
  if(LOW == digitalRead(CLASH_PIN))
  {
    //Play a sound
    WT588D_Send1(0x00);
   
    delay(100);
    //Wait for user to let off the button
    while(LOW == digitalRead(CLASH_PIN)) {}
   
  }
 
  if(LOW == digitalRead(AUX_PIN))
  {
    //Play a sound
    WT588D_Send1(0x01);

    delay(100);   
    //Wait for user to let off the button
    while(LOW == digitalRead(AUX_PIN)) {}
  }
 
  if(LOW == digitalRead(ACTIVATE_PIN))
  {
    //Play a sound
    WT588D_Send1(0x02);
   
     delay(100);
    //Wait for user to let off the button
    while(LOW == digitalRead(ACTIVATE_PIN)) {}
  }
 
  //Use the primary blade LED to indicate the status of the BUSY pin
  if(HIGH == digitalRead(WT588D_BUSY))
  {
    //Dimmly light the primary blade LED
    analogWrite(LED_RED_PIN, 64);
  }
  else
  {
    //Turn the primary blade LED off
    digitalWrite(LED_RED_PIN, LOW);
  }

}

Gone fishing and i think i caught something, dont know if it's sprat or a bluefin tuna...
I'll see when i gut it...

Just kidding, i just needed some code to get me started and this looks fine to me.
Title: Re: Arduino Lightsaber
Post by: billpealer on Feb 05, 2016, 03:01 pm
Gone fishing and i think i caught something, dont know if it's sprat or a bluefin tuna...
I'll see when i gut it...

Just kidding, i just needed some code to get me started and this looks fine to me.
it will not help you with the ADXL
Title: Re: Arduino Lightsaber
Post by: billpealer on Feb 05, 2016, 03:11 pm
Completely right.
I would only add, that most current control circuitry actually varies the voltage to make sure the current is constant. Reason is, it's easy to play with voltage. Usually then there is a shunt resistance to sense the current (convert the current to voltage again), and based on that sensed current (which is a voltage, lol), adjust the voltage to ensure the current is stable.
hook a car battery up to your buckpuck, don't PWM control it or analog potentiometer it,..  plug it into your blue luxeon.  start the timer. 

Title: Re: Arduino Lightsaber
Post by: wailer on Feb 05, 2016, 03:33 pm
it will not help you with the ADXL
I know, but i think i can can tackle that problem myself found some other example code that will get me started, should not be too hard.
Will post examples as soon as i got it figured out.

If you wan't to teach people how to fish hand them a fishing rod :).

btw was my i++ explanation any help?
Title: Re: Arduino Lightsaber
Post by: JakeSoft on Feb 05, 2016, 05:41 pm
hook a car battery up to your buckpuck, don't PWM control it or analog potentiometer it,..  plug it into your blue luxeon.  start the timer. 
If we are waiting for the LED to blow up, then we'll be waiting for a really long time. 12 volts is 12 volts, regardless of the source. Because science.
Title: Re: Arduino Lightsaber
Post by: billpealer on Feb 05, 2016, 09:14 pm
If we are waiting for the LED to blow up, then we'll be waiting for a really long time. 12 volts is 12 volts, regardless of the source. Because science.
the buckpuck model in question is variable voltage based on the input.  7v in would yield 3.4v 700ma (according to luxdrive)  12v in would be,...  more.  this is from Luxdrives FAQ

"Can I input more voltage than my LEDs need or will that hurt my driver and/or LEDs?

Yes, you can input more voltage than your LED needs as long as it is in the driver range of 5-32VDC. It is best practice to use an input voltage that is closer to your needs. For example if your system ran around 7 volts, it is better to stick with the 12VDC than to use a 24VDC, whereas the 24VDC input would still work, it is better for the system overall if you used the closer value."

do you think the buckpuck can intelligently detect the MAX VF for any 3W LED and alter its voltage? If so,..  where does all the extra V go,?..  it's not being converted to A like most buck/boosts,  that = heat on the puck.   i was not interpreting that as the case from the above Q/A. 7v and 700ma will cook a 3W LED with passive cooling.  7v * 700ma = 4.9 Watt

stop judging me!
(https://jennyscakedreams.files.wordpress.com/2015/12/c03bc9cc92f837c614c2404b4e723ae5.jpg)
Title: Re: Arduino Lightsaber
Post by: DJWing79 on Feb 05, 2016, 11:04 pm
ok, here's another question....can I use one buckpuck to drive the constant amperage out at 1000 ma but not use the control pin (not getting a dimmer module) and instead have the Negative out feed through a N-FET gate like my current build...would that work? I haven't done my test yet, but I've heard the buckpucks don't generate heat in the same way a boost module would
Title: Re: Arduino Lightsaber
Post by: Protonerd on Feb 06, 2016, 04:09 pm
hook a car battery up to your buckpuck, don't PWM control it or analog potentiometer it,..  plug it into your blue luxeon.  start the timer. 


:) please read the manual:
"The 3021/3023 Wide Range LED Power Module is a high efficiency dc to dc converter which delivers a fixed output current by varying the output voltage as required to maintain the specified current .  A fast response current-sensing circuit permits the unit to be used in applications where flashing or pulsing of the LEDs is required."

I swear I did not, I simply have tons of experience with such circuits.
Title: Re: Arduino Lightsaber
Post by: Kdot on Feb 08, 2016, 07:57 pm
So been a minute on posting here, however the progress has not stopped.

I completely have redone my coding, using this for my switch and swing Click here (https://blog.adafruit.com/2009/10/20/example-code-for-multi-button-checker-with-debouncing/). I was looking for who posted there code for the plasma saber, thanks for that! Did have to add a bit more coding to make the debounce work though.



I have worked out most my audio issues. Start up to Hum is seamless now, and was able to get rid of the 1700ms delay. Working on getting swing to be long enough to hear and switch to Hum seamlessly, only hangup i have now is getting the full swing to play quick enough for another swing, however i think a second sensor might help that. Also have my 3W Cree Blue LED hooked up. Will try and get a video soon.


Sample code:

else {
     PlayComplete(2);
     SABER_On = true;
     Serial.println("Saber is off, turning it on");
     for (int fadeValue = 30 ; fadeValue <= 255; fadeValue += 5) {
       // sets the value (range from 0 to 255):
       analogWrite(LED_test, fadeValue);
       // wait for 30 milliseconds to see the dimming effect
     delay(30);
     }
     PlayLoop(1);

   }
 }
 //Is a swing detected
 if (SW_justpressed[1]) {
   SW_justpressed[1] = 0;
   if (SABER_On) {

     Serial.println("Swing detected");
     Serial.println("Playing swing sound");
     PlayComplete(randNumber = random(3, 7));
     delay(150);
     PlayLoop(1);
   }
Title: Re: Arduino Lightsaber
Post by: purgedsoul on Feb 10, 2016, 04:34 pm
only hangup i have now is getting the full swing to play quick enough for another swing,

been working on this part, something about using the delay function to wait for the first sound to finish, is doing this. Need to replace this with a non-blocking delay... if anybody can come up with this solution please do share.  :)
Title: Re: Arduino Lightsaber
Post by: DJWing79 on Feb 10, 2016, 06:49 pm
have you tried using millis?
Title: Re: Arduino Lightsaber
Post by: Kdot on Feb 10, 2016, 07:35 pm
been working on this part, something about using the delay function to wait for the first sound to finish, is doing this. Need to replace this with a non-blocking delay... if anybody can come up with this solution please do share.  :)
purgedsoul! thank you so much, i took the sample code you had posted previous and have been reworking that to fit my setup.

@DJWing79, i started to play with that, but was not 100% sure of what i was doing, but was kind of a side thought while working something else out
Title: Re: Arduino Lightsaber
Post by: wailer on Feb 11, 2016, 12:17 am
Sample code, wtd533 arduino library and even saber wave files can be found here https://github.com/ACDCLabs/WT588D.git
Even a complete bin file that can be uploaded to the 533 directly is in the repository.

Too bad no accelerometer code, but hey my own code is slowly coming together.
Thanks JakeSoft ahum....just kidding i mean Ecloud thanks for the fish man ;)
Title: Re: Arduino Lightsaber
Post by: stinky1 on Feb 11, 2016, 05:27 am

Here is a link to a lightsaber build that has RGB PWM code in it.  It uses a Joe Jedi or MR616 sound card,  so of course this is not a drop it in and it will work code for the whole shebang,  but will show you code that will need to be adjusted to your build.

Arduino as RGBx PWM controller and Soundcard interface (http://www.fx-sabers.com/forum/index.php?topic=22838.0)

I was gonna post the code,  but its over 9,000 limit lol!!! 
Title: Re: Arduino Lightsaber
Post by: purgedsoul on Feb 11, 2016, 07:25 am
purgedsoul! thank you so much, i took the sample code you had posted previous and have been reworking that to fit my setup.

@DJWing79, i started to play with that, but was not 100% sure of what i was doing, but was kind of a side thought while working something else out

Welcome Kdot, glad it helped.
Title: Re: Arduino Lightsaber
Post by: JakeSoft on Feb 11, 2016, 08:23 pm
Thanks JakeSoft ahum....just kidding i mean Ecloud thanks for the fish man ;)
You are welcome for the parts lists, sample code, 100+ support posts, this thread, example videos, and of course the original idea.
Title: Re: Arduino Lightsaber
Post by: wailer on Feb 12, 2016, 12:11 am
You are welcome for the parts lists, sample code, 100+ support posts, this thread, example videos, and of course the original idea.
Of course thanks for that, without this thread i would not have come this far.
But sifting through all snippets of sample code is pretty hard work and contributing to a  more or less completed code would be more efficient, and more of a "open source" idea.
But that is my humble opinion.
Title: Re: Arduino Lightsaber
Post by: neskweek on Feb 12, 2016, 10:12 am
been working on this part, something about using the delay function to wait for the first sound to finish, is doing this. Need to replace this with a non-blocking delay... if anybody can come up with this solution please do share.  :)
Avoid delays at all cost ! Delays interfere with motion detection interrupts.

Have a look at my solution here (full code LightSaber Operating System) (http://forum.arduino.cc/index.php?topic=361566.msg2610431#msg2610431)

SWING_SUPPRESS might require some tweaking depending of how much time is spend for a full loop in your code.
Title: Re: Arduino Lightsaber
Post by: Canobi on Feb 15, 2016, 10:12 am
Anyone here use photoshop?

For some reason the circuit artwork isn't printing at 1:1 scale and I don't know why.

Title: Re: Arduino Lightsaber
Post by: billpealer on Feb 15, 2016, 03:20 pm
Of course thanks for that, without this thread i would not have come this far.
But sifting through all snippets of sample code is pretty hard work and contributing to a  more or less completed code would be more efficient, and more of a "open source" idea.
But that is my humble opinion.
one could re-post a collective file that is a repository of all the (useful) sample code people have contributed.  that would be nice. and a way to pay it forward.

2-3 weeks i'll have ADXL335 code to post. though analogRead code is hardly scarce.
Title: Re: Arduino Lightsaber
Post by: billpealer on Feb 15, 2016, 03:22 pm
Anyone here use photoshop?

For some reason the circuit artwork isn't printing at 1:1 scale and I don't know why.


do you use a laser or inkjet printer?  master your files as PDF (if you can)  print the PDF file in Reader and change your scaling to 1:1 or "original" or "100%"  depending on your printer make and model.
Don't print from a browser,  double click the local PDF and print from Adobe Reader 10 is best 11 has some bugs.  I can post screen grabs of 1:1 scale printing in Epson and HP printer dialog. If you are Canon or Lexmark, you are on your own.
make sure you have "border-less" or "edge to edge" turned OFF.  that should print to the scale you have in your original project.
Title: Re: Arduino Lightsaber
Post by: Canobi on Feb 15, 2016, 09:17 pm
do you use a laser or inkjet printer?  master your files as PDF (if you can)  print the PDF file in Reader and change your scaling to 1:1 or "original" or "100%"  depending on your printer make and model.
Don't print from a browser,  double click the local PDF and print from Adobe Reader 10 is best 11 has some bugs.  I can post screen grabs of 1:1 scale printing in Epson and HP printer dialog. If you are Canon or Lexmark, you are on your own.
make sure you have "border-less" or "edge to edge" turned OFF.  that should print to the scale you have in your original project.
Thanks Bill :)

I use a Samsung laser printer and I've just set up laptop for the lab so may well have missed something. I'll have a look at the settings when I get back from work.

The PDFs need a bit of contrast adjustment as they come out off white which shows in the prints and use photoshop 5.

One thing is, I have to select pixle density on import and I'm wondering if that may be influencing things.
Title: Re: Arduino Lightsaber
Post by: billpealer on Feb 16, 2016, 12:30 am
Thanks Bill :)

I use a Samsung laser printer and I've just set up laptop for the lab so may well have missed something. I'll have a look at the settings when I get back from work.

The PDFs need a bit of contrast adjustment as they come out off white which shows in the prints and use photoshop 5.

One thing is, I have to select pixle density on import and I'm wondering if that may be influencing things.
that's prolly it.

make sure your pixel depth (density- measured in DPI dots/inch or PPI pixels/inch) is the same as your work space. (the native file)

300 dpi is a common print work space  72 dpi is for screens (LCD OLED, PLASMA CRT etc...)

photoshop menu chain  Image > Image Size   (select Image Size)  you should see the native DPI or PPI there.  or Alt+Ctrl + I

if your android circuit board making software is vector based  (you can zoom in as close as you want the the lines and text look good or even better) it most likely is exporting in 300dpi PDFs.
Title: Re: Arduino Lightsaber
Post by: Canobi on Feb 16, 2016, 01:29 am
Turned out a stupid print preference, the "pre" scaling was set to "shrink to print area".

Everything is printing and lining up properly again (whew!), I can stop panicking now lol.
Title: Re: Arduino Lightsaber
Post by: JakeSoft on Feb 16, 2016, 03:34 am
Special thanks to BillPealer for the tip about decaying your swing and clash sounds to the END of the hum sound. I've been mixing/remixing sound files for a while now, but the transitions from clash to hum were always (no pun intended) hit or miss. Since I employed this technique, the transitions are much smoother.
Title: Re: Arduino Lightsaber
Post by: billpealer on Feb 16, 2016, 05:14 am
Special thanks to BillPealer for the tip about decaying your swing and clash sounds to the END of the hum sound. I've been mixing/remixing sound files for a while now, but the transitions from clash to hum were always (no pun intended) hit or miss. Since I employed this technique, the transitions are much smoother.
not quite sure that was me.  You are adding clash and swing to the END of your hum?  like IN audacity? or WT playlists?  or are you altering your swing and clash sounds with your sound editor so they decay to a tone that is more akin to the ambient hum?   if so, you're welcome. LOL. 
Title: Re: Arduino Lightsaber
Post by: wailer on Feb 16, 2016, 08:50 am
one could re-post a collective file that is a repository of all the (useful) sample code people have contributed.  that would be nice. and a way to pay it forward.

2-3 weeks i'll have ADXL335 code to post. though analogRead code is hardly scarce.
Been experimenting with the 335 to get usable  readings.
I think the best way is to convert the readings to G force's to detect a swing so you can easily up or down the sensitivity.
You could even incorporate  a potmeter (also connected to analog in) to adjust this while using your saber, even have different swing sounds per reading (swing 1  +g swing 2 -g)
Have not been able to detect clashes with it but i think a standard clash detector (with a spring inside) should work better.
Some interesting code can be found here https://chionophilous.wordpress.com/2011/06/20/getting-started-with-accelerometers-and-micro-controllers-arduino-adxl335/
Hope i can post some code soon.
Title: Re: Arduino Lightsaber
Post by: neskweek on Feb 16, 2016, 11:22 am
Been experimenting with the 335 to get usable  readings.
I think the best way is to convert the readings to G force's to detect a swing so you can easily up or down the sensitivity.
You could even incorporate  a potmeter (also connected to analog in) to adjust this while using your saber, even have different swing sounds per reading (swing 1  +g swing 2 -g)
Have not been able to detect clashes with it but i think a standard clash detector (with a spring inside) should work better.
Some interesting code can be found here https://chionophilous.wordpress.com/2011/06/20/getting-started-with-accelerometers-and-micro-controllers-arduino-adxl335/
Hope i can post some code soon.
On MPU6050 device :

I did use quaternion instead to detect a swing: any w axe variation means the hilt did move.
As for swing sound : A simple random chose of swing sound do the same.

I did use G force variations to detect clashes. But I agree with that a clash/bump sensor would better suit that role.

one could re-post a collective file that is a repository of all the (useful) sample code people have contributed.  that would be nice. and a way to pay it forward.

2-3 weeks i'll have ADXL335 code to post. though analogRead code is hardly scarce.
I did post my full code, hoping people may complete it with other devices :
LightSaberOS (https://github.com/neskweek/LightSaberOS)
Title: Re: Arduino Lightsaber
Post by: JakeSoft on Feb 16, 2016, 03:39 pm
On MPU6050 device :

I did use quaternion instead to detect a swing: any w axe variation means the hilt did move.
As for swing sound : A simple random chose of swing sound do the same.

I did use G force variations to detect clashes. But I agree with that a clash/bump sensor would better suit that role.
I did post my full code, hoping people may complete it with other devices :
LightSaberOS (https://github.com/neskweek/LightSaberOS)
Note that he used an MPU6050 which is a different animal than the ADXL335 chosen as the standard motion sensor in this thread. So keep that in mind when trying to apply techniques found in this code.
Title: Re: Arduino Lightsaber
Post by: Protonerd on Feb 16, 2016, 05:40 pm
Note that he used an MPU6050 which is a different animal than the ADXL335 chosen as the standard motion sensor in this thread. So keep that in mind when trying to apply techniques found in this code.
When I started out, I took 3 sound modules (W588D, WT5001, DFPlayer) and switched between them quite frequently in my quest to find the Holy Gaplessness. I used compile directives (conditional inclusions) to be able to make the switch fast. If I had a - say - clash function, I had a piece of code for all 3 of them.

Something like this would be possible in neskweek's LSOS as well. For swings this would mean configuring whether a ball sensor, an MPU or an ADXL is used. For clash similarly. I guess such conditions already exists to define whether the code is running on an RGB or a LED string saber.
Title: Re: Arduino Lightsaber
Post by: neskweek on Feb 16, 2016, 09:44 pm
Note that he used an MPU6050 which is a different animal than the ADXL335 chosen as the standard motion sensor in this thread. So keep that in mind when trying to apply techniques found in this code.
I do concur that concerning the manner your get data from each module is totally different.

But concerning on how to treat them to obtain the result, it might be the same, from my point of view ;p

I was just giving the principles,that I used and that may remain the same, wathever the module is:

For a swing you want to detect a displacement in space. A simple difference between 2 Quaternion.w do the trick.

For a clash you want to detect a "violent" acceleration/deceleration followed by a "brutal" full stop.
Depending on the module you use and how fast it is able to change state you may need to do several passes throught the loop to detect changes of Magnitude (G force)


[Edit]

To make things clearer concerning Swing detection :
IMUs sucks at detecting change of positions in space. It could be achieved but you may end up with a huge code, and for our arduino device it's not what we want.

IMus are good at detecting acceleration and rotations.
When you play around with your saber, you changes its orientation (in other words, the IMU did rotate around its X/Y axes).

Differences between 2 quaternions are use to detect change of orientation, easily.
The only thing I omited is that you have to test around which axes the blade has rotated : you may don't want to trigger a swing when the saber did rotate along Z IMU's axe (like when Qui-Gon is burying is saber in a massive metalic airlock at the start of Episode 1).

[Edit 2]
While I was typing the last edit,  I realized one thing :
a test combining that a difference of 2 quaternions is above a certain value and that an X or Y acceleration is also above a certain value would be even more efficient :

The swing would be triggered only when making "wide" movements.

Hope it makes any sense ;)
Title: Re: Arduino Lightsaber
Post by: billpealer on Feb 17, 2016, 05:14 pm
I did post my full code, hoping people may complete it with other devices :
LightSaberOS (https://github.com/neskweek/LightSaberOS)
Thanks i'll take a look. Se if i can use it or abuse it.
Note that he used an MPU6050 which is a different animal than the ADXL335 chosen as the standard motion sensor in this thread. So keep that in mind when trying to apply techniques found in this code.
My hypothesis (untested) may be novel ( or not)-  will be to trigger swing, with the ADXL using a state change mechanic. quantify all the axis readings upon start up, and trigger the swing based on the total state change.

so- and the below code sample is me thinking out loud.  it is not syntax accurate.

setup for the pin outs and whatnot.

int state
State = AnalogRead (X+Y+Z);

void loop
If (New_State + State) is < or >  (300 - New_State) // this number is totally arbitrary till i solder up the ADXL and start getting reads from rests and swings.

Send_Command(1);  //swing
Delay (100); // if you can swing more than 10 times a second, have a cookie.

New_State = State;
Title: Re: Arduino Lightsaber
Post by: RCNiner on Feb 17, 2016, 08:42 pm
Has anyone done an led string blade with these set ups? I haven't seen anything in the forums
Title: Re: Arduino Lightsaber
Post by: billpealer on Feb 17, 2016, 09:50 pm
i thought proto did.
Title: Re: Arduino Lightsaber
Post by: wailer on Feb 17, 2016, 10:13 pm
Thanks i'll take a look. Se if i can use it or abuse it.My hypothesis (untested) may be novel ( or not)-  will be to trigger swing, with the ADXL using a state change mechanic. quantify all the axis readings upon start up, and trigger the swing based on the total state change.

so- and the below code sample is me thinking out loud.  it is not syntax accurate.

setup for the pin outs and whatnot.

int state
State = AnalogRead (X+Y+Z);

void loop
If (New_State + State) is < or >  (300 - New_State) // this number is totally arbitrary till i solder up the ADXL and start getting reads from rests and swings.

Send_Command(1);  //swing
Delay (100); // if you can swing more than 10 times a second, have a cookie.

New_State = State;
I think you are absolutely right keep it simple as possible.
Tried to update my mathematical skills but quaternion's just gave me a headache...
And hey a arduino is good but not a pentium i7 keeping the code as small as posible reduces the risk of lag.
Title: Re: Arduino Lightsaber
Post by: neskweek on Feb 19, 2016, 06:44 pm
I think you are absolutely right keep it simple as possible.
Tried to update my mathematical skills but quaternion's just gave me a headache...
And hey a arduino is good but not a pentium i7 keeping the code as small as posible reduces the risk of lag.
Nonsense !

1. You don't have to understand mathematics behind quaternions tu use them. Just like you don't need to know how to read hexadecimal to code or know how an engine works to drive (would be best tho...)

You just need to know what they do (they determine your hilt orientation) and find a library that can calculate quaternions from your gyroscope data.
Of course you can still use only the gyroscope data, but you'll have to address "cadrant lockup" problems (and good luck with that)
As for using G force to finely detect swings... I still don't see how you're going to manage to do that.
But hey! If you find a better way to do this with your idea: be my guest !

2.Do you find this laggy ? (https://www.youtube.com/watch?v=wY8BSSEyYLY)

[EDIT]
Sorry I didn't get the ADXL335  was only an accelerometer and not an IMU. :P
So my solution is not applicable to your devices
But hey still good luck with that !
Title: Re: Arduino Lightsaber
Post by: katan007 on Feb 19, 2016, 09:36 pm
Hey Star Wars Guys and Gals,

I just got my sound modules (WT588D-16p 8m) for my sabres in last week though still need my arduino pro-mini usb program connector. I've made this sketch based on connecting the module to one of my mega's. It plays really well so far and is quite a bit different than the ones I've seen partially posted on this thread (sorry not yet at wanting to deal with accelerometers). There is the odd issue that will cause bouncing in the blade on/off function, however this attempt is the least buggy of my efforts thus far. It could use a new pair or multiple pairs of eyes to go over for optimizing and improvements if anyone is willing to take a crack. The end of the code hasn't been completed for the change in sound or colour states but that is wicked easy i just haven't decided which goes where I suppose.  

Also for all those who are interested in my code here feel more than welcome to snag it as it has been posted for anyones use!
Title: Re: Arduino Lightsaber
Post by: stinky1 on Feb 20, 2016, 08:27 am
Hey Star Wars Guys and Gals,

I just got my sound modules (WT588D-16p 8m) for my sabres in last week though still need my arduino pro-mini usb program connector. I've made this sketch based on connecting the module to one of my mega's. It plays really well so far and is quite a bit different than the ones I've seen partially posted on this thread (sorry not yet at wanting to deal with accelerometers). There is the odd issue that will cause bouncing in the blade on/off function, however this attempt is the least buggy of my efforts thus far. It could use a new pair or multiple pairs of eyes to go over for optimizing and improvements if anyone is willing to take a crack. The end of the code hasn't been completed for the change in sound or colour states but that is wicked easy i just haven't decided which goes where I suppose. 


Code is nice!  But what parts are you using?  Old school tilt sensors and clash sensor?  Cant blame you the 6050's code is dammned confusing and complex.

Anyways a list of parts used makes it easier to understand or for someone to replicate.   oooo so many codes recently!  Thanks!!!

Title: Re: Arduino Lightsaber
Post by: katan007 on Feb 20, 2016, 07:53 pm
My arduino mega has both open 5 & 3.3V pins that i use for the power supply to the module so there would be a few changes for people who need to switch it to the mini (as I will be soon), but if your competent in the arduino playground that shouldn't be an issue (perhaps a tad bit of tinkering).

The program is built so far for the basic clash and swing sensors that act as switches and not pwm/analogue accelerometer. the counter states could be changed easily based on different forces on the accelerometer but I'm not particularly set on that as simplicity is better in some cases.

No worries, always glad to help!
Title: Re: Arduino Lightsaber
Post by: wailer on Feb 20, 2016, 08:16 pm
Nonsense !

1. You don't have to understand mathematics behind quaternions tu use them. Just like you don't need to know how to read hexadecimal to code or know how an engine works to drive (would be best tho...)

You just need to know what they do (they determine your hilt orientation) and find a library that can calculate quaternions from your gyroscope data.
Of course you can still use only the gyroscope data, but you'll have to address "cadrant lockup" problems (and good luck with that)
As for using G force to finely detect swings... I still don't see how you're going to manage to do that.
But hey! If you find a better way to do this with your idea: be my guest !

2.Do you find this laggy ? (https://www.youtube.com/watch?v=wY8BSSEyYLY)

[EDIT]
Sorry I didn't get the ADXL335  was only an accelerometer and not an IMU. :P
So my solution is not applicable to your devices
But hey still good luck with that !
If you build yourself a car you do have to know how a engine works to if you want to be able to drive it at all (i know, another project of mine).
So my opinion is that if you are coding you have to know how things work, if things do not work correctly how will you fix them.
Swings on G's is not that hard just wait till your 335 output (as it only measures acceleration thats easy) exceeds a given threshold and play a sound...

I never implied your project was laggy... :smiley-confuse:
Title: Re: Arduino Lightsaber
Post by: neskweek on Feb 20, 2016, 11:51 pm
Yeah, my bad :p

Sorry again, I did lose my temper.
Title: Re: Arduino Lightsaber
Post by: Canobi on Feb 21, 2016, 04:30 pm
Hi guys

I felt my contributions have been a bit lacking recently and have permission from Jake to post pics and go through the fabrication process I'm using to make the saber PCBs.

I hope it will dispel some of myths and mystery about making PCBs at home and encourage others to have a go as its really not that difficult (as long as health and safety precautions are taken seriously, it's actually a fun and highly intersting process).



Part one is mostly descriptive, the exiting stuff will happen in part two so please bear with me.


----Part One----

I use a common home brew technique called toner transfer. It was discovered a few years ago that laser (and to a lesser degree ink jet) toner inks are resistant to many forms of etching mediums. Not all printers are made the same though so if you decide you might like to try your hand at etching after reading this, avoid Brother models as the ink for those have a higher melting point and results are very hit and miss. I use a 1200dpi Samsung mono tone laser jet printer and it's worked like a charm so far.


To make use of the ink as a resist, the circuit image is first checked to make sure it is true black and white (and corrected if not) then the image is mirrored in readiness for printing.

The next step is to make a test print with the toner levels set to minimum. To avoid miss printing the proper run, a mark is made somewhere on the top of the sheet for correct orientation later. The test print gives a print area "hot spot" and a piece of gloss photo paper is cut slightly larger than the print area and secured in place with sticky notes for easy removal.

Once secured, it's put back in the loading tray in the correct orientation and the toner levels are set to maximum. You need as much ink as you can get your printer to lay down as a resist layer, adjusting the printers altitude setting to high will also help to increase the ink density, though finding the settings for this can be elusive:

(http://i1225.photobucket.com/albums/ee395/Can-obi/IMG_20160220_080014.jpg) (http://s1225.photobucket.com/user/Can-obi/media/IMG_20160220_080014.jpg.html)

A piece of copper clad board is then roughly cut so it's slightly larger than the piece of gloss paper, this ensures none of the print is placed "off board" by accident. It's then buffed with 0000 grade wire wool along both axis (length, then width and back to length for a final pass) and cleaned with acetone and isopropyl alcahol to ensure there is no dirt, oils or residues left on the copper surface.

The easiest way to check how clean the copper is after wiping it down is the water test. The board should be able to hold water for a minimum of 10 seconds as enough oil residue to stop the toner bonding to the copper will part the water.

Once cleaned and checked, the board is heated in increments over a 20min period till it reaches about 30~40°C:

(http://i1225.photobucket.com/albums/ee395/Can-obi/IMG_20160221_145340.jpg) (http://s1225.photobucket.com/user/Can-obi/media/IMG_20160221_145340.jpg.html)



The print is then carefully aligned and placed face down (one end first) onto the heated copper surface and fed through the laminater about 4~5 times and the next part is to feed it through a Hot Roll laminator set to max temp (I use a GBC HotSeal H312). This allows for far fewer passes as the board is already warmed and doesn't draw heat away from the ink and rollers:

(I modified my laminator and cut a section out of the main housing to gain better access to the rollers)
(http://i1225.photobucket.com/albums/ee395/Can-obi/IMG_20160221_152350.jpg) (http://s1225.photobucket.com/user/Can-obi/media/IMG_20160221_152350.jpg.html)

Note: Externally heated rollers are not recommended for this type of work as they suffer from hot spots and can't the high temperatures where the pressure is applied due to the fact that the feed rate is so slow and the rollers start to cool down as they turn away from the heat source.
**


Normally the board and paper would then be cooled under cold running water. Once cold it would go in a receptical cintaining warm water to soften the paper for easy removal.

That bit is messy and more brands than not will also leave the gloss layer on the board as well. It does come off by rubbing, but this comes with a high risk of accidentally knocking some of the ink off while your at it and vias have a nasty habit of protecting the gloss layer inside them so need fingernails or a relatively pointy but blunt tool to get them out.

I count myself to be very lucky in this respect as I don't have to do any of that nonsense. I discovered by accident that the local supermarket brand of gloss paper I use peals off easily and cleanly while the board is still hot leaving the ink and a very fine layer of paper behind:

(http://i1225.photobucket.com/albums/ee395/Can-obi/IMG_20160220_110259.jpg) (http://s1225.photobucket.com/user/Can-obi/media/IMG_20160220_110259.jpg.html)

Ink that is still attached to the photo paper is an indication of possible oils still present on the copper, or can be a caused by using under temperaturesn as in this case as I only passed it through the laminator three times and it could have done with at least one more.

Your kind of committed once peeling has begun, so I use an etch resist pen to fill in any holes that do appear. If thin tracks are broken, I use the acetone to clean off all the ink and start again with a fresh print as etch resist pens don't come with fine tips, let alone one that can deal with the .3mm tracks used on the saber boards.


Well, that's it for the moment. I hope it was informative and if there are any questions regarding any part of the process, please feel free to ask.
Title: Re: Arduino Lightsaber
Post by: billpealer on Feb 29, 2016, 08:41 pm
any new sabers to show off? 
Wailer? Katan?  Nesk?...

Bueller?
Title: Re: Arduino Lightsaber
Post by: JakeSoft on Mar 01, 2016, 02:27 am
any new sabers to show off? 
Wailer? Katan?  Nesk?...

Bueller?
I'm waiting on my Canobi board. I figure why not demo the Mk. IV software and his board at the same time?
Title: Re: Arduino Lightsaber
Post by: neskweek on Mar 01, 2016, 12:43 pm
any new sabers to show off? 
Wailer? Katan?  Nesk?...

Bueller?
I'm quite far from "show and tell" :P : I'm still working on the software.

Anyway I don't want to rush any build stages.
So when software will reach an acceptable state I'll switch to designing a good chassis.
Then I'll  make custom external part using a lathe.

So not for tomorow
Title: Re: Arduino Lightsaber
Post by: Protonerd on Mar 01, 2016, 10:19 pm
I'm quite far from "show and tell" :P : I'm still working on the software.

Anyway I don't want to rush any build stages.
So when software will reach an acceptable state I'll switch to designing a good chassis.
Then I'll  make custom external part using a lathe.

So not for tomorow
OMG, you can work the lathe? That's crazy, with the skills you have we can already greet the next shooting star of the sabersmith community!

As for me, I also have a design waiting some work with the lathe. I cannot work with it, at least not without some serious support from friends, but I make some progress. It's gonna be a saber staff and I dream about having 2 DIYino boards inside communicating with each other, 2 speakers...OK, stop daydreaming.

I also wait for my ASP saber hilt (yeah, I actually helped crowfunding that guy) and then I decide it is going to be:
1. an LED string saber
2. an HP LED saber (most probably)
3. a neopixel saber

With this superb community started by JakeSoft, the possibilities are limitless.
Title: Re: Arduino Lightsaber
Post by: neskweek on Mar 02, 2016, 12:38 am
Yeah, my grandfather have a lathe. An old one. Not heavily precise but for what I plan to do it would be just enough.

After I'm not a pro of this tool, but my father is, so I'll ask for advices ;)
Title: Re: Arduino Lightsaber
Post by: Canobi on Mar 02, 2016, 02:52 am
Quick update regarding the field test boards. Key parts are finally in which took forever to arrive (Chinese new year probably).

Few vids coming up as a result, I'll try and get the first one finished tomorrow.
Title: Re: Arduino Lightsaber
Post by: Protonerd on Mar 02, 2016, 10:12 pm
I'm waiting on my Canobi board. I figure why not demo the Mk. IV software and his board at the same time?
Wow, Jake, I saw that MK IV video with the motion conrolled blaster block! That elevates this FX to a whole new level! I always felt awkward because pushing the button (which is just never there where my fingertip looks for it) and swinging the saber at the same time gave me a finemotoric challenge. Not that is history!
Title: Re: Arduino Lightsaber
Post by: JakeSoft on Mar 02, 2016, 10:27 pm
Wow, Jake, I saw that MK IV video with the motion conrolled blaster block! That elevates this FX to a whole new level! I always felt awkward because pushing the button (which is just never there where my fingertip looks for it) and swinging the saber at the same time gave me a finemotoric challenge. Not that is history!
Thanks, Proto! It was stupidly simple to do too. Just play a blaster sound instead of a swing. All the same logic applies. I'm surprised nobody has done it yet. I bet others will now, though.  ;)
Title: Re: Arduino Lightsaber
Post by: neskweek on Mar 02, 2016, 10:58 pm
Thanks, Proto! It was stupidly simple to do too. Just play a blaster sound instead of a swing. All the same logic applies. I'm surprised nobody has done it yet. I bet others will now, though.  ;)
Starting by me ;)
Title: Re: Arduino Lightsaber
Post by: JakeSoft on Mar 03, 2016, 01:21 am
Starting by me ;)
Just give credit.
Title: Re: Arduino Lightsaber
Post by: neskweek on Mar 03, 2016, 01:16 pm
Off course I will
Title: Re: Arduino Lightsaber
Post by: neskweek on Mar 03, 2016, 07:49 pm
Hey guys, just a quick question.

I was searching some good speaker to put inside a hilt, and I found that somesurface tranduscer measure exactly 28mm in diameter (and they are 4ohms 3W).

Do you think those could be used to transform the outer surface of the hilt into the actual speaker (not mentionning it would also act as a rumble device) ?

[EDIT]
So I may answer to myslef by a yes, it can.
here are some examples :  https://www.youtube.com/watch?v=xC1GUSu1bLU (https://www.youtube.com/watch?v=xC1GUSu1bLU)
Ok, our surface is not the same (smaller) , but I'll take that as a proof of concept.
Tests needs to be made.

Furthermore, the blade could also be used as a speaker : I found some interesting devices that uses piezo electrics device and plexiglass to make fantastic speakers.
So applying a correct piezo speaker to the emiter might produce the same.

Title: Re: Arduino Lightsaber
Post by: Canobi on Mar 05, 2016, 12:01 am
The transducer's contact has to be mounted flush with a flat surface so might not work in a tube without an internal plate of some kind.

I have a bunch which I bought for a Tron identity disc project ad I'm not keen on putting speaker holes in the shells and they were the perfect solution.

I really really like the idea of turning the blade into a speaker though, it makes sense as its probably the blade that makes all the sound anyway.

Title: Re: Arduino Lightsaber
Post by: neskweek on Mar 05, 2016, 12:09 am
I was thinking putting one or more of those  small transducer, vertically, inside the emiiter walls.

If the blade needs to be sanded in order to get flatter, in that place,  that shouldn't be a drama :)


I just thought of something more.
15 days ago I watched  Sabertalk 8 on Spacewindu youtube channel and during this program they talked about the possibility to push saber sound to another device via Bluetooth.

That's quite an interresting idea. But not an easy one to achieve for several reasons.
But if we want to just have sound to a bigger external speaker, I just thought that a FM Radio emitter would make just as good without difficulties. So I also ordered a tiny module to add to my future hilts.
Title: Re: Arduino Lightsaber
Post by: JakeSoft on Mar 05, 2016, 01:20 am
The transducer's contact has to be mounted flush with a flat surface so might not work in a tube without an internal plate of some kind.

I have a bunch which I bought for a Tron identity disc project ad I'm not keen on putting speaker holes in the shells and they were the perfect solution.

I really really like the idea of turning the blade into a speaker though, it makes sense as its probably the blade that makes all the sound anyway.


This might work. I'd be interested to see somebody try it. It would probably not be dual-able, but would be a good show piece.
Title: Re: Arduino Lightsaber
Post by: Canobi on Mar 05, 2016, 02:52 am
Yay, it finally worked!

Was having a major headache trying to upload this video the last couple days and suddenly it's worked :D



https://youtu.be/8MqT_i8w57E (https://youtu.be/8MqT_i8w57E)


Just out of interest, how does one embed video on this site? I can't seem to find an icon for it.
Title: Re: Arduino Lightsaber
Post by: Canobi on Mar 05, 2016, 05:55 pm
Just found these:

(http://i1225.photobucket.com/albums/ee395/Can-obi/IMG_20160305_154238.jpg) (http://s1225.photobucket.com/user/Can-obi/media/IMG_20160305_154238.jpg.html)

They're very close in size to the discontinued micro 3w amps but have the added advantage that they can take pin headers, which would certainly make integrating them on the board more straightforward.
Title: Re: Arduino Lightsaber
Post by: Protonerd on Mar 05, 2016, 08:58 pm
Yay, it finally worked!

Was having a major headache trying to upload this video the last couple days and suddenly it's worked :D



https://youtu.be/8MqT_i8w57E (https://youtu.be/8MqT_i8w57E)


Just out of interest, how does one embed video on this site? I can't seem to find an icon for it.
I can only stand up and bow to you Sir! I never though someone actually can make a PCB at home, awesome!
Title: Re: Arduino Lightsaber
Post by: MAS3 on Mar 05, 2016, 10:58 pm
Just out of interest, how does one embed video on this site? I can't seem to find an icon for it.
Embedding video was a hack in older versions of the forum software.
It is one of the many things that got broken after updating to the newest and beta SMF forum software, about a year ago.
Don't expect that to be fixed any time soon.
Title: Re: Arduino Lightsaber
Post by: Canobi on Mar 05, 2016, 11:26 pm
I can only stand up and bow to you Sir! I never though someone actually can make a PCB at home, awesome!
Thank you :)


This is just the beginning, at some point down the line I want to include electro plating to my roster of fabrication skills so I can do proper vias on two sided boards.

I'm still on one side at the moment but I can see me moving on to two very soon.

Actually, I could possibly do with your assistance. I saw your open source saber board thread and it got me thinking about integrating an amp on mine but not sure I can pull it off on a one sided PCB.
Title: Re: Arduino Lightsaber
Post by: Canobi on Mar 05, 2016, 11:53 pm
Embedding video was a hack in older versions of the forum software.
It is one of the many things that got broken after updating to the newest and beta SMF forum software, about a year ago.
Don't expect that to be fixed any time soon.
Shame, ah well, links it is then.

Thanks for clearing that up mas3

Title: Re: Arduino Lightsaber
Post by: Canobi on Mar 07, 2016, 11:00 pm
Here's part 2.

https://youtu.be/k4tMNRgwcBI (https://youtu.be/k4tMNRgwcBI)

Its a bit rough around the edges so apologies for that.

Please let me know if the quality sucks, it seems a bit hit n miss when I review at home, sometimes plays back in HD, other times it looks really compressed so unsure if it's just my bandwidth or not.

Title: Re: Arduino Lightsaber
Post by: destructables on Mar 08, 2016, 03:33 pm
Hey guys, just a quick question.

I was searching some good speaker to put inside a hilt, and I found that somesurface tranduscer measure exactly 28mm in diameter (and they are 4ohms 3W).

Do you think those could be used to transform the outer surface of the hilt into the actual speaker (not mentionning it would also act as a rumble device) ?

[EDIT]
So I may answer to myslef by a yes, it can.
here are some examples :  https://www.youtube.com/watch?v=xC1GUSu1bLU (https://www.youtube.com/watch?v=xC1GUSu1bLU)
Ok, our surface is not the same (smaller) , but I'll take that as a proof of concept.
Tests needs to be made.

Furthermore, the blade could also be used as a speaker : I found some interesting devices that uses piezo electrics device and plexiglass to make fantastic speakers.
So applying a correct piezo speaker to the emiter might produce the same.


I'd been looking into one of those myself, as I'm modding an ultrasaber that as of right now has a solid pommel. If the transducer would work, that would save me from having to mill holes into the pommel.
Title: Re: Arduino Lightsaber
Post by: neskweek on Mar 08, 2016, 11:22 pm
I'd been looking into one of those myself, as I'm modding an ultrasaber that as of right now has a solid pommel. If the transducer would work, that would save me from having to mill holes into the pommel.
You still need those holes for safety issues : batteries can vent.

Old batteries, or defectuous battery, when you ask of them to much power start to heat.
This leads to some wearing effect. At some point this wear will make the battery leak. When they leak they vent gases.
If you have no holes in your hilt, those gases build up pression inside the hilt, until the hilt structure can take it anymore : in short term your hilt might explode.
If you don't believe look at articles on electonic cigarette exploding : some crappy designed of those stuff does not have venting holes.

So as I said earlier : YOU WANT HOLES ! ( even small ones ;) )


That brought me to talk another matter. I don't know if it had already been discussed in this thread, but does any of you monitor battery charge ?
You may also want to : if battery goes below a certain voltage, it simply dies, even if it is brand new.
Since arduino board are always on ....  
You'll find here a way to do so (http://provideyourown.com/2012/secret-arduino-voltmeter-measure-battery-voltage/)
Title: Re: Arduino Lightsaber
Post by: destructables on Mar 08, 2016, 11:56 pm
You still need those holes for safety issues : batteries can vent.


So as I said earlier : YOU WANT HOLES ! ( even small ones ;) )

Makes me wonder why Ultrasabers doesn't have any vent holes in their sabers. It's a single milled tube. Maybe around where the switch is mounted?
Title: Re: Arduino Lightsaber
Post by: neskweek on Mar 09, 2016, 12:50 am
Lots of industrials aren't well informed on battery venting risks....

OMG!! And they provide their device with trustfire (well named) batteries  :o  :o  :o

Well, then.... Battery venting is not that common, but hey... shit happens !
Title: Re: Arduino Lightsaber
Post by: Protonerd on Mar 09, 2016, 03:41 pm
You still need those holes for safety issues : batteries can vent.

So as I said earlier : YOU WANT HOLES ! ( even small ones ;) )

You are rigth, we want holes. And saber hilts have them. I also own an UltraSabers, the pommel always has holes, because there is where you want to put your speaker, and very often the emitter has windows (although they might be blocked by the blade).


Quote
That brought me to talk another matter. I don't know if it had already been discussed in this thread, but does any of you monitor battery charge ?
You may also want to : if battery goes below a certain voltage, it simply dies, even if it is brand new.
Since arduino board are always on .... 
You'll find here a way to do so (http://provideyourown.com/2012/secret-arduino-voltmeter-measure-battery-voltage/)
I did try it, but later neglected the topic due to more pressing matters. But a very important point. The deep discharge is however a rare event, if the voltage drops below a critical point, the chips do not work any more, and that means they also do not consume much. If you supply through VIN, the LDO will also caese to work if the input voltage drops below 5V (not immediately, but sooner or later). After which no current will flow, or only a minimal leakage.
Apart from this, most sabers have kill keys. I.e. if you do not need your saber, you plug in the kill key, physically separating the battery from the electronics. So far I only have one saber where the electronics can really go into deep sleep, and I can keep the saber months in a row on the shelf wo/kill key and I can still wake it up. So with a chipset in deep sleep, the risk is minimized. I hope that the Atmegas can be put into deep sleep mode and woken up again easily.

With neopixels, a very cool in-blade PLI (power level indicator) could be achieved. With green/yellow/red regions.
Title: Re: Arduino Lightsaber
Post by: neskweek on Mar 09, 2016, 04:57 pm
Atmega328 can be put in deep sleep mode. I tried with your design and it works. To wake it up you need to hit the hilt (like a clash) to generate the necessary  interrupt.

From what I could find on the net a normal/default deep sleep on those chips  needs 0,36mAh but with further tweaking lower consumption rates  can be achieved (some claims 1 to 4µA) 

source : http://www.gammon.com.au/forum/?id=11497 (http://www.gammon.com.au/forum/?id=11497)
Title: Re: Arduino Lightsaber
Post by: Protonerd on Mar 09, 2016, 07:07 pm
I found this one:
http://playground.arduino.cc/Learning/ArduinoSleepCode

And from here I visited the data sheet of the Atmega chips.It says that pin change interrupts on any of the PCINTx pins can be used to wake up the Atmega from any of the sleep modes. I.e. any of the 2 switches could also do the trick (theoretically, proof still pending :) )

The MPU6050 also has power management registers, some info can be found here:
http://playground.arduino.cc/Main/MPU-6050

The USB chip FT232RL has a so called USB suspend mode, but shame on me, I could not find in the datasheet how to drive the chip into that state...
Title: Re: Arduino Lightsaber
Post by: neskweek on Mar 09, 2016, 11:40 pm
And from here I visited the data sheet of the Atmega chips.It says that pin change interrupts on any of the PCINTx pins can be used to wake up the Atmega from any of the sleep modes. I.e. any of the 2 switches could also do the trick (theoretically, proof still pending :) )
Well ... I only play 2 hours with LowPower library and this one doesn't seem to agree :P

Title: Re: Arduino Lightsaber
Post by: JakeSoft on Mar 10, 2016, 03:39 am
Here is an early drop of the Universal Saber (USaber) library I've been working on. So far, only a few blades are supported but I have plans to support other hardware and blade types as I can find time to add them.

Blade Types:
CheapieBlade: Emulates the blade behavior of a cheap toy lightsaber!
SingleLedBlade: Basic one-LED blade with power up/down effects and random flicker!
StringBlade: A basic six-segment string blade.

No documentation yet, but here is some unit test code to show intended usage.

Code: [Select]

/*
 * SaberBlades.ino
 *  This will test lightsaber blades!
 
 *  Created on: Mar 8, 2016
 *      Author: JakeSoft
 */


#include "SingleLedBlade.h"
#include "CheapieBlade.h"
#include "StringBlade.h"

#define LED_PIN1 3
#define LED_PIN2 5
#define LED_PIN3 6
#define LED_PIN4 9
#define LED_PIN5 10
#define LED_PIN6 11

void TestBlade(IBladeManager* apBlade)
{
bool lPowerupComplete = false;
bool lPowerdownComplete = false;

apBlade->Init();

Serial.println("On()");
        apBlade->On();
delay(2000);

Serial.println("Off()");
apBlade->Off();
delay(2000);

Serial.println("PowerUp(2000)");
while(!lPowerupComplete)
{
apBlade->SetChannel(255, 0);
lPowerupComplete = apBlade->PowerUp(2000);
}
delay(1500);

Serial.println("PowerDown(2000)");
while(!lPowerdownComplete)
{
lPowerdownComplete = apBlade->PowerDown(2000);
}
delay(1500);

//Note: Testing flicker patterns is skipped if no patterns are supported
for(int lFlicker = 0; lFlicker < apBlade->GetFeatures().Flickers; lFlicker++)
{
Serial.print("Flicker pattern ");
Serial.println((int)lFlicker);

long lStartTime = millis();

//Turn on the blade
apBlade->On();

//Apply flicker for 5 seconds for
while(millis() - lStartTime < 5000)
{
apBlade->ApplyFlicker(lFlicker);
}

//Turn off the blade
apBlade->Off();

delay(1000);
}

//Test setting individual channels
for(int lChannel = 0; lChannel < apBlade->GetFeatures().Channels; lChannel++)
{
Serial.print("Channel ");
Serial.print(lChannel);
for(int lPower = 0; lPower <= 255; lPower++)
{
apBlade->SetChannel(lPower, lChannel);
apBlade->PerformIO();
delay(1);
}
delay(1500);
for(int lPower = 255; lPower >= 0; lPower--)
{
apBlade->SetChannel(lPower, lChannel);
apBlade->PerformIO();
delay(1);
}

apBlade->Off();
}

delay(1000);
}

/**
 * The setup function is called once at startup of the sketch
 */
void setup()
{
  Serial.begin(9600);
}

/**
 * The loop function is called in an endless loop
 */
void loop()
{

Serial.println("\nTesting CheapieBlade");
IBladeManager* lpBlade = new CheapieBlade(LED_PIN1);
TestBlade(lpBlade);
delete lpBlade;

Serial.println("\n\nTesting SingleLedBlade");
lpBlade = new SingleLedBlade(LED_PIN1);
TestBlade(lpBlade);
delete lpBlade;

Serial.println("\n\nTesting StringBlade");
lpBlade = new StringBlade(LED_PIN1, LED_PIN2, LED_PIN3,
                                  LED_PIN4, LED_PIN5, LED_PIN6);
TestBlade(lpBlade);
delete lpBlade;

delay(5000);

}



Comment out the blade types you aren't interested in or, create your own derived class to implement your own custom solution.

I'm hoping this will be step towards standardization that will allow many contributors to supply cross-compatible code for some really gee-wiz lightsaber projects. Try it out and let me know what you guys think. MTFBWY.
Title: Re: Arduino Lightsaber
Post by: neskweek on Mar 10, 2016, 05:36 pm
Ok boys (and girls).

I nailed agressive power save mode with wake up via PCINT interreupts (other PIN than D2 and D3) :

Code: [Select]

#include <avr/sleep.h>
#include <avr/power.h>
#include <avr/interrupt.h> 


timeToDeepSleep = millis();


setup(){
// your stuffs
// Aux button (for example)
PCMSK0 |= (1 << PCINT4); // set PCINT4 (PIN 12) to trigger an interrupt on state change
// Main button (for example)
PCMSK2 |= (1 << PCINT20); // set PCINT20 (PIN 4) to trigger an interrupt on state change
//your stuffs
}


loop{

//Your stuffs
timeToDeepSleep = millis();
deepSleep();
//Your stuffs

}

void deepSleep() {

if (millis() - timeToDeepSleep >= DEEP_SLEEP) {
Serial.println(F("Powersave mode"));
delay(20);


set_sleep_mode(SLEEP_MODE_PWR_DOWN);   // sleep mode is set here
noInterrupts ();
// timed sequence follows

// enables the sleep bit in the mcucr register
sleep_enable();

// disable ADC
byte old_ADCSRA = ADCSRA;
ADCSRA = 0;

// turn off various modules
power_all_disable ();



//Reduce processor frequency
byte oldCLKPR = CLKPR;
CLKPR = bit(CLKPCE);
CLKPR = clock_div_256;

// turn off brown-out enable in software
MCUCR = bit (BODS) | bit(BODSE);  // turn on brown-out enable select
MCUCR = bit(BODS);   // this must be done within 4 clock cycles of above
// guarantees next instruction executed
// sleep within 3 clock cycles of above
interrupts ();
sleep_cpu ();

PCIFR |= bit (PCIF0) | bit(PCIF1) | bit(PCIF2); // clear any outstanding interrupts
PCICR |= bit (PCIE0) | bit(PCIE2); // enable pin change interrupts

sleep_mode();

// THE PROGRAM CONTINUES FROM HERE AFTER WAKING UP
// cancel sleep as a precaution
sleep_disable();
CLKPR = oldCLKPR;
power_all_enable ();
ADCSRA = old_ADCSRA;
CLKPR = bit(CLKPCE);
CLKPR = clock_div_1;
interrupts ();
delay(20);Serial.println(F("Normal mode"));delay(20);
timeToDeepSleep = millis();
}
}



// the followingis not needed if you use SoftwareSerial library or other libraries making use of those interruptes
#if defined(PCINT0_vect)
ISR(PCINT0_vect)

// No need to put stuff in there to make you out of sleep mode

}
#endif

#if defined(PCINT1_vect)
ISR(PCINT1_vect, ISR_ALIASOF(PCINT0_vect));
#endif

#if defined(PCINT2_vect)
ISR(PCINT2_vect, ISR_ALIASOF(PCINT0_vect));
#endif



I've got one problem tho... My ampmeter isn't accurate enough to catch those reading.
It can't read below 200mA :P

If you use main button to make your device wake up, you'll need to press it twice to ignite the saber.
Title: Re: Arduino Lightsaber
Post by: destructables on Mar 10, 2016, 06:50 pm
Here is an early drop of the Universal Saber (USaber) library I've been working on. So far, only a few blades are supported but I have plans to support other hardware and blade types as I can find time to add them.

Blade Types:
CheapieBlade: Emulates the blade behavior of a cheap toy lightsaber!
SingleLedBlade: Basic one-LED blade with power up/down effects and random flicker!
StringBlade: A basic six-segment string blade.

No documentation yet, but here is some unit test code to show intended usage.

Code: [Select]

/*
 * SaberBlades.ino
 *  This will test lightsaber blades!
 
 *  Created on: Mar 8, 2016
 *      Author: JakeSoft
 */


#include "SingleLedBlade.h"
#include "CheapieBlade.h"
#include "StringBlade.h"

#define LED_PIN1 3
#define LED_PIN2 5
#define LED_PIN3 6
#define LED_PIN4 9
#define LED_PIN5 10
#define LED_PIN6 11

void TestBlade(IBladeManager* apBlade)
{
 bool lPowerupComplete = false;
 bool lPowerdownComplete = false;

 apBlade->Init();

 Serial.println("On()");
        apBlade->On();
 delay(2000);

 Serial.println("Off()");
 apBlade->Off();
 delay(2000);

 Serial.println("PowerUp(2000)");
 while(!lPowerupComplete)
 {
 apBlade->SetChannel(255, 0);
 lPowerupComplete = apBlade->PowerUp(2000);
 }
 delay(1500);

 Serial.println("PowerDown(2000)");
 while(!lPowerdownComplete)
 {
 lPowerdownComplete = apBlade->PowerDown(2000);
 }
 delay(1500);

 //Note: Testing flicker patterns is skipped if no patterns are supported
 for(int lFlicker = 0; lFlicker < apBlade->GetFeatures().Flickers; lFlicker++)
 {
 Serial.print("Flicker pattern ");
 Serial.println((int)lFlicker);

 long lStartTime = millis();

 //Turn on the blade
 apBlade->On();

 //Apply flicker for 5 seconds for
 while(millis() - lStartTime < 5000)
 {
 apBlade->ApplyFlicker(lFlicker);
 }

 //Turn off the blade
 apBlade->Off();

 delay(1000);
 }

 //Test setting individual channels
 for(int lChannel = 0; lChannel < apBlade->GetFeatures().Channels; lChannel++)
 {
 Serial.print("Channel ");
 Serial.print(lChannel);
 for(int lPower = 0; lPower <= 255; lPower++)
 {
 apBlade->SetChannel(lPower, lChannel);
 apBlade->PerformIO();
 delay(1);
 }
 delay(1500);
 for(int lPower = 255; lPower >= 0; lPower--)
 {
 apBlade->SetChannel(lPower, lChannel);
 apBlade->PerformIO();
 delay(1);
 }

 apBlade->Off();
 }

 delay(1000);
}

/**
 * The setup function is called once at startup of the sketch
 */
void setup()
{
  Serial.begin(9600);
}

/**
 * The loop function is called in an endless loop
 */
void loop()
{

 Serial.println("\nTesting CheapieBlade");
 IBladeManager* lpBlade = new CheapieBlade(LED_PIN1);
 TestBlade(lpBlade);
 delete lpBlade;

 Serial.println("\n\nTesting SingleLedBlade");
 lpBlade = new SingleLedBlade(LED_PIN1);
 TestBlade(lpBlade);
 delete lpBlade;

 Serial.println("\n\nTesting StringBlade");
 lpBlade = new StringBlade(LED_PIN1, LED_PIN2, LED_PIN3,
                                  LED_PIN4, LED_PIN5, LED_PIN6);
 TestBlade(lpBlade);
 delete lpBlade;

 delay(5000);

}



Comment out the blade types you aren't interested in or, create your own derived class to implement your own custom solution.

I'm hoping this will be step towards standardization that will allow many contributors to supply cross-compatible code for some really gee-wiz lightsaber projects. Try it out and let me know what you guys think. MTFBWY.
Jake, I don't know you personally. But I want to hug you. Seriously.

...was that weird for me to say? Okay I'm just gonna go and sit over here and watch this thing run sample into perpetuity while I get office work done.
Title: Re: Arduino Lightsaber
Post by: JakeSoft on Mar 11, 2016, 12:59 am
Jake, I don't know you personally. But I want to hug you. Seriously.

...was that weird for me to say? Okay I'm just gonna go and sit over here and watch this thing run sample into perpetuity while I get office work done.
Haha! I'm glad it's working for you.
Title: Re: Arduino Lightsaber
Post by: martinmerlino on Mar 11, 2016, 06:15 pm
hello everyone:) can anyone make a skecth from this picture. thanks :)
Title: Re: Arduino Lightsaber
Post by: Canobi on Mar 12, 2016, 11:48 am
Finally got the 3w amp modules :)

(http://i1225.photobucket.com/albums/ee395/Can-obi/IMG_20160308_144510.jpg) (http://s1225.photobucket.com/user/Can-obi/media/IMG_20160308_144510.jpg.html)
(http://i1225.photobucket.com/albums/ee395/Can-obi/IMG_20160309_232920.jpg) (http://s1225.photobucket.com/user/Can-obi/media/IMG_20160309_232920.jpg.html)

The solder pads don't have holes but the exposed pads and lack of componants underneath makes for a kind of SMT hybrid so I set about making a footprint. However, I couldn't find any info regarding pad spacing and dims, so to get round that problem I cropped and scaled a pic of the amp to overlay on screen grabs of footprint edits until I had it right.

The amps will need to be soldered on by hand though as the components on the module have been through the reflow process once already and its not a hood idea to keep subjecting componants to those kinds of temperatures.

With that in mind, my plan is to load the pads with solder paste and sandwich it between the two boards as per the SMT norm, though for this trick to work with an iron, I extended the footprint pads out from under the amp a little so I have somewhere to apply heat:

(http://i1225.photobucket.com/albums/ee395/Can-obi/IMG_20160311_165423.jpg) (http://s1225.photobucket.com/user/Can-obi/media/IMG_20160311_165423.jpg.html)

So far I've only added the amp to the 3.7v board and will look at updating the 7.4v board as soon as I have time.



As a side note, I happen to have a few of these amps going spare, as well as some 2w full range speakers (27mm diameter) so if anyone is in need of either, just hit me up.
Title: Re: Arduino Lightsaber
Post by: JakeSoft on Mar 12, 2016, 01:55 pm
Finally got the 3w amp modules :)

(http://i1225.photobucket.com/albums/ee395/Can-obi/IMG_20160308_144510.jpg) (http://s1225.photobucket.com/user/Can-obi/media/IMG_20160308_144510.jpg.html)
(http://i1225.photobucket.com/albums/ee395/Can-obi/IMG_20160309_232920.jpg) (http://s1225.photobucket.com/user/Can-obi/media/IMG_20160309_232920.jpg.html)
Wow, that's even smaller than the PAM8403 modules I somebody else suggested. They are so cheap, I've bought 5 of them from ebay, but haven't had time to try them out yet.

(http://i.ebayimg.com/00/s/NjUwWDY1MA==/z/WpgAAOxyIv5TkeJ~/$_35.JPG?set_id=880000500F)
Title: Re: Arduino Lightsaber
Post by: JakeSoft on Mar 12, 2016, 10:13 pm
Here is another drop of the Universal Saber library. I put a lot of work into this one to ensure it was compatible with the Arduino IDE. Once you properly install the library, all you should have to do is include the library in the usual way from the IDE.

I verified the library works with IDE versions 1.0.5 and 1.6.5r5.

I provided an abstract base class so that motion detection can be interpreted in a more generic way regardless of what hardware is being used. I also added a simple motion manager example that will work with the tilt+clash sensor combo as was used in my Mk II system. (This is how the cheap toys do it.) The clash is interrupt-driven so you will NEVER miss a clash. Ever. There is a long clash de-bounce to prevent double-trigger. (If you are hitting the saber more than once every 100ms then you're The Flash and should be out fighting crime, not spending time here!)

Updates:
1. Added motion detection!
SimpleMotionManager : Detect motion with swing+clash sensor.

2. Added a new blade type
CrossGuardBlade : A simple two-channel cross-guard blade!

3. Added examples to the library. Examples can be accessed from the IDE in the usual way.
SaberBlades : Test/demo the blades
Motion : Test/demo motion manager

4. Added a copy of the full GPL license. It's free! Keep it free!

I hope you folks find it useful. Feedback welcome.
Title: Re: Arduino Lightsaber
Post by: neskweek on Mar 13, 2016, 03:27 pm
Man ... Great job you've done here (as always :D)!

Thank you !
Title: Re: Arduino Lightsaber
Post by: JcBailey on Mar 13, 2016, 03:52 pm
Hello. I just wanted to say thank you for this thread.

My son got a toy light saber for Christmas and broke it the first day so I set out to do better.
I have never tackled a project like this before so I started researching and found this thread. What at first was going to be a simple lightsaber with a polycarbonate blade is now becoming a replica of Yoda's saber. I have most of the electrical components and am waiting for a few more things to arrive before I start bread boarding.

I have not done an electronic project since high school and have never programmed anything. This project is very exciting and I am grateful for the information provided here and I look forward to sharing my project.

This is a picture of the hilt so far.
Title: Re: Arduino Lightsaber
Post by: JakeSoft on Mar 13, 2016, 07:37 pm
Hello. I just wanted to say thank you for this thread.

My son got a toy light saber for Christmas and broke it the first day so I set out to do better.
I have never tackled a project like this before so I started researching and found this thread. What at first was going to be a simple lightsaber with a polycarbonate blade is now becoming a replica of Yoda's saber. I have most of the electrical components and am waiting for a few more things to arrive before I start bread boarding.

I have not done an electronic project since high school and have never programmed anything. This project is very exciting and I am grateful for the information provided here and I look forward to sharing my project.

This is a picture of the hilt so far.
Welcome! I get a lot of messages and PMs on my YouTube channel and here on the forum from dads just like you. I'm always happy to hear when these videos and threads can help brighten a child's day, be it literal or the child within us all. Best of luck, I look forward to seeing your progress.
Title: Re: Arduino Lightsaber
Post by: JakeSoft on Mar 13, 2016, 07:40 pm
Man ... Great job you've done here (as always :D)!

Thank you !
Thanks, and you're welcome! That's nice to hear from one of the few people who think about saber software as much as I do.  :)
Title: Re: Arduino Lightsaber
Post by: T_R_O_N on Mar 13, 2016, 08:32 pm
I've finally finished reading the whole thread, great work everyone!!

Most of my parts have arrived a few weeks ago, and the last of what I need should arrive this week, then I'll be able to join in on the fun!

There was a post a while ago asking for photos of completed sabres, here I've attached some of mine. I built it last year November for a bit of cosplay at the Starwars Premiere, I also built one for my sister, they are just basic stunt sabres with aluminium tubing hilts.

My next step will be to put the arduino sound system into the hilt.
Title: Re: Arduino Lightsaber
Post by: Protonerd on Mar 13, 2016, 10:15 pm
Here is another drop of the Universal Saber library. I put a lot of work into this one to ensure it was compatible with the Arduino IDE. Once you properly install the library, all you should have to do is include the library in the usual way from the IDE.



I hope you folks find it useful. Feedback welcome.
Hugs from me as well!

Now confronted with LSOS and Usaber I kinda know what I'm going to do after DIYino verification: I'm embarking on a serious study of the secrets of C-coding, using your code as learning vehicle! To be very honest: looking at both of your codes with neskweek, I really do not know how I pulled it off to make my saber at the first place with my meager coding experience.

But hey, I do like learning!
Title: Re: Arduino Lightsaber
Post by: JakeSoft on Mar 14, 2016, 01:32 am
Hugs from me as well!

Now confronted with LSOS and Usaber I kinda know what I'm going to do after DIYino verification: I'm embarking on a serious study of the secrets of C-coding, using your code as learning vehicle! To be very honest: looking at both of your codes with neskweek, I really do not know how I pulled it off to make my saber at the first place with my meager coding experience.

But hey, I do like learning!
Technically, it's C++. But you'll learn. hehe :)
Title: Re: Arduino Lightsaber
Post by: Soulbp on Mar 14, 2016, 03:32 am
I finally finished reading the whole thread, plus most of the led string thread. I believe I'm going to get some of this hardware and throw my hat the ring. I've been away from programing for a few years but I'm a former game deisgner\programer. I've noticed a lot of use of delays in sample code. There are a variety of ways to accomplish the same things without locking up the logic. Can you get timestamps from the CPU clock? You can check time passage or using incremental counters all balanced with if statements. Just some thoughts.
Title: Re: Arduino Lightsaber
Post by: neskweek on Mar 14, 2016, 08:56 am
@Soulbp
Welcome ! It's always nice to see newcomers !

Concerning delays, you're right. The least we use it the better it is. But others solutions (at least all I thought off and try) consume more hex file size. Since we only have 32K ...

I personnaly did remove all delays from "action Mode", but kept the others, since in other mode it's less important.


For Kylo Ren blade lovers, I thought it could be an interesting piece of hardware :
https://www.youtube.com/watch?v=RJ2xGFfrND0
Title: Re: Arduino Lightsaber
Post by: JakeSoft on Mar 14, 2016, 02:54 pm
@Soulbp
Welcome ! It's always nice to see newcomers !

Concerning delays, you're right. The least we use it the better it is. But others solutions (at least all I thought off and try) consume more hex file size. Since we only have 32K ...

I personnaly did remove all delays from "action Mode", but kept the others, since in other mode it's less important.

I agree with neskweek's approach. For time-critical portions of code that are expected to be called with great frequency, time "bookmarking" is  better than delays because it keeps the logic spinning. Anything run while in "action mode" is a good example. When the saber is on, you want quick response from motion sensing and so on, so don't lock up your processor on a delay. But, for less critical code then it makes sense to just keep it as simple as possible and use a delay thereby keeping the hex file size in check. For super-time-critical code, you *should* use delays, such as serial comms. You can't have any variance or your comms won't work. Balance is key to avoid a delay witch-hunt with no benefit.
Title: Re: Arduino Lightsaber
Post by: Soulbp on Mar 14, 2016, 05:12 pm
Hmm... 32k so hmm oop can be an advantage her or disadvantage.. Classes can be used to help reduce redundancy but then you have higher memory usages poetentialy. Seems like a timeelapsed function could be used to replace some delays and keep code redundancy down. Does either the axis unit you use Jake or the unit Nesskweek uses does either one have a method for determining the size of the vectors used? That can be extremely handy in uses velocity based code. I suppose i will contribute to the thread less until I actually have stuff in front of me fo see.
Title: Re: Arduino Lightsaber
Post by: Akavari on Mar 14, 2016, 05:52 pm
Hi guys, just sorry for my English, I really do not speak, and talk through Google perevodchik.Reshil collect nephew lightsaber on the Arduino Nano 3, prompt pozhaluyska, a sketch to use that better garland of LEDs, or one high-power LED, which take sounds lightsaber, and how they add to the sketch for Arduino, thank you in advance)
Title: Re: Arduino Lightsaber
Post by: billpealer on Mar 14, 2016, 07:41 pm
hello everyone:) can anyone make a skecth from this picture. thanks :)
Who ever posted that diagram is probably a hack.  That sketch won't work.
Title: Re: Arduino Lightsaber
Post by: billpealer on Mar 14, 2016, 07:46 pm
Here is another drop of the Universal Saber library. I put a lot of work into this one to ensure it was compatible with the Arduino IDE. Once you properly install the library, all you should have to do is include the library in the usual way from the IDE.

I verified the library works with IDE versions 1.0.5 and 1.6.5r5.

I provided an abstract base class so that motion detection can be interpreted in a more generic way regardless of what hardware is being used. I also added a simple motion manager example that will work with the tilt+clash sensor combo as was used in my Mk II system. (This is how the cheap toys do it.) The clash is interrupt-driven so you will NEVER miss a clash. Ever. There is a long clash de-bounce to prevent double-trigger. (If you are hitting the saber more than once every 100ms then you're The Flash and should be out fighting crime, not spending time here!)

Updates:
1. Added motion detection!
SimpleMotionManager : Detect motion with swing+clash sensor.

2. Added a new blade type
CrossGuardBlade : A simple two-channel cross-guard blade!

3. Added examples to the library. Examples can be accessed from the IDE in the usual way.
SaberBlades : Test/demo the blades
Motion : Test/demo motion manager

4. Added a copy of the full GPL license. It's free! Keep it free!

I hope you folks find it useful. Feedback welcome.
Wow Jake,..  what did you go an do?
I have been out for a week with the fuggin flu and all this has come out!?
Help me out here with some mental prep....  i downloaded the zip,..  but i have  never actually used a library or anyone elses arduino work.

what are the .ino and .cpp files for?   I also do not have arduinio installed on the PC I am using right now.
Title: Re: Arduino Lightsaber
Post by: Protonerd on Mar 14, 2016, 10:53 pm
Ok boys (and girls).

I nailed agressive power save mode with wake up via PCINT interreupts (other PIN than D2 and D3) :


I've got one problem tho... My ampmeter isn't accurate enough to catch those reading.
It can't read below 200mA :P

If you use main button to make your device wake up, you'll need to press it twice to ignite the saber.
Great, simply great! I've copied it into my old saber code and in a blink of an eye I was able to send me device to the Bahamas to relax.

First of all, big cudos, the code works. The saber can be woken up with either one of the switches.

For sure I also made some measurements. Due to the fact that my PSU is also not much better and cannot read anything below 10mA, I had to use a trick. I connected 1.5Ohm (smallest I happened to find at home) in series between the PSU+ and the VIN pin. After that I connected my multimeter between the 2 terminals of this makeshift shunt resistance (in all equipments current metering happens this way in fact).
Current consumed by the circuitry is therefore [U_psu-U_vin]/R_shunt.
During operation I measured between 80mV and 200mV (translating to ~50mA to 130mA (what does it mean: essentially nothing, because it does not reflect actual consumption in a real saber with LEDs on and full speaker activity, so just take the values as are, the deltas interest us!)

If the saber board is in idle mode (i.e. not in config and no in action, but doing nothing) I measured 55mV -> 36mA, then as the device entered sleep mode, I measured 40mV -> 26mA.

My first though was: well, that's not gonna save the world... But it bugged me, because I knew the code was right. So I looked at my board. Power LED of the Arduino Nano happily turned on, same for the LED of the MPU. Bumm, they eat mAs (not exactly sure how much, mut anything from 1mA to 20mA). The deep sleep only affects so far the Atmega, so the DFPlayer and the MPU draw an unknown current. This all means that we need to look at it from a different perspective: we need to consider the delta, which is 10mA.

Then I had the bright idea to simply disconnect the supply of both DFPlayer and the MPU. This reduced the current somewhat, but I expected more. Until I remember how whole chips can be back-supplied through their I/O's. This happened in this case as well, so not only VCC has to be disconnected, but the SCL and SDA of the MPU as well as both Rx and Tx of the DFplayer (and all the rest, busy, int of MPU)! With this more I came to following values:


Summary:
- saber on/action mode:                               50-130mA (just for reference)
- idle mode:                                                36mA
- sleep mode (with code from neskweek):      26mA
- idle mode (disconnect DFPlayer):                21mA
- idle mode (disconnect DFPlayer+MPU):       17mA
- sleep mode (disconnect DFPlayer+MPU):     7.3mA

So the end result of saving approx. 10mA did not change. The code works perfectly, and we do not know what draws the remaining 10mA (for sure LEDs, there is a considerable measurement inaccuracy of my makeshift instrumentation etc., and the FTDI chip probably draws also quite a current). But we know that a power is drawn by the other components as well. This will need on the long run maybe a new concept, either changing HW or (hopefully only) SW.

Big thanks to neskweek for his work, which enabled my measurements.
Title: Re: Arduino Lightsaber
Post by: neskweek on Mar 14, 2016, 11:20 pm
That's great you was able to measure those.

But I'm quite disapointed by the deep sleep readings. Ithought they would be lower :P

Seeing those readings, maybe the fact that I make use of PCINT for wake up, other pins than those of the buttons may still be powered :
 In the code I explecitly ask for DPIN 4 and 12 monitoring, but I didn't inquire the state of the other pins in those silly interrupts register (PCMSK0,PCMSK2) so ....
Title: Re: Arduino Lightsaber
Post by: Soulbp on Mar 15, 2016, 12:33 am
I was theorizing on clash detection with out a clash sensor, this is where delays limit potential. As it's a little different doing collision detection in a game world where you can trace out and find intersection the basic concepts can apply. Using velocity can be very telling however if you are not able to sample the data quickly enough it doesn't matter. A clash would occur when the size of the entire velocity vector is high, then drops abruptly there should be point of zero or near zero follows by a reversal of velocity. This is a bounce. That's what you want, this won't happen as easily without a real impact as even if your arm goes full stop or quickly changes direction you'll have ramp down before the velocity changes to zero and reverse, snapping your arm might approximate this but I'm doubtful it would register quite the same as a legitimate ate impact. To minimize accidental clash you can check both direction of travel and speed of travel.
Title: Re: Arduino Lightsaber
Post by: JakeSoft on Mar 15, 2016, 01:27 am
I was theorizing on clash detection with out a clash sensor, this is where delays limit potential. As it's a little different doing collision detection in a game world where you can trace out and find intersection the basic concepts can apply. Using velocity can be very telling however if you are not able to sample the data quickly enough it doesn't matter. A clash would occur when the size of the entire velocity vector is high, then drops abruptly there should be point of zero or near zero follows by a reversal of velocity. This is a bounce. That's what you want, this won't happen as easily without a real impact as even if your arm goes full stop or quickly changes direction you'll have ramp down before the velocity changes to zero and reverse, snapping your arm might approximate this but I'm doubtful it would register quite the same as a legitimate ate impact. To minimize accidental clash you can check both direction of travel and speed of travel.
That all sounds reasonable. Whip up an algorithm that doesn't consume a ton of memory or CPU and we'll be glad to try it out.

"I shall follow your career with great interest." --Counselor Palpatine
Title: Re: Arduino Lightsaber
Post by: JakeSoft on Mar 15, 2016, 01:34 am
Wow Jake,..  what did you go an do?
I have been out for a week with the fuggin flu and all this has come out!?
Help me out here with some mental prep....  i downloaded the zip,..  but i have  never actually used a library or anyone elses arduino work.

what are the .ino and .cpp files for?   I also do not have arduinio installed on the PC I am using right now.
To install the library, all you should need to do is copy the USaber folder from the .ZIP file to your C:\Users\<user name>\Documents\Arduino\libraries or C:\Users\<user name>\Arduino\libraries folder, depending on what version of the IDE you have installed.

After that, restart your Arduino IDE and USaber will show up under File->Examples. You can open any of the example sketches just like you can with the built in examples.

To include the library in your own sketch, just select Sketch->Import Library and select "USaber". It's really that easy.
Title: Re: Arduino Lightsaber
Post by: Soulbp on Mar 15, 2016, 01:54 am
That all sounds reasonable. Whip up an algorithm that doesn't consume a ton of memory or CPU and we'll be glad to try it out.

"I shall follow your career with great interest." --Counselor Palpatine
Reasonable yes, you point out two possible flaws. I need to read up more on the hardware and libs used. A basics theory might require a custom delay function that does a while loop pulling data from the axis hardware whichever type and breaks out of the loop early for a clash. Anyway, basicly in the main loop depending how frequently you can pull the data you'd want to store the velocity each loop through the code if (VSize(velocity) - VSize(lastloopvelocity) < somemagnitude) /// basicly the initial check would be did the velocity drop a large amount between loops, VSize being the magnitude or speed of the velocity then you can do late individual axis for directions or even see if the speed is + or minus as it should be a float that can give an indication of direction ,or che k first for zero to see if it dropped to zero and then next loop see if it reversed. I'll stop talking theory, I'll wait till I can put it into practice.
Title: Re: Arduino Lightsaber
Post by: neskweek on Mar 15, 2016, 08:38 am
I was theorizing on clash detection with out a clash sensor, this is where delays limit potential. As it's a little different doing collision detection in a game world where you can trace out and find intersection the basic concepts can apply. Using velocity can be very telling however if you are not able to sample the data quickly enough it doesn't matter. A clash would occur when the size of the entire velocity vector is high, then drops abruptly there should be point of zero or near zero follows by a reversal of velocity. This is a bounce. That's what you want, this won't happen as easily without a real impact as even if your arm goes full stop or quickly changes direction you'll have ramp down before the velocity changes to zero and reverse, snapping your arm might approximate this but I'm doubtful it would register quite the same as a legitimate ate impact. To minimize accidental clash you can check both direction of travel and speed of travel.
Yeah theory is cool. That's the exact thought I did use when started movement detection.

IMUs on the other hand does not detect deceleration fast enough. At least mine.
With this theory , you may  also trigger clash on fast movements when changing direction.
Title: Re: Arduino Lightsaber
Post by: billpealer on Mar 15, 2016, 02:23 pm
Ok boys (and girls).

I nailed agressive power save mode with wake up via PCINT interreupts (other PIN than D2 and D3) :

Code: [Select]

#include <avr/sleep.h>
#include <avr/power.h>
#include <avr/interrupt.h> 


timeToDeepSleep = millis();


setup(){
// your stuffs
// Aux button (for example)
PCMSK0 |= (1 << PCINT4); // set PCINT4 (PIN 12) to trigger an interrupt on state change
// Main button (for example)
PCMSK2 |= (1 << PCINT20); // set PCINT20 (PIN 4) to trigger an interrupt on state change
//your stuffs
}


loop{

//Your stuffs
timeToDeepSleep = millis();
deepSleep();
//Your stuffs

}

void deepSleep() {

if (millis() - timeToDeepSleep >= DEEP_SLEEP) {
Serial.println(F("Powersave mode"));
delay(20);


set_sleep_mode(SLEEP_MODE_PWR_DOWN);   // sleep mode is set here
noInterrupts ();
// timed sequence follows

// enables the sleep bit in the mcucr register
sleep_enable();

// disable ADC
byte old_ADCSRA = ADCSRA;
ADCSRA = 0;

// turn off various modules
power_all_disable ();



//Reduce processor frequency
byte oldCLKPR = CLKPR;
CLKPR = bit(CLKPCE);
CLKPR = clock_div_256;

// turn off brown-out enable in software
MCUCR = bit (BODS) | bit(BODSE);  // turn on brown-out enable select
MCUCR = bit(BODS);   // this must be done within 4 clock cycles of above
// guarantees next instruction executed
// sleep within 3 clock cycles of above
interrupts ();
sleep_cpu ();

PCIFR |= bit (PCIF0) | bit(PCIF1) | bit(PCIF2); // clear any outstanding interrupts
PCICR |= bit (PCIE0) | bit(PCIE2); // enable pin change interrupts

sleep_mode();

// THE PROGRAM CONTINUES FROM HERE AFTER WAKING UP
// cancel sleep as a precaution
sleep_disable();
CLKPR = oldCLKPR;
power_all_enable ();
ADCSRA = old_ADCSRA;
CLKPR = bit(CLKPCE);
CLKPR = clock_div_1;
interrupts ();
delay(20);Serial.println(F("Normal mode"));delay(20);
timeToDeepSleep = millis();
}
}



// the followingis not needed if you use SoftwareSerial library or other libraries making use of those interruptes
#if defined(PCINT0_vect)
ISR(PCINT0_vect)

// No need to put stuff in there to make you out of sleep mode

}
#endif

#if defined(PCINT1_vect)
ISR(PCINT1_vect, ISR_ALIASOF(PCINT0_vect));
#endif

#if defined(PCINT2_vect)
ISR(PCINT2_vect, ISR_ALIASOF(PCINT0_vect));
#endif



I've got one problem tho... My ampmeter isn't accurate enough to catch those reading.
It can't read below 200mA :P

If you use main button to make your device wake up, you'll need to press it twice to ignite the saber.
thanks for this. i really have no plan on making a kill switch.

Are you going to attach the .h libraries so we can include them?
Title: Re: Arduino Lightsaber
Post by: Soulbp on Mar 15, 2016, 02:48 pm
Yeah theory is cool. That's the exact thought I did use when started movement detection.

IMUs on the other hand does not detect deceleration fast enough. At least mine.
With this theory , you may  also trigger clash on fast movements when changing direction.
Thanks that's what I was hoping for from people who have handled the hardware. I was curious how refined IMU data is as it's essentially little balls pressing against walls, so I wasn't how well in practice it would be let alone how quickly you could sample the data.
Title: Re: Arduino Lightsaber
Post by: Soulbp on Mar 15, 2016, 04:01 pm
http://www.digikey.com/product-search/en?v=497&mpart=H3LIS331DLTR
This may be a solution as it seems impact/collision detection is harder on the 6050 etc because they are low g. High g will give more refined data.
Title: Re: Arduino Lightsaber
Post by: neskweek on Mar 15, 2016, 05:24 pm
Those are 3 axis accelerometer.

I am currently trying to have contacts with some companies who makes piezo tubes.

A simple piezo tube in the emiter should be enough to detect clashes and lockups. In theroy ;)

But for clashes the code Protonerd came up with on MPU6050 devices  is really neat. And it works with a damned high precision.
Title: Re: Arduino Lightsaber
Post by: stinky1 on Mar 15, 2016, 07:25 pm
Can anyone update this drawing for a RGB 750mah type Luxeon Star/Cree type emitter?
I plan on using the Version 7 Type architecture with the state your own colors coding.
So many changes in mrk 8 compiliator compilation,  I'm wondering if it still works!!  It's just I can't afford to burn anything out as I have like no money left.

http://s1073.photobucket.com/user/cest_bastien1/media/Lightsaber/AS2_LEDstringSaberArduino_NeskweekRevised_zpsu5k0ljck.png.html

Damn thing is I ordered a 3w total,  1 watt per LED RGB star and the resistors to
limit them.   Figured out the Nano and PWM limits them from frying.=wasted dough/   So forget the 3w one,and i'll order a 9watt one,  just so all this isn't so confusing, as it seems everyone goes for the higher wattage one,  and it is the ones (9w) used in builds,  so KISS.
Order another part.......

You guys are making mad progress!!!  Thanks millions!

Ahhh more to buy......
Title: Re: Arduino Lightsaber
Post by: JakeSoft on Mar 16, 2016, 01:27 am
Anybody want to contribute an MPU6050 MotionManager to the USaber library? That seems to be the popular choice over in Proto's thread. I don't have the hardware to test it myself.
Title: Re: Arduino Lightsaber
Post by: neskweek on Mar 16, 2016, 08:12 am
Anybody want to contribute an MPU6050 MotionManager to the USaber library? That seems to be the popular choice over in Proto's thread. I don't have the hardware to test it myself.
If no one does it before I will. But I'll be quite busy until the end of this month
Title: Re: Arduino Lightsaber
Post by: JakeSoft on Mar 17, 2016, 12:26 am
If no one does it before I will. But I'll be quite busy until the end of this month
We're not on a clock here. ;)
Title: Re: Arduino Lightsaber
Post by: honcka on Mar 17, 2016, 12:35 am
Hello,
My 5 year son want lightsaber, but i dont want buy comercial craps,i found interesting LightSaberOS. I tried to make this exactly by the walkthrough, but i stucked on importing library, i still see only basic but no library from the imported project. I am sorry for lammer question
Title: Re: Arduino Lightsaber
Post by: neskweek on Mar 17, 2016, 08:56 am
Hey Honcka ! Welcome !

From readme ;)
Quote
1. If not already done create this directory : C:\Users\[YOUR USER]\Arduino
2. Copy and Paste LightSaberOS-master\Libraries directory inside C:\Users\[YOUR USER]\Arduino
After done this, start import process again from point 5.

@Everyone
Please post errors concerning LSOS on github (https://github.com/neskweek/LightSaberOS/issues/new).
Let's keep those thread as clean as possible ;)

I won't answer those on this forum anymore !
Title: Re: Arduino Lightsaber
Post by: billpealer on Mar 21, 2016, 03:30 pm
is there going to be mention or a link, as to where these items live?

#include <avr/sleep.h>
#include <avr/power.h>
#include <avr/interrupt.h>

Nesweek,  your power save code does not work with out it.

Proto, you tested this?  Where did you download the libraries?
Title: Re: Arduino Lightsaber
Post by: Stemplar on Mar 21, 2016, 06:01 pm
Hello: I´m from to Argentina. This is my first and partial ligthsaber proyect.

Video:

https://youtu.be/CkjhoDr0pjs (https://youtu.be/CkjhoDr0pjs)

- Nano Arduino
- WT588-U (One Line)
- 74CH595 (Shift Register Chip)
- UNL2803 (Darlintong Chip)
- 8 Led (replaced by 8 segments of 8 LEDs).
- Own Soft (no copy).

Thanks
Marcelo

Title: Re: Arduino Lightsaber
Post by: jshaw on Mar 21, 2016, 06:07 pm
Hello: I´m from to Argentina. This is my first and partial ligthsaber proyect.

Video:

https://youtu.be/CkjhoDr0pjs (https://youtu.be/CkjhoDr0pjs)

- Nano Arduino
- WT588-U (One Line)
- 74CH595 (Shift Register Chip)
- UNL2803 (Darlintong Chip)
- 8 Led (replaced by 8 segments of 8 LEDs).
- Own Soft (no copy).

Thanks
Marcelo


Very nice!  I'd be interested to hear how you are using the 74CH595 and UNL2803? 
Title: Re: Arduino Lightsaber
Post by: Stemplar on Mar 21, 2016, 08:34 pm
Very nice!  I'd be interested to hear how you are using the 74CH595 and UNL2803? 
Thank you, JSHAW.

The chip 74CH595, I use it to turn 8 segments of LEDs, with only three digital outputs from NANO.

The UNL2803 chip, I use it for when you need to turn 64 LEDs. That is, when you need to manage power.

Greetings.
Title: Re: Arduino Lightsaber
Post by: Stemplar on Mar 21, 2016, 08:41 pm
I have a problem with my design.

For sound, I use the WT588-U chip, but only allows me to handle 4 sounds.

When I recorded the sound fifth in both One-Wire and Three-Line or KEY mode, the positions of the sounds change when I enter the loop, and I can not wear them in the position that I recorded.

The module is the WT588-U (28 Pins)

Does anyone know, how to properly call sounds from the loop?

Thanks
Title: Re: Arduino Lightsaber
Post by: JakeSoft on Mar 22, 2016, 02:59 am
I'll just leave this right here.

https://youtu.be/2gKd2tWIF-E (https://youtu.be/2gKd2tWIF-E)

I took a look at the manual and the serial commands look pretty robust (after painfully running the command table through Google to translate from Chinese to English, of course).

Dude even made a library with basic functionality which could be expanded upon:
https://github.com/Critters/MP3FLASH16P (https://github.com/Critters/MP3FLASH16P)

I attached my translated serial commands. Not to get us too far off track, but I may pick one of these up for experimenting. It could be one more sound module to add to the USaber library. (I'm working on adding sound support, I swear!)

Title: Re: Arduino Lightsaber
Post by: Stemplar on Mar 22, 2016, 05:32 pm
Thank you, JakeSoft

I will work to experience this method.

I will keep you informed.

But... Is there any library for my WT588-U (28p) or WT588-16P ?
Title: Re: Arduino Lightsaber
Post by: JakeSoft on Mar 22, 2016, 10:19 pm
Thank you, JakeSoft

I will work to experience this method.

I will keep you informed.

But... Is there any library for my WT588-U (28p) or WT588-16P ?
Everything you need to control WT588D over one-line serial is in post #47 of this thread.
Title: Re: Arduino Lightsaber
Post by: Stemplar on Mar 23, 2016, 01:33 pm
Here is the code for the One-line serial mode.
Just remember to change de config in the WT588D programmer.

Code: [Select]

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);
}


Yes, I tried with this code, but... when i record the sound 5 (0 to 4) in the module WT588D-U (28P), after to ejecute the first time all sounds, there is a shift of sounds.

The number 0 ceases to be 0 and became 4.
Number 1 ceases to be 1 and became 1.
Number 2 ceases to be 2 and 3 became.
-
-
-
-
Number 5 ceases to be 5 became the 0.

Is there any solution for this?.

P/D: sorry for my bad english, but I am Spanish.
Title: Re: Arduino Lightsaber
Post by: neskweek on Mar 25, 2016, 09:28 am
Hey guys !

is that what you call a recharge port/kill switch (5.5mmx2.1mm DC Power jack socket female) ? :
(http://g02.a.alicdn.com/kf/HTB1cXCdKVXXXXX2apXXq6xXFXXXE/Promotion-5-Pcs-5-5mmx2-1mm-DC-Power-Jack-Socket-Female-Panel-Mount-Connector.jpg_640x640.jpg)
Title: Re: Arduino Lightsaber
Post by: JakeSoft on Mar 25, 2016, 02:22 pm
Hey guys !

is that what you call a recharge port/kill switch (5.5mmx2.1mm DC Power jack socket female) ? :

Yup.
Title: Re: Arduino Lightsaber
Post by: splinter182 on Mar 25, 2016, 04:04 pm
I'll just leave this right here.

https://youtu.be/2gKd2tWIF-E (https://youtu.be/2gKd2tWIF-E)

I took a look at the manual and the serial commands look pretty robust (after painfully running the command table through Google to translate from Chinese to English, of course).

Dude even made a library with basic functionality which could be expanded upon:
https://github.com/Critters/MP3FLASH16P (https://github.com/Critters/MP3FLASH16P)

I attached my translated serial commands. Not to get us too far off track, but I may pick one of these up for experimenting. It could be one more sound module to add to the USaber library. (I'm working on adding sound support, I swear!)


This looks like the same module that Protonerd is using on his project with flash memory instead of the microsd card slot. I've been working on adding wt588d support to LSOS for my own saber and while going thru  neskweek code it looked like DFPlayer library already has code in place to handle using a MP3-Flash-16p module. It takes a parameter for memory type and flash is one of the options.

Also jake, I'm sorry i never got back to you on hangout. (i asked you as question about wt588d) I made a stupid mistake, i didn't realize i had to set up my playlists.
Title: Re: Arduino Lightsaber
Post by: JakeSoft on Mar 25, 2016, 04:18 pm
This looks like the same module that Protonerd is using on his project with flash memory instead of the microsd card slot. I've been working on adding wt588d support to LSOS for my own saber and while going thru  neskweek code it looked like DFPlayer library already has code in place to handle using a MP3-Flash-16p module. It takes a parameter for memory type and flash is one of the options.
Hey, you might be right! Great observation! After your post, I dissected neskweek's DFPlayer code that he includes with LightSaberOS. The commands look to be identical. That's great news. It means somebody has already laid a lot of the ground work.

I'd actually prefer USB over SD. One could route a small extension cable to an external port on their hilt and then program new sounds without ever taking the hilt apart! Try that with an SD card.
Title: Re: Arduino Lightsaber
Post by: splinter182 on Mar 25, 2016, 05:27 pm
Hey guys !

is that what you call a recharge port/kill switch (5.5mmx2.1mm DC Power jack socket female) ? :
(http://g02.a.alicdn.com/kf/HTB1cXCdKVXXXXX2apXXq6xXFXXXE/Promotion-5-Pcs-5-5mmx2-1mm-DC-Power-Jack-Socket-Female-Panel-Mount-Connector.jpg_640x640.jpg)
Yes those are exactly it!

follow this link for the wiring:
http://forums.thecustomsabershop.com/showthread.php?2235-Recharge-port-hookup (http://forums.thecustomsabershop.com/showthread.php?2235-Recharge-port-hookup)
Title: Re: Arduino Lightsaber
Post by: splinter182 on Mar 25, 2016, 05:40 pm
Hey, you might be right! Great observation! After your post, I dissected neskweek's DFPlayer code that he includes with LightSaberOS. The commands look to be identical. That's great news. It means somebody has already laid a lot of the ground work.

I'd actually prefer USB over SD. One could route a small extension cable to an external port on their hilt and then program new sounds without ever taking the hilt apart! Try that with an SD card.
That is true, and with limited space its hard to make things easily removable!

I've found the site of the ebay vendor of the MP3-Flash-16p module, cheaper than ebay and free shipping.

http://www.uctronics.com/64m-bit-mp3-voice-module-serial-spi-flash-ssop24-amplifier-mini-usb-for-arduino.html (http://www.uctronics.com/64m-bit-mp3-voice-module-serial-spi-flash-ssop24-amplifier-mini-usb-for-arduino.html)
Title: Re: Arduino Lightsaber
Post by: neskweek on Mar 25, 2016, 07:42 pm
Yes those are exactly it!

follow this link for the wiring:
http://forums.thecustomsabershop.com/showthread.php?2235-Recharge-port-hookup (http://forums.thecustomsabershop.com/showthread.php?2235-Recharge-port-hookup)

Thanks guys. I wanted to be sure before ordering them.
I'd like to order those via TCSS but I leave in europe and 50€ of transport is just not acceptable for me.

I found another source for those , if some of you are interested and if you're not in a hurry (15days delivery min), I'll give you the link via PM.

Finally thank you for the wirings instruction ;)
Title: Re: Arduino Lightsaber
Post by: JakeSoft on Mar 25, 2016, 08:23 pm
That is true, and with limited space its hard to make things easily removable!

I've found the site of the ebay vendor of the MP3-Flash-16p module, cheaper than ebay and free shipping.

http://www.uctronics.com/64m-bit-mp3-voice-module-serial-spi-flash-ssop24-amplifier-mini-usb-for-arduino.html (http://www.uctronics.com/64m-bit-mp3-voice-module-serial-spi-flash-ssop24-amplifier-mini-usb-for-arduino.html)
Thanks for the link. This guy seems to have all kinds of goodies for sale. :)

I wonder how much flash memory the module actually has. The product description says it can support between 2M and 16M but it doesn't actually say how much is on the one being sold. 2M might be just enough for one font at a low quality sample rate, but 16M would give you breathing room for perhaps 2 or more at a high sample rate. The later being preferable, of course.
Title: Re: Arduino Lightsaber
Post by: splinter182 on Mar 25, 2016, 09:56 pm
Thanks for the link. This guy seems to have all kinds of goodies for sale. :)

I wonder how much flash memory the module actually has. The product description says it can support between 2M and 16M but it doesn't actually say how much is on the one being sold. 2M might be just enough for one font at a low quality sample rate, but 16M would give you breathing room for perhaps 2 or more at a high sample rate. The later being preferable, of course.
Yes, he has tons of cool stuff. Seems like the sound chip is being used on various different boards and is able to even use a usb flash drive as storage.

The module in the link is for the 64mbit module, so 8 MB of space.
i don't see a 16MB module but shouldn't be too hard to find a 16mb spi flash chip and swap it.
They event suggest a 16MB chip, the W25Q128.
Title: Re: Arduino Lightsaber
Post by: JakeSoft on Mar 26, 2016, 12:12 am
Yes, he has tons of cool stuff. Seems like the sound chip is being used on various different boards and is able to even use a usb flash drive as storage.

The module in the link is for the 64mbit module, so 8 MB of space.
i don't see a 16MB module but shouldn't be too hard to find a 16mb spi flash chip and swap it.
They event suggest a 16MB chip, the W25Q128.
Well, 8M is workable at least. I've used a WT588Ds with only 8M and was able to fit 2 fonts and some low-sample-rate menu sounds too. With easy sound upload via USB, switching to new sounds frequently is easy anyway.
Title: Re: Arduino Lightsaber
Post by: Canobi on Mar 26, 2016, 07:08 pm
Hey guys

It's time for me to get acquainted properly with the WT programming as the boards are pretty much finished. Filming the last phase is turning out not to be as straightforward as the last two parts were and I've had to cheat and done a couple steps twice which has slowed things down a tad, sorey bout that.

However, I have improved the solder resist process in doing so and the results are much more consistent and are much better quality than I was getting before so it's not all bad.

 
Anyhoo, I've had an idea for a blaster fx core using the WT in key mode and was pondering on making use of the BUSY pin but I can't for the love of me find any info regarding the pin's voltage and current ratings.

Anyone know what they are?
Title: Re: Arduino Lightsaber
Post by: Protonerd on Mar 26, 2016, 07:27 pm
Well, 8M is workable at least. I've used a WT588Ds with only 8M and was able to fit 2 fonts and some low-sample-rate menu sounds too. With easy sound upload via USB, switching to new sounds frequently is easy anyway.
I was intrigued so I just looked at how much storage space all 8 of my high-quality saber fonts (all from SaberFont, no advertisement intended, and I was quite affronted by one of the "artists" covertly accusing me of piracy in a comment to one of my YouTube videos, but you can find really good ones there) take, it's 23MB. They are really good fonts, and after some years building saber replicas in my opinion 4-5 fonts are more than enough. You will settle very fast for some favorites...
Title: Re: Arduino Lightsaber
Post by: JakeSoft on Mar 26, 2016, 10:56 pm
Ok, guys. Here is another drop of the Universal Saber library. The major addition is: Sound! I finally added sound support. And let me tell you, this one didn't come easy. I added an example of how to implement a sound-handling class by creating a saber sound player for the WT588D. I'm still working on multi-font support, but the interface will at least support one sound font plus menu sounds. This is likely enough for simple projects.

1. Added sound support!
WT588DSoundPlayer: A sabers sound player for the WT588D.

You have to parameterize it to tell it how many sound of each type (swing, clash, power-up, etc) you have by populating a data structure. This is an alternative to a bunch of #define or const int statements that have typically been used. It puts it all in one convenient place. These are all things you would have to define anyway, the constructor just forces you to do it up front.

So for example, if you had in your WT588D equations (play lists) programmed like this:
0x00 = Power Up
0x01 = Hum
0x02 = Swing
0x03 = Clash 1
0x04 = Clash 2
0x05 = Power Down

You'd parameterize as in the following example sketch:
Code: [Select]

#include<USaber.h>

//The data structure that describes your sound layout
WT588DSoundMap gSoundMap;

//Pointer to the actual sound player
ASoundPlayer* gpSaberSound;

//The I/O pin for one-line serial comms
#define WT588D_SDA 13

void setup()
{
  //Sound font features
  gSoundMap.Features.PowerUpSoundsPerFont = 1;
  gSoundMap.Features.HumSoundsPerFont = 1;
  gSoundMap.Features.SwingSoundsPerFont = 1;
  gSoundMap.Features.ClashSoundsPerFont = 2; //0x03 and 0x04 are clash sounds
  gSoundMap.Features.PowerDownSoundsPerFont = 1;

  //Base address offset for all sounds (typically zero)
  gSoundMap.Locations.BaseAddr = 0;

  //Sound locations on the module
  gSoundMap.Locations.PowerupBase = 0;
  gSoundMap.Locations.HumBase = 1; 
  gSoundMap.Locations.SwingBase = 2;
  gSoundMap.Locations.ClashBase = 3; //0x03 and 0x04 are clash sounds
  gSoundMap.Locations.PowerdownBase = 5;
 

  //Now create the player
  gpSaberSound = new WT588DSoundPlayer(WT588D_SDA, &gSoundMap);

  //And intialize it
  gpSaberSound->Init();
}

void loop()
{
  //code code code...

  //Get to a place where you want play a power up sound and...
  gpSaberSound->PlaySound(eePowerUpSnd, 0); //Play the 0th (the first) power-up sound

  //blah blah blah...

  //Get to a place where you want to play a random clash sound...
  gpSaberSound->PlayRandomSound(eeClashSnd);
}


2. Fixed a bug in SimpleMotionManager that would sometimes allow double-trigger on clash events.

Whew, I need a break. I hope you all enjoy. MTFBWY.
Title: Re: Arduino Lightsaber
Post by: JakeSoft on Mar 26, 2016, 11:02 pm
I was intrigued so I just looked at how much storage space all 8 of my high-quality saber fonts (all from SaberFont, no advertisement intended, and I was quite affronted by one of the "artists" covertly accusing me of piracy in a comment to one of my YouTube videos, but you can find really good ones there) take, it's 23MB. They are really good fonts, and after some years building saber replicas in my opinion 4-5 fonts are more than enough. You will settle very fast for some favorites...
You may be able to plop down a 16MB flash chip in place of your SD card on a future revision of DIYino. You'll get that USB-sound transfer feature you were looking for a while back in a conversation I remember. I could see two USB ports: One for the MCU, one for the sound. Might take up less room than the SD card too.

And you are right about settling on favorites. I've reprogrammed my Mk. II with several fonts since I built it, but I keep going back to my original set. It supports 3 fonts, but only use my favorite one of them 90% of the time.
Title: Re: Arduino Lightsaber
Post by: Stemplar on Mar 28, 2016, 04:58 pm
Ok, guys. Here is another drop of the Universal Saber library. The major addition is: Sound! I finally added sound support. And let me tell you, this one didn't come easy. I added an example of how to implement a sound-handling class by creating a saber sound player for the WT588D. I'm still working on multi-font support, but the interface will at least support one sound font plus menu sounds. This is likely enough for simple projects.

1. Added sound support!
WT588DSoundPlayer: A sabers sound player for the WT588D.

You have to parameterize it to tell it how many sound of each type (swing, clash, power-up, etc) you have by populating a data structure. This is an alternative to a bunch of #define or const int statements that have typically been used. It puts it all in one convenient place. These are all things you would have to define anyway, the constructor just forces you to do it up front.

So for example, if you had in your WT588D equations (play lists) programmed like this:
0x00 = Power Up
0x01 = Hum
0x02 = Swing
0x03 = Clash 1
0x04 = Clash 2
0x05 = Power Down

You'd parameterize as in the following example sketch:
Code: [Select]

#include<USaber.h>

//The data structure that describes your sound layout
WT588DSoundMap gSoundMap;

//Pointer to the actual sound player
ASoundPlayer* gpSaberSound;

//The I/O pin for one-line serial comms
#define WT588D_SDA 13

void setup()
{
  //Sound font features
  gSoundMap.Features.PowerUpSoundsPerFont = 1;
  gSoundMap.Features.HumSoundsPerFont = 1;
  gSoundMap.Features.SwingSoundsPerFont = 1;
  gSoundMap.Features.ClashSoundsPerFont = 2; //0x03 and 0x04 are clash sounds
  gSoundMap.Features.PowerDownSoundsPerFont = 1;

  //Base address offset for all sounds (typically zero)
  gSoundMap.Locations.BaseAddr = 0;

  //Sound locations on the module
  gSoundMap.Locations.PowerupBase = 0;
  gSoundMap.Locations.HumBase = 1; 
  gSoundMap.Locations.SwingBase = 2;
  gSoundMap.Locations.ClashBase = 3; //0x03 and 0x04 are clash sounds
  gSoundMap.Locations.PowerdownBase = 5;
 

  //Now create the player
  gpSaberSound = new WT588DSoundPlayer(WT588D_SDA, &gSoundMap);

  //And intialize it
  gpSaberSound->Init();
}

void loop()
{
  //code code code...

  //Get to a place where you want play a power up sound and...
  gpSaberSound->PlaySound(eePowerUpSnd, 0); //Play the 0th (the first) power-up sound

  //blah blah blah...

  //Get to a place where you want to play a random clash sound...
  gpSaberSound->PlayRandomSound(eeClashSnd);
}


2. Fixed a bug in SimpleMotionManager that would sometimes allow double-trigger on clash events.

Whew, I need a break. I hope you all enjoy. MTFBWY.
EXCELENT JAKESOFT ...... !!!!!!

In the future, I will try this library.
Title: Re: Arduino Lightsaber
Post by: Stemplar on Mar 28, 2016, 05:03 pm
In the past weekend, I have advanced in my project.

I found a library, a talking clock that left me run sounds WT588D-U.

I share a video of the tests.

Prueba de Sable - Massabers (https://youtu.be/FF3J5MX3iO8)


Now we must work on the look and feel of the saber.

Thanks to all for the help.



Title: Re: Arduino Lightsaber
Post by: Protonerd on Mar 28, 2016, 09:06 pm
You may be able to plop down a 16MB flash chip in place of your SD card on a future revision of DIYino. You'll get that USB-sound transfer feature you were looking for a while back in a conversation I remember. I could see two USB ports: One for the MCU, one for the sound. Might take up less room than the SD card too.
You remember right, once I reach break-even with my DIYino design, I want to embark on a quest for a high-end Arduino saber core. I already sketched up in my mind the core requirements:
1. Flash instead of SD
2. Equally important in my eyes is that it must have only a single USB port. An USB takes up nearly the same room as an SD, and latter is flatter.
3. I think about an Atmega with more memory.
4. Use flash to store arbitrary data accessible by the uC.

However this one I intend to do in a team.
Title: Re: Arduino Lightsaber
Post by: splinter182 on Mar 28, 2016, 11:35 pm
Ok, guys. Here is another drop of the Universal Saber library. The major addition is: Sound! I finally added sound support. And let me tell you, this one didn't come easy. I added an example of how to implement a sound-handling class by creating a saber sound player for the WT588D. I'm still working on multi-font support, but the interface will at least support one sound font plus menu sounds. This is likely enough for simple projects.

1. Added sound support!
WT588DSoundPlayer: A sabers sound player for the WT588D.

You have to parameterize it to tell it how many sound of each type (swing, clash, power-up, etc) you have by populating a data structure. This is an alternative to a bunch of #define or const int statements that have typically been used. It puts it all in one convenient place. These are all things you would have to define anyway, the constructor just forces you to do it up front.

So for example, if you had in your WT588D equations (play lists) programmed like this:
0x00 = Power Up
0x01 = Hum
0x02 = Swing
0x03 = Clash 1
0x04 = Clash 2
0x05 = Power Down

You'd parameterize as in the following example sketch:
Code: [Select]

#include<USaber.h>

//The data structure that describes your sound layout
WT588DSoundMap gSoundMap;

//Pointer to the actual sound player
ASoundPlayer* gpSaberSound;

//The I/O pin for one-line serial comms
#define WT588D_SDA 13

void setup()
{
  //Sound font features
  gSoundMap.Features.PowerUpSoundsPerFont = 1;
  gSoundMap.Features.HumSoundsPerFont = 1;
  gSoundMap.Features.SwingSoundsPerFont = 1;
  gSoundMap.Features.ClashSoundsPerFont = 2; //0x03 and 0x04 are clash sounds
  gSoundMap.Features.PowerDownSoundsPerFont = 1;

  //Base address offset for all sounds (typically zero)
  gSoundMap.Locations.BaseAddr = 0;

  //Sound locations on the module
  gSoundMap.Locations.PowerupBase = 0;
  gSoundMap.Locations.HumBase = 1; 
  gSoundMap.Locations.SwingBase = 2;
  gSoundMap.Locations.ClashBase = 3; //0x03 and 0x04 are clash sounds
  gSoundMap.Locations.PowerdownBase = 5;
 

  //Now create the player
  gpSaberSound = new WT588DSoundPlayer(WT588D_SDA, &gSoundMap);

  //And intialize it
  gpSaberSound->Init();
}

void loop()
{
  //code code code...

  //Get to a place where you want play a power up sound and...
  gpSaberSound->PlaySound(eePowerUpSnd, 0); //Play the 0th (the first) power-up sound

  //blah blah blah...

  //Get to a place where you want to play a random clash sound...
  gpSaberSound->PlayRandomSound(eeClashSnd);
}


2. Fixed a bug in SimpleMotionManager that would sometimes allow double-trigger on clash events.

Whew, I need a break. I hope you all enjoy. MTFBWY.
Awesome work JakeSoft!

I think i'm gonna have to do a LSOS and USaber hybrid.
Title: Re: Arduino Lightsaber
Post by: Soulbp on Mar 29, 2016, 03:27 am
There is a place just down the street from me that makes PCBs, they also populate boards etc,.. After I get everything working I was planing on going-over to them to see what they can do. They maybe able give me some direction on both the flash and single USB for all shortage. I'd also like ubs recharge for the batteries if it can all be one port. That kills alot of birds with one stone.
Title: Re: Arduino Lightsaber
Post by: JakeSoft on Mar 30, 2016, 12:26 am
There is a place just down the street from me that makes PCBs, they also populate boards etc,.. After I get everything working I was planing on going-over to them to see what they can do. They maybe able give me some direction on both the flash and single USB for all shortage. I'd also like ubs recharge for the batteries if it can all be one port. That kills alot of birds with one stone.
Lucky you! That'll make shipping a non-issue for you. Are you state side? So far, the only folks who have shown enough ambition to build PCBs are in Europe. Great for them, but the shipping is painful for us Yankees.
Title: Re: Arduino Lightsaber
Post by: Soulbp on Mar 30, 2016, 01:02 am
Yes, im state side. Once I have a working model and talk to them I can let you know what they quote and what they say.
Title: Re: Arduino Lightsaber
Post by: Protonerd on Mar 30, 2016, 10:54 pm
Lucky you! That'll make shipping a non-issue for you. Are you state side? So far, the only folks who have shown enough ambition to build PCBs are in Europe. Great for them, but the shipping is painful for us Yankees.
No need to shed Yankee tears :) I talked to the local post clerk, it seems an insured, bubble foil envelope costs about 10$, actually no matter where I send it (US the same as when I send to a neighboring country), non-insured is ~4$.
Title: Re: Arduino Lightsaber
Post by: Protonerd on Mar 30, 2016, 11:18 pm
Look what I've found:
http://www.ebay.de/itm/4-Stueck-USB-Rechargeable-4200mAh-3-7V-BRC-18650-Batterie-Battery-Li-ion-AKKU-UK-/272065940619?_trksid=p2141725.m3641.l6368

A 3.7V type 18650 battery with in-built USB recharger...? How cool is that? It seems it's only slightly longer (67mm instead of 65) but has a great capacity. Maybe such a battery can be tweaked to connect to the USB of the board and have it charged while connected.
Title: Re: Arduino Lightsaber
Post by: JakeSoft on Mar 31, 2016, 01:42 am
No need to shed Yankee tears :) I talked to the local post clerk, it seems an insured, bubble foil envelope costs about 10$, actually no matter where I send it (US the same as when I send to a neighboring country), non-insured is ~4$.
Well, that's good news. For comparison, domestic uninsured padded envelope from the United States Postal Service is ~2 USD according to my local post office. It goes up from there depending on how much insurance you add.
Title: Re: Arduino Lightsaber
Post by: Canobi on Apr 01, 2016, 11:30 pm
Hi guys

Started populating the boards only to find the provided SOT-23-5 footprint (used for the 3v3 regulator) is way off scale so had to make my own and mod the layout artwork. Major bummer as finding the couple hrs straight needed to make them was not easy. Got time off next week so I'll see about re doing them then.

I'm also having trouble with converted audio as well. For some reason the WT software won't accept anything above 8Khz, anyone else had this problem?
Title: Re: Arduino Lightsaber
Post by: splinter182 on Apr 01, 2016, 11:39 pm
Look what I've found:
http://www.ebay.de/itm/4-Stueck-USB-Rechargeable-4200mAh-3-7V-BRC-18650-Batterie-Battery-Li-ion-AKKU-UK-/272065940619?_trksid=p2141725.m3641.l6368

A 3.7V type 18650 battery with in-built USB recharger...? How cool is that? It seems it's only slightly longer (67mm instead of 65) but has a great capacity. Maybe such a battery can be tweaked to connect to the USB of the board and have it charged while connected.
I would not suggest those, the highest 18650 capacity is 3400mah from phillip NCR cells that are pretty expensive. Those are probably some 14500 cells inside a 18650 body with a usb lipo charger, probably a 900mah actuall capacity.

I'm also having trouble with converted audio as well. For some reason the WT software won't accept anything above 8Khz, anyone else had this problem?
thats weird, i just open my wavs in audacity, manually change the project rate to 22000 hz and save the new wavs
Title: Re: Arduino Lightsaber
Post by: Canobi on Apr 02, 2016, 12:28 am
thats weird, i just open my wavs in audacity, manually change the project rate to 22000 hz and save the new wavs
I'm doing exactly that using three audio software packages, audacity (the only free one I've used), acid pro 6 and soundforge 7 but no joy :/

Might do a wt software reinstall and see if that helps.
Title: Re: Arduino Lightsaber
Post by: JakeSoft on Apr 02, 2016, 02:18 am
I'm doing exactly that using three audio software packages, audacity (the only free one I've used), acid pro 6 and soundforge 7 but no joy :/

Might do a wt software reinstall and see if that helps.
Is the WT software rejecting your sound files when you attempt to import?

Make sure you actually type "22000" in the project rate menu. If you use the pull down menu without typing, then it will go to 22050, which won't work.

Title: Re: Arduino Lightsaber
Post by: Canobi on Apr 02, 2016, 02:34 am
Is the WT software rejecting your sound files when you attempt to import?

Make sure you actually type "22000" in the project rate menu. If you use the pull down menu without typing, then it will go to 22050, which won't work.
Tried that, same story :(
Title: Re: Arduino Lightsaber
Post by: JakeSoft on Apr 02, 2016, 04:29 am
Tried that, same story :(
Hmm. That's weird. I've converted probably hundreds of files that way at 10K, 20K, and 22K Hz and it's always worked. If you continue to have problems, you could send me your sound files and I could possibly build the binary for you.
Title: Re: Arduino Lightsaber
Post by: Canobi on Apr 02, 2016, 11:26 am
Thanks Jake, I'll bare that in mind.

I'm sure it's something stupidly simple going on, not heard anyone else complain about sampling frequency problems.
Title: Re: Arduino Lightsaber
Post by: Canobi on Apr 03, 2016, 12:16 am
Found out what the issue was.

The sound files I was trying to convert were mono so I switched to a set of stereo files and it worked a treat.
Title: Re: Arduino Lightsaber
Post by: JakeSoft on Apr 03, 2016, 04:56 am
Found out what the issue was.

The sound files I was trying to convert were mono so I switched to a set of stereo files and it worked a treat.
That's still strange. All of the files I have used are mono. There must have been something else that it didn't like. But, as long as you are able to move forward, I guess just go with it.
Title: Re: Arduino Lightsaber
Post by: Canobi on Apr 03, 2016, 01:22 pm
Oh? that is a bit weird then.

Quick question regarding the hum. I know some have layered it onto the clash/swing sounds.

The hum I have is nearly 30 seconds long so it'll need trimming down but not sure what the optimum duration for the trick to work is (if there is one), or if length is just down to memory size.
Title: Re: Arduino Lightsaber
Post by: JakeSoft on Apr 03, 2016, 05:09 pm
Oh? that is a bit weird then.

Quick question regarding the hum. I know some have layered it onto the clash/swing sounds.

The hum I have is nearly 30 seconds long so it'll need trimming down but not sure what the optimum duration for the trick to work is (if there is one), or if length is just down to memory size.
There is no set length as long as you aren't running out of flash memory. However how the sounds blend together is impacted by what part of the hum you choose to layer into the other sounds (swing, clash, etc.). Assuming your hum loops seamlessly if played back-to-back, copy a portion of the hum from the end and merge it with your other sounds so that when the sound is done playing, it will transition smoothly into the idle hum sound.

Hum....[clash event]Clash+End_Of_Hum...Hum...Hum...Hum...
Title: Re: Arduino Lightsaber
Post by: billpealer on Apr 05, 2016, 04:51 pm
I would not suggest those, the highest 18650 capacity is 3400mah from phillip NCR cells that are pretty expensive. Those are probably some 14500 cells inside a 18650 body with a usb lipo charger, probably a 900mah actuall capacity.
concur.
Title: