Skip to main content

Reply to "MP3 Sound for Crossing Gate"

ken's trains posted:

Now for the problem I can't explain. During the non-play cycle (5 sec.), the speaker clicks loudly at about a 1 Hz rate. I changed my simple program to power the Arduino and only have the output turn the transistor off--no speaker 1 Hz pops. As soon as I cycle the transistor on/off with the 5 sec. delays, the pops are back during the off cycle. I just measured the Arduino output pin state (connected to the transistor base thru the 500 ohm resistor) and it is ~ 0.17V when LOW and ~3.99V when HIGH.

Well, if your PNP switch circuit is symmetrical (i.e., 5.0V DC on the emitter), then in the OFF cycle you are apply a forward voltage (i.e., base-emitter) of 1V into the PNP via the 1K base resistor!  This is, say, about 1/2 mA of base current which the 2N3906 will amplify and "weakly" attempt to power up the MP3 electronics.  I suspect the MP3 electronics is trying to start up but the PNP is not providing enough current and the circuit shuts down, then tries again after 1 sec causing the hiccups that couple over to the amplifier.

As to why you have 4.0V (rather than 5.0V) on an output pin when driven HIGH is the question. I tried to zoom in on your pics but couldn't quite make out which exact pins you are using.  Here's one scenario which could explain the 4V.  Suppose you left the 10K tied to ground rather that moving it to 5V when going from NPN to PNP.  Additionally suppose you are using an output pin that is operating as a so-called open-collector (OC) output.  These outputs can only "drive" current when LOW.  When HIGH the pin essentially floats so that that 10K to ground would provide about 1/2 mA of base current which is coincidentally what you measured.  This inability of an OC to drive current when HIGH would explain why it did absolutely nothing when trying to power the MP3 player directly from the output pin.  Well, that's one scenario anyway.

I guess if you have a 5V relay module lying around that is one way to make a better electrical switch with an "on" resistance less than 0.1 Ohms or whatever!  I think a FET would also work if powering the player and amplifier simultaneously.  As you point out, those eBay relay modules can be driven directly from an Arduino output pin because the relay module has a transistor buffer driving the relay coil which requires only a few mA of trigger current. 

OGR Publishing, Inc., 1310 Eastside Centre Ct, Suite 6, Mountain Home, AR 72653
800-980-OGRR (6477)
www.ogaugerr.com

×
×
×
×
×