One switch >two microcontroller GPIOs?

For Adafruit customers who seek help with microcontrollers

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
datac
 
Posts: 8
Joined: Tue Feb 16, 2016 2:07 am

One switch >two microcontroller GPIOs?

Post by datac »

Excuse the noob engineering question.

I'd like to drive both a Trinket GPIO and the input pin for an ATXRaspi from a single switch. I'm assuming these should be isolated to be safe. Is an optoisolator the best choice, or would a pair of diodes do the job?

User avatar
michaelmeissner
 
Posts: 1832
Joined: Wed Aug 29, 2012 12:40 am

Re: One switch >two microcontroller GPIOs?

Post by michaelmeissner »

I don't think Adafruit stocks it, but you might want to look for a "double pull double throw" switch. This switch has two independent connections, so you could hook the trinket to one side and the Raspberry Pi.

For example: http://www.futureelectronics.com/en/tec ... .aspx?IM=0

User avatar
datac
 
Posts: 8
Joined: Tue Feb 16, 2016 2:07 am

Re: One switch >two microcontroller GPIOs?

Post by datac »

I'm familiar with those, and that would save some hassle, but I need to drive this from a single switch (the push function of an Adafruit rotary encoder, to be specific).

If I were doing caveman engineering I'd fire a DPDT relay with the switch, but that seems like overkill designed to hide my ignorance of proper electrical design. I assume there's a simple MOSFET or other solid state equivalent, if I knew what it was or how to use it.

User avatar
adafruit_support_mike
 
Posts: 67485
Joined: Thu Feb 11, 2010 2:51 pm

Re: One switch >two microcontroller GPIOs?

Post by adafruit_support_mike »

You can use a couple of transistors per output:
buffers.jpg
buffers.jpg (15.81 KiB) Viewed 247 times
The two-inverter step from the switch to the GPIO pin makes the signal at the pin match the signal at the switch. If you don't mind reversing your logic, you can eliminate the first transistor in either path.

Locked
Please be positive and constructive with your questions and comments.

Return to “Microcontrollers”