Go Down

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

billpealer

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)


Try putting this somewhere in your code:

Code: [Select]


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

JakeSoft

#61
Oct 22, 2015, 07:30 pm Last Edit: Oct 22, 2015, 07:32 pm by JakeSoft
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. ;-)

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

Code: [Select]

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!

billpealer

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

billpealer

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

kingale

 
Quote
Does the hum sound not play at all, or does it just not loop for you?
I hear like multiple taps, so i guess the play function in getting run each loop

JakeSoft

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

Well, I'm not sure what you're getting at. You managed to confuse me. The data pin is defined, It's pin 8. It's WT588D_SDA.

 I think the code you are looking for was linked in the OP, but I'll put it here again. http://forum.arduino.cc/index.php?topic=227435.0

billpealer

#66
Oct 23, 2015, 05:43 am Last Edit: Oct 23, 2015, 05:52 am by billpealer
Well, I'm not sure what you're getting at. You managed to confuse me. The data pin is defined, It's pin 8. It's WT588D_SDA.

 I think the code you are looking for was linked in the OP, but I'll put it here again. http://forum.arduino.cc/index.php?topic=227435.0

your image on page 1 has data as pin 13,. and pin 9 is.....  Red MOSFET.

just sayin.

had a guy at work tell me any C programming with "_"  in it is a defined name of a proxy.  so WT588D_Send_Command()  is a pin, that would have been defined with all the others. Or,.. it's a statement called up in the Loop function. 

your photo is out of date?

or  what pin do you have the "WT588D_Send_Command()" pushing out of?


my biggest issue with SB's code is...
 void loop()
{

  WT588D_Send_Command(file_count);

  file_count++;  .. etc etc....


"WT588D_Send_Command"  is not mentioned in the WT588D's sample C code for any mode, 1line,3line, or key.    and the name "WT588D_Send_Command"  is not defined anywhere.  Where the heck is this function coming from?.  it is NOT Anywhere  on the internet PERIOD except this very thread and SBs.

billpealer

wait,.. 
Arduino is like Chinese.  Backwards. the below code IS the program of "WT588D_Send_Command()"

the void loop calls up "WT588D_Send_Command"  but that function isn't defined till below the function that calls it up.  forgive my logical brain for not realizing computer code is nonlinear and or counter intuitive.

thank god it isn't like cake.  or people would be baking the box of cake at 350 degrees and "enjoying it"  when the last instruction is take the contents out of the bag, and mix with water and oil in large bowl"

is all arduino code bottom up?


From SB
"


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

Roibal

Awesome, keep up the good work!

grond

perfect work jakeSoft, your my inspiration.i'm new about arduino and these things so is there any chance keep hum sound up while clash or swing sounds playing? i wanna try to do your work with wt588d-u, pro mini 3.3 and gy-521 with single 3.7 18650. i hope its possible to make it.

JakeSoft

perfect work jakeSoft, your my inspiration.i'm new about arduino and these things so is there any chance keep hum sound up while clash or swing sounds playing? i wanna try to do your work with wt588d-u, pro mini 3.3 and gy-521 with single 3.7 18650. i hope its possible to make it.
I don't see why not. I've actually been meaning to try out running with an 18650. You obviously won't have a 5V rail anywhere in your project, but you don't really need one if you use the 3.3V pro mini. I'm not familiar with the gy-521, but if it's a 3.3V device then you'll be fine. The schematic will work out differently, but it should be possible to make something that works with a 3.7V power source. Good luck!

Canobi

I've edited my post (#43) on page 3 to include download links to folders containing the new versions of the PCBs.

I've also amended the system description in the post to reflect the changes I made to the layout designs.

purgedsoul

I've edited my post (#43) on page 3 to include download links to folders containing the new versions of the PCBs.

I've also amended the system description in the post to reflect the changes I made to the layout designs.
Thank you for sharing! :)

RTPfan

Hi coders and circuit makers,

I am someone else getting a project together.  Everything seems to be progressing well except I am having difficulty with the WT588D chip.

Firstly, in 3 line mode, I do not get the same as the timing diagram in the documentation.

My sound plays fine (and have tested the right ones are being selected using about 140 test sounds).

The documentation ( http://e-radionica.com/productdata/WT588D%20CHIP&MODULE%20DETAILED%20INFORMATION.pdf ) shows the sound (and busy signal) starting after 2 ms and states it happens 2 ms after successful data transmission.  The 2 ms in the diagram is referenced to the data becoming stable and not the rising edge of the last clock.  I would expect it to be referenced the last clock rising edge so this diagram at least seems inaccurate in one respect.

What I get is that sound and busy do not start until 24mS after the rising edge of chip select.  This is reliable and if I delay the CS further it still always happens 24ms after the rising CS!

The documentation may be wrong or this may indicate I am not doing things correctly.

Does anybody else have experience with this or has timed the time until the busy signal?


Secondly with reference to the repeat function.  An example is given where the repeat command is sent before the sound command is started.

The documentation states on page 18 that the repeat command repeats the sound that is currently playing so this example would not be expected to work if the documentation is right.

If I do it as teh documentation suggests then it seems to work; however if I follow the example then it does not work ever.  The only way I could see the example working is if the code was in a loop so that the repeat command was sent again before the sound ended.

Does anyone have any definitive experience of making the repeat command work reliably?

Your experiences/ comments on the above would be appreciated.




Canobi

No problem @purgedsoul, in fact, I have another little goody to share...

I started looking for a simple way to make my blades flicker without having to write code to do it. After stopping to see if 555s running at different frequencies could work, I decided to move on as I wasn't happy with the extra amount of space/routing/complexity they would add to the layout design.

I then hit on an idea and started to look a bit deeper into candle effect flicker LEDs. Turns out you can use em to control the blade LED(s).

To make it work, all you'd have to do is stick a flicker LED in series with the uC's output pin going to the mosfet gate:



The best place to find them is on eBay as most outlets have a min order requirement in the 1000s and I've even found 3mm versions which are ideal for this purpose.

Handily, this youtube vid showes the idea in practice (minus the MCU):

http://youtu.be/753-lkao8l0

Go Up