Arduino Lightsaber

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?

Maybe this will help?

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

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.

nom_smile:
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: WT588D.rar - Google Drive"
The software is only pc compatible.

iamearlgrey:
@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: WT588D.rar - Google Drive"
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).

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

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.

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.

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.

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.

Ok. time to move it to the hilt.

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.

billpealer:
Arduino Lightsaber Project testing complete. - YouTube

Ok. time to move it to the hilt.

Hey, nice job. It looks like you've got a viable solution there.

I misinterpreted the flicker schematic so here is how it should be wired for uC control:

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.

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.

one more thing need wire gage as well just in case.

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

iamearlgrey:
@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: WT588D.rar - Google Drive"
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)

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

hey i am guessing that when you used the accelerometer that it eliminated the use of the motion sensor. is this correct?

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.

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.

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;

  }
}

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

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

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.