Not new to electronics, but I am new to coding. I'm trying to modify a code & circuit by dbodnar to bring some thunder and lightning to mighty Mjolnir (Thor's hammer) for a comicon next weekend. The LEDs edge-light plexiglass with lightning etched on it. Using his original circuit (attached dbodnar pic) and coding, I got everything to work. Then I tried to modify it so I could match the left and right audio channels on the DFPlayer to separate 20W LED arrays. The thunder played, but the LEDs didn't light up. Trying to use some logical deduction, I think it comes down to the something after the mp3_play(1). Looked simple enough, but it's proving to be a bit more challenging than originally thought. I guess that's what happens sometimes when you swing for the fence on your first at bat.
Parts on breadboard from L to R: 12V/5V converter, amplifier (from computer speakers), DFPlayer Mini, 2 x IRF540N MOSFETs, and Arduino Pro Mini with the USB to TTL wires shown. Parts below are two 20watt LED arrays (2 x 10watt LEDs in parallel). Speakers, push button, and (12V lipo not 3.3V) battery kind of speak for themselves.
Any help would be greatly appreciated.
#include <DFPlayer_Mini_Mp3.h>
const int buttonPin = 3; // the number of the pushbutton pin
int buttonState = 0; // variable for reading the pushbutton status
int buusyPin = 10; // sound player busy
int bsy = 0;
int LEDstripLightL = 13; // IRF540N to LED strip light and DAC_L output
int LEDstripLightR = 12; // IRF540N to LED strip light and DAC_R output
int sensorPinL = A0; // Audio level samples for DAC_L
int sensorPinR = A1; // Audio level samples for DAC_R
int sensorValueL = 0; // variable to store the value coming from the DAC_L
int sensorValueR = 0; // variable to store the value coming from the DAC_R
int buttn = 0;
//***************************************SETUP*************************************
void setup () {
pinMode(buttonPin, INPUT);
pinMode(LEDstripLightL, OUTPUT);
pinMode(LEDstripLightR, OUTPUT);
pinMode(buusyPin, INPUT);
pinMode(buttonPin, INPUT);
Serial.begin (9600);
mp3_set_serial (Serial); //set Serial for DFPlayer-mini mp3 module
mp3_set_volume (30); // must remove mp3_reset(); to get this to work
}
//.......................................LOOP................................................
void loop () {
Serial.println("");
Serial.println("Waiting for Button Push");
do {
buttn = digitalRead(buttonPin); // pins closest to power pins
} while (buttn == 0);
Serial.println("Button Hit");
mp3_play(1);
delay(100);
do {
sensorValueL = analogRead(sensorPinL);
sensorValueR = analogRead(sensorPinR);
Serial.print(sensorValueL);
Serial.print(sensorValueR);
Serial.print(" ");
if (sensorValueL >= 750) {
Serial.println("large number! ");
digitalWrite(LEDstripLightL, HIGH);
}
if (sensorValueL <= 666) {
digitalWrite(LEDstripLightL, LOW);
}
if (sensorValueR >= 750) {
Serial.println("large number! ");
digitalWrite(LEDstripLightR, HIGH);
}
if (sensorValueR <= 666) {
digitalWrite(LEDstripLightR, LOW);
}
bsy = digitalRead(buusyPin);
} while (bsy == 0); // zero when sound active
}
//...................................... END LOOP ........................................
MjolnirCode.ino (2.29 KB)
It is hard to tell without a schematic of what you have. Fritzing is a very very crap substitute for a schematic. The battery bit had me fooled for a time.
Also many people are on mobile devices so a .ino file is about as useful as a chocolate tea pot. That is why we have a way to post your code in a scrolling window, which you would know about if you had bothered to read the how to use this forum sticky post.
Hi,
Welcome to the forum.
Please read the first post in any forum entitled how to use this forum.
http://forum.arduino.cc/index.php/topic,148850.0.html then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.
Fritzy not good, low resolution so cannot see pin names.
Better circuit, all pins labelled and clear wiring.
Tom.. 
Hi,
What are the part numbers of the FETS?
Have you got code that just fades the LEDs to make sure that works properly?
Thanks.. Tom.. 
Grumpy_Mike:
It is hard to tell without a schematic of what you have. Fritzing is a very very crap substitute for a schematic. The battery bit had me fooled for a time.
I got tired of drawing (and re-drawing) my setup on 11x17 paper and found the Fritzing program. Are there better (and free) ones out there?
Grumpy_Mike:
Also many people are on mobile devices so a .ino file is about as useful as a chocolate tea pot. That is why we have a way to post your code in a scrolling window, which you would know about if you had bothered to read the how to use this forum sticky post.
Read the forum sticky post....after I searched the forum for a solution and saw that was a common response. Didn't consider people using mobile devices, so thanks for that insight. Code added.
TomGeorge:
Fritzy not good, low resolution so cannot see pin names.
Fritzing was the first and most intuitive program I came across. Is there a better (and free) program you would recommend?
The MOSFETs are IRF540N.
surveyranger:
The MOSFETs are IRF540N.
Well that is a problem. They need a 10V gate signal to turn them on and your Arduino can only provide a 5V one. You need a "logic level" FET. That is one that will switch on fully with 5V.
The one in the original diagram was an IRL520, that is a logic level one, the clue is in the "L".
surveyranger:
Fritzing was the first and most intuitive program I came across. Is there a better (and free) program you would recommend?
The MOSFETs are IRF540N.
ExpressSCH.. Free and not a huge application.
https://www.expresspcb.com/free-cad-software/
Tom... 
I haven't had an issue with the gate on the IRF540N triggered by the Pro Mini. I got that combo from another Instructable for a drone strobe light, and it worked fine. The "IRF540N/20W LED/Pro mini/DFPlayer Mini" setup also worked fine in the original dbodar circuit & code.
So here's the sketch. And "no" I can't draw a straight line.
Attached it too in case it doesn't show up.
Here's the Fritzing picture for reference too.
Hi,
I haven't had an issue with the gate on the IRF540N triggered by the Pro Mini.
Can you measure the voltage across the MOSFET from Source to Drain when the MOSFET is ON please?
Thanks.. Tom... 
Delta_G:
Pulling how much current through it?
Hooked up the circuit per dbodnar, except with the IRF540N, and ran it 10 times. Never drew more than 2.114A as measured with a Fluke 27II. Average was 1.956A
Delta_G:
Ever needed one to be fully on before? The grumpy one knows his stuff. You should listen to him.
Have not needed a circuit designed by myself to require a MOSFET to be fully on. I tend to err on the cautious side. When I replace parts, I use the same on that was in the original circuit.
Delta_G:
The grumpy one knows his stuff. You should listen to him.
I don't doubt Mr. Grumpy, and I will remember that moving forward with future circuits using Arduino. Observation showed me that the circuit from the strobe LED Instructable works using the IRF540N MOSFET.
TomGeorge:
Hi,
Can you measure the voltage across the MOSFET from Source to Drain when the MOSFET is ON please?
Thanks.. Tom... 
The max was 11.512V and the min was 5.283V with the circuit on.
Hi,
Thanks for the circut too, shows what we need to see.
What are the specs on your LEDs?
As @Delta_G has said, you are not turning the MOSFET fully ON.
Does the MOSFET feel warm?
If you read that "Destructible" project the OP there mentions that the MOSFETs will get hot, unfortunately he/she has not realized why.
Tom... 
I haven't had an issue with the gate on the IRF540N triggered by the Pro Mini.
You have now.
You can appear to have something working but unless you test it properly you are just guessing. That FET is working on a knife edge, adding another one can push it off.
Why ask for help and ignore the results?
Instructables are generally crap written by idiots. There are some exceptions but not in this case.
TomGeorge:
Thanks for the circut too, shows what we need to see.
What are the specs on your LEDs?
Sorry, these were true ebay specials. Nothing on them except a + and -. I bought a pack of 10 for $4 expecting a few of them not to work. So far 5 have lit up.
TomGeorge:
As @Delta_G has said, you are not turning the MOSFET fully ON.
Does the MOSFET feel warm?
If you read that "Destructible" project the OP there mentions that the MOSFETs will get hot, unfortunately he/she has not realized why.
Tom... 
Short Youtube video of the dbodnar setup using the 1 x 20W LED array and the IRF540N. The LEDs were a little warm after 30s, but I didn't feel any temperature change in the MOSFET.
Grumpy_Mike:
You have now.
You can appear to have something working but unless you test it properly you are just guessing. That FET is working on a knife edge, adding another one can push it off.
Why ask for help and ignore the results?
I see that now. It works as built, but not as designed/intended. I'll buy some IRLxxx MOSFETs to swap out later, but I don't have the time right now to wait on them to get in before I put it all together.
Is there anything wrong with the code that would prevent it from having the LEDs flash in synch with each audio channel? The Arduino IDE "verified" it, but that doesn't mean it will pull samples from both channels.
I was able to get the LEDs to light along with the sound when I sampled off the SPK connections to the A1 & A0 while the amp was connected to DAC_L & R. There were some clicks and pops in the speaker playback so I'll look into reducing that.
Hi,
Sorry, these were true ebay specials. Nothing on them except a + and -. I bought a pack of 10 for $4 expecting a few of them not to work. So far 5 have lit up.
I assume you have the LEDs like in the Destructible, if so you are trying to control LEDs that look to me as though they need a regulated current supply, there is no current limit resistor built in.
You need to use a variable power supply and measure current and voltage to see where their rated power point is.
How do I know, I have the same LEDs, probably bought from the same seller, I haven't had time to drag them out of the draw and check what characteristic they have.
Tom... 
I wanted to close out this thread. Insides aren't so pretty, but it is loud and bright. Caught a lot of people by surprise at the Comic Con.
Video