安卓耳机插孔按钮布线?

huangapple go评论70阅读模式
英文:

Android Headphone Jack Button Wiring?

问题

我正在尝试弄清楚如何使用耳机插孔来触发我应用中的操作,使用自定义按钮。我已经放置了一些代码,可以检测我按下插入端口的耳机上的按钮,但是如果我插入一个TRRS电缆并短接引脚,什么反应都没有。

我找到了这个链接:https://source.android.com/devices/accessories/headset/plug-headset-spec

但是上面写到R1应该是0欧姆,那么短接它不会导致某些动作吗?耳机没有外部电压,所以我认为我不需要在电路中施加电压。R1代表什么?播放、暂停、静音还是其他功能?有谁能指点我正确的方向来解决这个问题吗?

英文:

I am trying to figure out how to use the headphone jack to trigger an action in my app, using a custom button. I have some code in place that will detect when I press a button on a headset plugged into the port, but if I plug a TRRS cable into the port and short the pins, I get nothing.

I found this: https://source.android.com/devices/accessories/headset/plug-headset-spec

But it says that R1 is supposed to have 0 ohms, so won't shorting it cause it to do something? The headset has no external voltage to it, so I didn't think I'd have to apply voltage to my circuit. And what does R1 represent? Play, pause, mute, or other? Can anyone point me in the right direction to sort this out?

答案1

得分: 2

好的,我弄清楚了。经过多次测试,使用许多电阻,我终于明白了它的工作原理。

在TRRS插头上,有4个环 - R1(尖端)和R2是扬声器,R3是地线,R4(底部)是麦克风。

将R4短接到R3应该会触发“播放/暂停”按钮动作。

我没有理解的部分是,电路希望电路上始终存在由于麦克风引起的电阻。因此,当您插入它时,必须至少有1100欧姆的电阻跨越R4-R3,以便手机认为已插入麦克风。关于电阻有很大的变化。在我的测试中,1100欧姆和4400欧姆都可以。如果没有这个电阻,它会认为只有扬声器,并忽略任何按钮信号。

我弄错的地方是我以为它只在按下按钮时需要电阻。不是的,它需要始终存在,因此您将电阻与开关并联放在电路中。

希望这对将来可能对硬件了解不多的其他人有所帮助。

英文:

Ok, I figured it out. After much testing with many resistors, I finally realized how it works.

On the TRRS plug, there are 4 rings - R1 (tip) and R2 are the spearkers, R3 is ground, and R4 (base) is for the microphone.

Shorting R4 to R3 is supposed to trigger the "play/pause" button action.

The part I didn't understand is that the circuit expects there to always be resistance on the circuit due to the microphone. So, when you plug it in, there needs to be at least 1100 ohms of resistance across R4-R3 in order for the phone to think there is a microphone plugged in. There is a lot of variance on how much resistance. In my testing, 1100 ohms worked, as did 4400 ohms. Without this resistance, it thinks there is only speakers, and ignores any button signals.

Where I screwed up is that I thought it needed the resistance only when the button was pushed. Nope, it needs to be there constantly, so you put the resistor in the circuit in parallel with the switch.

Hope this helps someone else out in the future that also might not have a great handle on hardware.

huangapple
  • 本文由 发表于 2020年9月5日 01:29:41
  • 转载请务必保留本文链接:https://go.coder-hub.com/63745641.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定