0
\$\begingroup\$

What circuit can I use to switch on a speaker with an arduino (stm32 board)? Ideally the speaker will run longer (automatic off after some time-0.5s)

I have a stopwatch program in STM32 (digitalpinread(low)-when i connect pin to ground=program run) and I need to run speaker-sirene when the push button starts the stopwatch in arduino (sirene ON from start stopwatch with some delay, maybe 0.5s). Is it possible with N-mosfet or what do I need for that?

When momentary push button is ON, the stopwatch will run in arduino software and for some time it should activate the sirene longer (c. 0.5s-1s). Start sound for runners :-)

Explanation example:

schematic

simulate this circuit – Schematic created using CircuitLab

\$\endgroup\$
4
  • \$\begingroup\$ What do you expect the speaker to do? Is this just some sort of buzzer? A normal speaker will probably be destroyed, if you connect it to 12VDC. \$\endgroup\$
    – jusaca
    Commented Jul 26, 2019 at 9:00
  • \$\begingroup\$ Oh, with siren you mean buzzer, I guess. That is OK \$\endgroup\$
    – jusaca
    Commented Jul 26, 2019 at 9:12
  • \$\begingroup\$ Oh my .. You need some bias/pull up/down and network for the mosfet / current limitation, and some capacitor or software for the push button debounce then you need a proper highside driver + output stage with some filtering depending on what you want the speaker to do :) \$\endgroup\$
    – Sorenp
    Commented Jul 26, 2019 at 9:14
  • \$\begingroup\$ Yes siren for motorcycle (12V, 1A,100dB). Could you send me a picture of connection please? A software in arduino is closed. I need a automatic off siren after some time (little more time for siren-ON then momentary push button on). Do you understand me? Is it possible with some circuit without change in arduino code? Thanks for your help. \$\endgroup\$
    – preclix
    Commented Jul 30, 2019 at 11:10

1 Answer 1

1
\$\begingroup\$

The delay is very easy to generate in your software, no need to do this in the circuit. Just wait the specified time after your input trigger fires before activating the output.

You can use a FET (like you have drawn in the circuit), but you have to make some changes.

  • Don't connect the gate of the FET directly to ground, that way the FET will never turn on. You can put a pull down resistor (~10 kOhms) there, but that is not really necessary.
  • Use one pin of the controller as your input for the switch (e.g. pull down resistor to ground and switch to Vcc) and one pin as an output to control the FET gate.
  • Choose a logic level FET that can be switched on by 3.3V.
\$\endgroup\$
1
  • \$\begingroup\$ Yes, but the code in arduino is closed (maked by 3rd person). I can contact for edit, but ideally i want create solution without edit a code in arduino. I have a completed box with connectors so i can use only two pins (digital-3.3 and gnd from arduino). Everything else must be create outside. Maybe 5V from arduino a i can use too. The sirene is outside equipment. After start stopwatch in arduino device (connect digital pin to ground) i want sirene make sound 0,5s-1s longer than push-button in state on. \$\endgroup\$
    – preclix
    Commented Jul 28, 2019 at 10:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.