Arduino Lightsaber

Anghelos:
I was wondering....
In order to have the hum restarting i have to put a force-play the hum after every kind of sound (wether is swing or clash or turning on or lookup) But then isn't better to put the hum in the every sound playlist at the end of every sound?

What's the best solution?

EDIT: I just tried to put the hum sound after every sound effect and also having the 3 hums in the hum slot one after one other (as u suggested). My hum sounds are 4secs long.

In the code i put the same as before but with 4000 delay (so repeating after 4 seconds).

My issue now is that after every swing/clash i have a second of silence, than start the hum sound....why?
During the idle the hum is fine.

What is most commonly done is to just follow all the sounds with a bunch of hum sounds (I typically do at least 2 minutes worth). That way, you don't have to play a hum sound explicitly after each clash/swing. You'll get it for "free" as far as coding is concerned.

Be mindful that the sound card takes time to react, so you may need to send the command a few milliseconds before you actually want it to happen. Also, be sure your sounds are NOT in MP3 format, that will be sure to cause lag on switching sounds. Keep them in .wav format.

All my sounds are .wav format,
So i have to put a HUGE numeber of hum sounds after every clash/swing/etc, until i reach a total amount of 2 mins.

But question is, how can I do this:
"so you may need to send the command a few milliseconds before you actually want it to happen"
?

I mean, as soon as a swing or clash occurs, i send the command, i cannot 'anticipate' the event... O_o'

EDIT: well anyway it did the trick, now works just fine.....until i access the menu and i change the volume, then i have problems with moments of no sound, like the hum is cutted time by time

Anghelos:
EDIT: well anyway it did the trick, now works just fine.....until i access the menu and i change the volume, then i have problems with moments of no sound, like the hum is cutted time by time

Without seeing your code I can't know for sure, but I suspect it's your menu code rapid-firing commands at the WT588D. After each time the volume is changed with the SetVolume() method, put a 100ms delay in your code. That should clean it up if it is what I think it is.

i sent the code in ur message, it's quite long.
OFC, any suggestion to make it better is more than welcome.

The base idea is:

After turning on the Latching button, the arduino board prepares to be used, when it's ready a sound is played.

Now with a momentary switch you can turn on the lightsaber (one click) or access the menu (hold the button for a little while).
In the menu you can change color of the blade, flickering effect, FoC, sound font, sound volume, clash/swing sensitivity, and i think is all.

Anghelos:
i sent the code in ur message, it's quite long.
OFC, any suggestion to make it better is more than welcome.

The base idea is:

After turning on the Latching button, the arduino board prepares to be used, when it's ready a sound is played.

Now with a momentary switch you can turn on the lightsaber (one click) or access the menu (hold the button for a little while).
In the menu you can change color of the blade, flickering effect, FoC, sound font, sound volume, clash/swing sensitivity, and i think is all.

I took a look at it. Where is PLAY_DURATION defined? You are using it as a delay after some of your sound play commands but I don't see that it is actually defined anywhere.

https://pastebin.com/i00pzHS5 this is your sound library, a bit modified. And u can see play duration here :slight_smile:

Anghelos:
https://pastebin.com/i00pzHS5 this is your sound library, a bit modified. And u can see play duration here :slight_smile:

I PM'd you but will say here that I'm not sure what the issue is. Maybe post up your code here so others can chime in.

Hi everyone!
I apologize for such a noob question, but I have to ask.
In my saber build I have led and wt588d running on 2 separate CR123A and arduino running on crona battery 9v. Should I do a common ground for everything or I have to do separate ones for all related to different power sources?
Initially I have connected a common gnd for all and it worked, but yesterday I have decided to resolder ground (it looked too clumsy to me) and my speaker started to make ticking sounds, also ADXL335 stopped working properly, just firing sounds randomly without acceleration.

Can this even happen because of common ground hook-up?
Or most likely something else?

How do you usually solder your common ground?

Hi jenga67

You were right the first time, wire everything back to ground, separating some of the devices will have caused a flaoting voltage situation which can cause all kinds of shenanigans (depending on the device).

Found some time during midst workshop rearrange to make the first of the round PCBs (24mm dia):

These were brought to tolerance by hand using a grinder, files and sandpaper and I used a micrometer to take the measurements.

I've started formulating a build plan for a jig to cut boards out, shouldn't take long once I've finished organising my workshop.

Hi everyone!

I have a small question regarding WT588D playlists (Equations), apologies for noobness in advance.

Up to this moment I was able to use only first 10 playlists on my WT588D (00H - 09H), referring to them in WT588D_Send_Command() as numbers from 0 to 9.
But when I try to use the next set with letters (0aH-0fH) or numbers (10H-19H) I can't get the sounds to play, WT588D is silent until I trigger one of the first 10 playlists.

If you guys could tell me what is required to use the playlists other than first 10, you would definitely save my day!

jenga67:
Hi everyone!

I have a small question regarding WT588D playlists (Equations), apologies for noobness in advance.

Up to this moment I was able to use only first 10 playlists on my WT588D (00H - 09H), referring to them in WT588D_Send_Command() as numbers from 0 to 9.
But when I try to use the next set with letters (0aH-0fH) or numbers (10H-19H) I can't get the sounds to play, WT588D is silent until I trigger one of the first 10 playlists.

If you guys could tell me what is required to use the playlists other than first 10, you would definitely save my day!

What are you passing as a parameter to WT588D_Send_Command? the function takes an unsigned char which you can pretty much treat as an 1 byte integer. Have you tried passing 10 to the function? the H in 0aH denotes the number as a Hex number, when converting it to decimal, the H is no longer needed

Hi Splinter, thanks for your reply!

I tried to pass 10, 11, 12 to WT, also letters a,b,c, 0a, 0b, 0c, but when the sound under those numbers is triggered it just gets silent.

But is it ok for you? You just upload all the sounds to playlists 0-9, a-f, 10-19 and pass the equation numbers to WT to be played? Nothing special declared in the code for the playlists?

jenga67:
Hi Splinter, thanks for your reply!

I tried to pass 10, 11, 12 to WT, also letters a,b,c, 0a, 0b, 0c, but when the sound under those numbers is triggered it just gets silent.

But is it ok for you? You just upload all the sounds to playlists 0-9, a-f, 10-19 and pass the equation numbers to WT to be played? Nothing special declared in the code for the playlists?

If you want to skip playlist addresses for some reason, you can do so by using the WT588D programming app's "insert silence" feature to populate the addresses you don't want to use with a 10ms silence. You can't outright skip addresses, doing so will make all playlists (equations) after the gap inaccessible at runtime; they won't play even if your code is perfect.

Hi guys!

I can say that I have finished my first build.

Have cut the hilt out of PVC tube, tried to make it look nicer, but it is still way too simple.
For next build I will order an aluminium hilt.

In the end, I have used Arduino Pro Micro 5v, WT588D-U, MPU6050, 2x CR123A 3.7v batteries for my build.
One battery with 5v stepup to Arduino and WT, another battery straight to the LED.
Used a motion manager from USaber library for MPU6050, it is great, I can recommend it 100%.
Big thanks to Jake for putting together USaber. I feel like playing with thresholds and timings a bit more, but later.

Here is a video of my build

Still have to figure out the playlist numbers usage up from 9, will do it later on, I was able to play those playlists, but they are not under the numbers i see in the software, strange.

Thanks everyone who contributed to this thread!

jenga67:
Hi guys!

I can say that I have finished my first build.

Have cut the hilt out of PVC tube, tried to make it look nicer, but it is still way too simple.
For next build I will order an aluminium hilt.

In the end, I have used Arduino Pro Micro 5v, WT588D-U, MPU6050, 2x CR123A 3.7v batteries for my build.
One battery with 5v stepup to Arduino and WT, another battery straight to the LED.
Used a motion manager from USaber library for MPU6050, it is great, I can recommend it 100%.
Big thanks to Jake for putting together USaber. I feel like playing with thresholds and timings a bit more, but later.

Here is a video of my build

Still have to figure out the playlist numbers usage up from 9, will do it later on, I was able to play those playlists, but they are not under the numbers i see in the software, strange.

Thanks everyone who contributed to this thread!

Congratulations on your first build! It's looking and sounding pretty good. As far as I know, you are the first to publish a video of a saber with that particular hardware combination. I'm glad USaber has served you well.

Hi everyone

First of all thanks to those who contributed to the incredible saber-library.
I have just started the project for my own saber.

I am going to use the following things:

  • Arduino Nano
  • MPU6050
  • SD-Card Adapter
  • DFPPlayer Mini
  • 3W Power LED (single color)
  • 10Ohm 3W Resistor
  • BUK453
  • XL6009E1 Boost Converter
  • BRC18650 3.7V 300mAh

I have planned designing a PCB where everything is going to be mounted, plus it is optional to use the SD-Card Adapter with SPI Interface or the DFP-Player. Eighter of both can be used.
The first design is already done. And it looks like this (DFPPlayer mini is missing):

I have now some questions for all those who already have built their own one:

  1. Question:
    I managed to create a Software for the Arduino Nano. MPU6050 is recognized, LED works wonderfull, even the soundthing works. BUT...
    Currently I am using the SD-Card Adapter with SPI (Link), but there is some pause between swing, clash and hums. It does not matter in which sequency. I have checked my audiofiles if there were any dead-spaces with silence in it, but there isn´t. What can I do? And what can I do to help you helping me?

  2. Question
    The PCB seems pretty bulky in my eyes. It is my first one every and I am pretty new to this, so are there any sugestions on making it perhaps a bit smaller?

  3. Question
    I want do build the hilt, but I haven´t the equipment for building one. I think a turning lathe and a milling machine would be something I could need in the process of construction.
    Are there some cheap facilities I cand send for example dxf-Files and they produce the desired thing? I´m thinking of 10-20€ per piece.
    If there are no facilities that meet those requirments, does anyone have any ideas on how I can carry on with my project?

Finally thank you all for your time in advance!

[EDIT]
4. Question
I got stuck implementing the lines for the DFPlayerSoundPlayer.
Error:

***\Arduino\ArduSaber\ArduSaber.ino: In function 'void setup()':

ArduSaber:212: error: 'DFPlayerSoundPlayer' was not declared in this scope

     DFPlayerSoundPlayer *lpSoundPlayer = new DFPlayerSoundPlayer(RX_PIN, TX_PIN, &gSoundMap);

     ^

ArduSaber:212: error: expected type-specifier before 'DFPlayerSoundPlayer'

     DFPlayerSoundPlayer *lpSoundPlayer = new DFPlayerSoundPlayer(RX_PIN, TX_PIN, &gSoundMap);

                                              ^

Multiple libraries were found for "SD.h"
 Used: ***\Arduino\libraries\SD
 Not used: C:\Program Files (x86)\Arduino\libraries\SD
exit status 1
'DFPlayerSoundPlayer' was not declared in this scope

My lines of Code where this shows up:

 #ifdef DFP_PLAYER
    memset(&gSoundMap, 0, sizeof(DFPlayerSoundMap));
    //Sound font features. Numbers here are arbitrary.
    //These values should be adjusted to match how your
    //sound module is programmed.
    gSoundMap.Features.FontIdsPerFont = 1;
    gSoundMap.Features.HumSoundsPerFont = 1;
    gSoundMap.Features.PowerUpSoundsPerFont = 1;
    gSoundMap.Features.PowerDownSoundsPerFont = 1;
    gSoundMap.Features.ClashSoundsPerFont = 8;
    gSoundMap.Features.SwingSoundsPerFont = 8;
    gSoundMap.Features.LockupSoundsPerFont = 1;
    gSoundMap.Features.BlasterSoundsPerFont = 1;
    gSoundMap.Features.ForceSoundsPerFont = 0;
    gSoundMap.Features.CustomSoundsPerFont = 0;
  
    //Sound locations
    gSoundMap.Locations.BaseAddr = 0;
    gSoundMap.Locations.BlasterBase = 21;
    gSoundMap.Locations.BootBase = 1;
    gSoundMap.Locations.ClashBase = 12;
    gSoundMap.Locations.SwingBase = 4;
    gSoundMap.Locations.LockupBase = 20;
    gSoundMap.Locations.PowerupBase = 2;
    gSoundMap.Locations.PowerdownBase = 22;
    gSoundMap.Locations.HumBase = 3;
    gSoundMap.Locations.FontIdBase = 1;
  
    DFPlayerSoundPlayer *lpSoundPlayer = new DFPlayerSoundPlayer(RX_PIN, TX_PIN, &gSoundMap);
  
    //Turn down the volume because 3W amp is so freak'n loud!
    // lpSoundPlayer->SetVolume(18);
    // lpSoundPlayer->Init();
  #endif

I have the following includes:

#include <Wire.h>
#include <USaber.h>
#include <TMRpcm.h>
#include <SD.h>
#include <SPI.h>

danboe70:
4. Question
I got stuck implementing the lines for the DFPlayerSoundPlayer.
Error:

***\Arduino\ArduSaber\ArduSaber.ino: In function 'void setup()':

ArduSaber:212: error: 'DFPlayerSoundPlayer' was not declared in this scope

DFPlayerSoundPlayer *lpSoundPlayer = new DFPlayerSoundPlayer(RX_PIN, TX_PIN, &gSoundMap);

^

ArduSaber:212: error: expected type-specifier before 'DFPlayerSoundPlayer'

DFPlayerSoundPlayer *lpSoundPlayer = new DFPlayerSoundPlayer(RX_PIN, TX_PIN, &gSoundMap);

^

Multiple libraries were found for "SD.h"
Used: ***\Arduino\libraries\SD
Not used: C:\Program Files (x86)\Arduino\libraries\SD
exit status 1
'DFPlayerSoundPlayer' was not declared in this scope




My lines of Code where this shows up:


#ifdef DFP_PLAYER
    memset(&gSoundMap, 0, sizeof(DFPlayerSoundMap));
    //Sound font features. Numbers here are arbitrary.
    //These values should be adjusted to match how your
    //sound module is programmed.
    gSoundMap.Features.FontIdsPerFont = 1;
    gSoundMap.Features.HumSoundsPerFont = 1;
    gSoundMap.Features.PowerUpSoundsPerFont = 1;
    gSoundMap.Features.PowerDownSoundsPerFont = 1;
    gSoundMap.Features.ClashSoundsPerFont = 8;
    gSoundMap.Features.SwingSoundsPerFont = 8;
    gSoundMap.Features.LockupSoundsPerFont = 1;
    gSoundMap.Features.BlasterSoundsPerFont = 1;
    gSoundMap.Features.ForceSoundsPerFont = 0;
    gSoundMap.Features.CustomSoundsPerFont = 0;
 
    //Sound locations
    gSoundMap.Locations.BaseAddr = 0;
    gSoundMap.Locations.BlasterBase = 21;
    gSoundMap.Locations.BootBase = 1;
    gSoundMap.Locations.ClashBase = 12;
    gSoundMap.Locations.SwingBase = 4;
    gSoundMap.Locations.LockupBase = 20;
    gSoundMap.Locations.PowerupBase = 2;
    gSoundMap.Locations.PowerdownBase = 22;
    gSoundMap.Locations.HumBase = 3;
    gSoundMap.Locations.FontIdBase = 1;
 
    DFPlayerSoundPlayer *lpSoundPlayer = new DFPlayerSoundPlayer(RX_PIN, TX_PIN, &gSoundMap);
 
    //Turn down the volume because 3W amp is so freak'n loud!
    // lpSoundPlayer->SetVolume(18);
    // lpSoundPlayer->Init();
  #endif



I have the following includes:


#include <Wire.h>
#include <USaber.h>
#include <TMRpcm.h>
#include <SD.h>
#include <SPI.h>

Try using DIYinoSoundPlayer instead. The DF version is depreciated. I really need to just remove it from the lib. You are not the first to get tripped up by it.

Ohhh...ok...I see.

That means I just have to change the class I am creating an instance of, right?
I do not need to change the hardware for it as well, or do I?

However, thanks a lot for your help. Appreciated it a lot!

I´ll post some images from the results as soon as I am finished.

danboe70:
Ohhh...ok...I see.

That means I just have to change the class I am creating an instance of, right?
I do not need to change the hardware for it as well, or do I?

However, thanks a lot for your help. Appreciated it a lot!

I´ll post some images from the results as soon as I am finished.

Yeah, that's right. Protonerd's DIYino boards use the same sound chip the DFPlayer sound modules, so the software is cross-compatible.