Arduino Lightsaber

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!

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

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

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.

making a few more small modifications.......

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?

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

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

llluis:
Here is the code for the One-line serial mode.
Just remember to change de config in the WT588D programmer.

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?

llluis:
Here is the code for the One-line serial mode.
Just remember to change de config in the WT588D programmer.

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.

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!

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

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

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.

Arduino fx system - Canobi.pdf (734 KB)

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! :stuck_out_tongue:

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:

Have you tried using the accelerometer's "tap" function with a high threshold instead of the clash sensor?

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

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.

Turn on repeat mode
WT588D_Send_Command(0xF2);

//Begin playlist 0
WT588D_Send_Command(0x00);

kingale:
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?

JakeSoft:
Sure. Here is the most important part of the code from SugarBombs:
(See full code here: WT588D-16P Sound Module Working Code - Audio - Arduino Forum)

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.

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.

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

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

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!

wait,.. the "send_command"? it goes out via the data pin?

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