# Pressing a physical button, but digitally using an Arduino in an existing circuit

I have a pair of speakers that by default select their input as bluetooth and I have to press a physical button (every time I power them up) to switch their input to auxiliary.

So I'm thinking of a small arduino based project where every time the arduino starts up (I will wire it to get 5V when the speakers start) it will simulate a button press. The software part is easy, when the arduino starts, just output the correct voltage on one of the pins, connected to the switch.

Trouble is that I need to press the switch just once (if I press it more than once, the inputs will cycle) and I cannot really understand the electrical schematic.

So as you can see there are 5 switches, all connected to the pin 45 of the MCU. I want to simulate a single press of the SW10/INPUT button.

Conceptually I think the pin 45 measures the voltage (since every button is series with a different resistor) in order to find out which button was pressed. So, is the AD_KEY line connected to the MCU between pin 45 and the 3,3K resistor? Just like a voltage divider?

If yes, does this mean that on startup, and only on startup, it is sufficient to output 1.2V [a] from the arduino to the AD_KEY line (which leads to pin 45, where the speaker's MCU will read) in order to simulate a button press?

Electronically, is there a way I can do this just once at the beginning, without wasting an mcu/arduino (even if just a micro arduino) here?

[a]: If we're talking about a voltage divider then when SW109/INPUT is pressed we have: $$V_{pin45} = V_{in}\frac{R80}{R80 + R1} =>$$ $$V_{pin45} = 3.3V\frac{2K\Omega}{2K\Omega + 3.3K\Omega} = 1.24V$$

• It could certainly be done once at the start by a non-digital circuit, and might be more reliable - I would use an NE555 in one-shot mode driving a transistor pulling the line low for a period at startup. The trick will be choosing how long it needs to be held for while the device is booting. Sep 15, 2020 at 9:36
• Your reasoning looks absolutely sound re. the voltage divider! Q - what if you press and hold the button? Does it cycle the input? Does it block the other buttons? If it's not unacceptable, you could just to tie it off to the correct level... Sep 15, 2020 at 9:37
• Paul, this sounds like a PIC10F200 to me. You've got 3.3 V already available on the board. Just wire up one of the PIC10F200 pins to one side of the switch (the left side in the diagram) and ground it (set the pin to 0 and "output," of course) for a moment and release. The PIC10F200 can be programmed to delay after power-on for a moment (half a second?) and then pulse low for a short period and then release it. It's a SOT23-6. Easily soldered on. No colostomy bag (the arduino.)
– jonk
Sep 15, 2020 at 9:56
• @awjlogan It has to be a single, short, press. Nothing else works. Thanks for confirming the voltage divider stuff.
– Paul
Sep 15, 2020 at 10:00
• Consider an 8-pin ATtiny instead of a full Arduino, you can still use an Arduino approach and use your Arduino as an ISP programmer for it. Though you might test with the full Arduino first; the real question in my mind is if there's a timing which makes this always work, or if you need to find something you can monitor to determine which mode it is in. Sep 15, 2020 at 14:35

Even simpler is just to have the Arduino or any other chip to connect the AD pin via 2k2 resistor to ground momentarily, just like what the button does.

You only need to have an open-drain output, which can be implemented in Arduino software, or with a suitable logic gate or comparator that has an open-drain output, or even with a transistor.

The timing circuit can also be an Arduino, or a 555, or simple RC time constant with schmitt trigger inverter gate or comparator.

• I have an idea what you're talking about, but for clarity: My output pin will be open-drain just AFTER I set it to low (ground), ie. after I actually pressed the button, in order to allow the physical button to function as normal afterwards, right? I will look into "Schmitt triggers", but I will definitely first try the arduino way.
– Paul
Sep 15, 2020 at 11:28
• Also, please correct me if I'm wrong: the current through my Arduino if I just use a pin and set it to LOW, would be 0.62mA. Which should be below the 20mA threshold of damaging the Arduino. 0.62mA computed like: I=V/R, I =3.3V / (3.3kO + 2kO) = 3.3/5.3 mA
– Paul
Sep 15, 2020 at 11:30
• Yes, set the pin as input without pull-up so it does not interfere with anything, and when simulating the button push, set the output value to low and direction to output. Yes, IO pin must sink 0.62mA when pulling low just like the real button, that is nothing that needs to worry about. Sep 15, 2020 at 11:36
• I have written the code and tested it, it works, you may find it here: github.com/paulbarbu/akai-input-change/blob/master/…
– Paul
Sep 16, 2020 at 13:10
• Now to see about the timer and transistor in order to get it out of there
– Paul
Sep 16, 2020 at 13:11

I think it would be better to use a 2N7000 MOSFET in parallel with the switch rather than trying to use the Arduino output directly.

Otherwise accidentally setting the output high would put 5V on a 3.3V chip, which could damage it. Cheap insurance for a single part. The output voltage will also be closer to zero when on, so probably more noise/drift margin.

Arduino Nanos from China are around \$2 and the transistor is almost free, so it's a fairly cheap and easy solution.

To simplify it you need a 3,3 volt Arduino (There are many variants to choose from) and a 2k ohm resistor.

Connect the 2k ohm resistor to a digital port and the other end of the resistor to "AD KEY" and also connect Arduinos GND to the amplifiers GND. And I believe you could supply a Arduino from the Amplifiers 3,3 volt rail.

Remember to set the digital pin to "floating state" when its not used, otherwise will it influence the voltage on "AD KEY".

pinMode(7, INPUT);


And to make a program that only run once:

void setup(){
// Code you want to run once
}

void loop(){
// No code
}


And take a look at ATtiny MCUs for your project, they can be programmed with Arduino IDE and the smallest is just a 8pin MCU = small, not power hungry and cheap.

• To ensure that BT is selected, is there any LEDs that could be sensed so a verification can be made? Sep 15, 2020 at 10:27
• Where should we add pinMode(7, INPUT) if not in setup() or loop()? Sep 15, 2020 at 20:29
• All code that is to be run ONCE needs to be in "void setup()". All code that exist in "void loop" will be executed in an infinite loop. And the 7 is just an example for pin 7, replace that with the pin that yu wish to use. Sep 16, 2020 at 7:42
• If you would like to get help off site, check my profile. Sep 16, 2020 at 10:22
• If you need, I have written the code and tested it, it works, you may find it here: github.com/paulbarbu/akai-input-change/blob/master/…
– Paul
Sep 16, 2020 at 13:09

A simple window comparator/inverter solution:

simulate this circuit – Schematic created using CircuitLab

The LM393 is an open collector device; both comparators must be off for the transistor Q1 to be turned on. The voltage thresholds $$\V_\mathrm{L}\$$ and $$\V_\mathrm{H}\$$ are set to $$\\frac{1}{3}V_+\$$ and $$\\frac{2}{3}V_+\$$ respectively. As the voltage across C1 rises between those two thresholds, both comparators are off. The voltage now applied to Q1's base allows it to conduct, pulling the switch connection to ground, simulating your button press. You can alter C1/R4 time constant, $$\\tau\$$, and/or the threshold levels to tune your inital delay, and pulse width. With the values given here, the initial delay before the pulse is 40 ms, and the pulse width is 70 ms. These can be calculated as follows:

$$\t_\mathrm{delay} = - \tau \ln (1 - \frac{V_\mathrm{L}}{V_+})\$$

$$\\mathrm{Pulse\ length} = \tau \ln (\frac{V_+ - V_\mathrm{L}}{V_+ - V_\mathrm{H}})\$$

Not as flexible as a microcontroller, but might just be cheaper..!

• Thanks for the solution, I will definitely try it as well, I don't have any experience with the N555 (not in your solution, but mentioned in answers/comments) or the LM393, so I'm keen to experiment a bit and learn about them.
– Paul
Sep 15, 2020 at 13:25
• @Paul No probs, all good fun! For this sort of thing, especially as one offs, realistically a microcontroller is unbeatable on flexibility, parts count, and even cost. On large volumes, the discrete(-ish) approach like above might be better as all the parts are standard/incredibly cheap and you don't have the programming step. Sep 15, 2020 at 13:30
• Yeah, this is just a personal project for learning/improving the usability of my speakers. But I also do not want to waste an arduino in there.
– Paul
Sep 15, 2020 at 13:33
• Just an observation, but you've basically built a 555 out of discrete components there - it's just a 10-10-10 instead of a 5-5-5 ... ;) Sep 16, 2020 at 3:01
• @brhans - I love this, fun little nugget :) Sep 16, 2020 at 8:34

Don Lancaster's CMOS Cookbook may have the simplest most elegant solution. A cmos 4093 plus a capacitor PUR, power up reset circuit. Fast, cheap and lovely.

• I have a copy of the CMOS Cookbook, but I'm kind of a freak. This answer is not helpful to the OP as it is written. Sep 17, 2020 at 1:31