Go Down

Topic: Arduino Lightsaber (Read 385073 times) previous topic - next topic

Balaclava

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






iamearlgrey

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.

Ibrene

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.

iamearlgrey

#108
Nov 09, 2015, 04:09 am Last Edit: Nov 09, 2015, 04:10 am by iamearlgrey
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?

nom_smile

Maybe this will help?

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



billpealer

#110
Nov 09, 2015, 07:54 pm Last Edit: Nov 09, 2015, 09:03 pm by billpealer
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.   

iamearlgrey

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.

JakeSoft

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

JakeSoft

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.

iamearlgrey

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.

billpealer

#115
Nov 11, 2015, 09:28 pm Last Edit: Jan 10, 2017, 08:06 pm by billpealer
https://youtu.be/qoQUYWZs6pI

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.

JakeSoft

#116
Nov 12, 2015, 04:05 am Last Edit: Nov 12, 2015, 04:06 am by JakeSoft
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.

Canobi

#117
Nov 15, 2015, 12:57 pm Last Edit: Nov 16, 2015, 04:46 pm by Canobi
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.

darkside

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.

darkside

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

Go Up