3
\$\begingroup\$

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.

Input buttons

MCU

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 $$

\$\endgroup\$
  • 2
    \$\begingroup\$ 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. \$\endgroup\$ – pjc50 Sep 15 at 9:36
  • 1
    \$\begingroup\$ 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... \$\endgroup\$ – awjlogan Sep 15 at 9:37
  • 2
    \$\begingroup\$ 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.) \$\endgroup\$ – jonk Sep 15 at 9:56
  • 1
    \$\begingroup\$ @awjlogan It has to be a single, short, press. Nothing else works. Thanks for confirming the voltage divider stuff. \$\endgroup\$ – Paul Sep 15 at 10:00
  • 2
    \$\begingroup\$ 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. \$\endgroup\$ – Chris Stratton Sep 15 at 14:35
5
\$\begingroup\$

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.

| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ 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. \$\endgroup\$ – Paul Sep 15 at 11:28
  • \$\begingroup\$ 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 \$\endgroup\$ – Paul Sep 15 at 11:30
  • 1
    \$\begingroup\$ 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. \$\endgroup\$ – Justme Sep 15 at 11:36
  • \$\begingroup\$ I have written the code and tested it, it works, you may find it here: github.com/paulbarbu/akai-input-change/blob/master/… \$\endgroup\$ – Paul 2 days ago
  • \$\begingroup\$ Now to see about the timer and transistor in order to get it out of there \$\endgroup\$ – Paul 2 days ago
4
\$\begingroup\$

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.

| improve this answer | |
\$\endgroup\$
2
\$\begingroup\$

A simple window comparator/inverter solution:

schematic

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

| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ 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. \$\endgroup\$ – Paul Sep 15 at 13:25
  • \$\begingroup\$ @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. \$\endgroup\$ – awjlogan Sep 15 at 13:30
  • 1
    \$\begingroup\$ 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. \$\endgroup\$ – Paul Sep 15 at 13:33
  • 2
    \$\begingroup\$ 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 ... ;) \$\endgroup\$ – brhans 2 days ago
  • \$\begingroup\$ @brhans - I love this, fun little nugget :) \$\endgroup\$ – awjlogan 2 days ago
1
\$\begingroup\$

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.

Ref.: https://create.arduino.cc/projecthub/arjun/programming-attiny85-with-arduino-uno-afb829

https://www.youtube.com/watch?v=gXXdoeu7yWw

| improve this answer | |
New contributor
Mats Karlsson is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
\$\endgroup\$
  • 1
    \$\begingroup\$ To ensure that BT is selected, is there any LEDs that could be sensed so a verification can be made? \$\endgroup\$ – Mats Karlsson Sep 15 at 10:27
  • \$\begingroup\$ Where should we add pinMode(7, INPUT) if not in setup() or loop()? \$\endgroup\$ – Thomas Weller Sep 15 at 20:29
  • \$\begingroup\$ 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. \$\endgroup\$ – Mats Karlsson 2 days ago
  • \$\begingroup\$ If you would like to get help off site, check my profile. \$\endgroup\$ – Mats Karlsson 2 days ago
  • \$\begingroup\$ 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/… \$\endgroup\$ – Paul 2 days ago
-1
\$\begingroup\$

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.

| improve this answer | |
New contributor
Gary Dirkse is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
\$\endgroup\$
  • 1
    \$\begingroup\$ 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. \$\endgroup\$ – Elliot Alderson yesterday

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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