Arduino Lightsaber

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?

PlasmaSaber_ver0.5.zip (1.85 KB)

JakeSoft:
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 :slight_smile:

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.

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.

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

Buy Products Online from China Wholesalers at Aliexpress.com

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.

Canobi:
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.

WT588D-16P_Amplifier.JPG

WT588D VOICE CHIP MODULE APPLICATION CIRCUIT.pdf (536 KB)

DAC_option.JPG

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

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

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.

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

JakeSoft:
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.

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

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.

Canobi:
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.

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

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!

JakeSoft:
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.

SoundTrix:
Indeed, one on constant hum, the other playing effects... Hmmmm... The possibilities are endless.

Aha! Now there's an idea...

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

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.

Mixing two channels playing different rythm and pitch makes sense, but when both are some kind of noise - is an overkill...

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

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.

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:

Been following this post for a while - conveniently timed with my own foray into an Arduino saber! Great work by all involved! :slight_smile:

I'm personally using kit from DFRobot, with a couple of changes - specifically the MP3 player & 6DOF gyro.

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

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

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.