Arduino Lightsaber

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

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

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

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:

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

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

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

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

Playing with it hopefully can figure it out lol

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

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

Yay! 8)

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Jakesoft,

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

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

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

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

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

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

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

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

Ok, I will watch for that. :)