Voting resources, early voting, and poll worker information - VOTE. ... Adafruit is open and shipping.
0

Sharing a microcontroller pin via a transistor
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Sharing a microcontroller pin via a transistor

by earnestblimp on Tue Jun 22, 2010 3:22 pm

Hi all,
I have an Arduino, and I have a circuit where it's possible to have the serial TX pin connect to either an LCD or an external serial connector. I was using a shorting block (a jumper) to decide which route to go, but I would very much like to solve the problem with software so I don't have to take the box apart if I want to switch them. Seems like I can use a bipolar junction transistor for this, along with a resistor.

I have used an NPN/resistor combo elsewhere to control power to various subcircuits (by switching to ground), but here it's switching a signal, not sure how that changes things. I was planning on using a PNP, with the Arduino TX pin connected to the emitter, and the destination component connected to the collector, and another pin driving the base (through the resistor). Grounding the base allows communication to happen, pulling it high halts it. Does anyone know if there's a generally a better way of doing this sort of thing? I was also considering a 4066, but didn't know how this compared to my proposed solution. Is there a generally more recommended approach? Thanks!

earnestblimp
 
Posts: 19
Joined: Thu Sep 17, 2009 10:42 am

Re: Sharing a microcontroller pin via a transistor

by franklin97355 on Tue Jun 22, 2010 6:38 pm

Is there a reason you can't use another pin? SoftwareSerial can use almost any pin.

franklin97355
 
Posts: 21582
Joined: Mon Apr 21, 2008 2:33 pm
Location: Lacomb, OR.

Re: Sharing a microcontroller pin via a transistor

by earnestblimp on Tue Jun 22, 2010 7:34 pm

Is there a reason you can't use another pin? SoftwareSerial can use almost any pin.


Yes, I have a mega, and the new software serial library doesn't support it, and the older one seems to have some timing issues. I've had great luck with the hardware serial, and would like to continue using it for the time being. However, if I can get a software switch working, then down the road, if the software serial ends up being really robust, then I can program the switch to disconnect the lcd from the hardware serial and use the TX pin for my other use (the external serial connector). Thanks.

earnestblimp
 
Posts: 19
Joined: Thu Sep 17, 2009 10:42 am

Re: Sharing a microcontroller pin via a transistor

by adafruit on Wed Jun 23, 2010 3:53 pm

the mega has more than one UART, no?

adafruit
 
Posts: 12151
Joined: Thu Apr 06, 2006 4:21 pm
Location: nyc

Re: Sharing a microcontroller pin via a transistor

by earnestblimp on Wed Jun 23, 2010 7:20 pm

the mega has more than one UART, no?


Yes, but I'm using all four unfortunately.

earnestblimp
 
Posts: 19
Joined: Thu Sep 17, 2009 10:42 am

Re: Sharing a microcontroller pin via a transistor

by oPossum on Wed Jun 23, 2010 9:16 pm

74HC4053, 74HC4052 and 74HC4051 can be used for logic level serial switching. They are 4066 type switches with a 1, 2 or 3 bit binary decoder.

Data Sheet
I am the Possum, and I approve of this message. Sent from MacBook Wheel Sorry for my bad German.
oPossum
 
Posts: 636
Joined: Fri Oct 26, 2007 12:42 am
Location: Michigan, USA

Re: Sharing a microcontroller pin via a transistor

by earnestblimp on Thu Jun 24, 2010 8:17 pm

74HC4053, 74HC4052 and 74HC4051 can be used for logic level serial switching. They are 4066 type switches with a 1, 2 or 3 bit binary decoder.

Thanks for the information! So, is there any reason to prefer one of these to the 4066 itself?

earnestblimp
 
Posts: 19
Joined: Thu Sep 17, 2009 10:42 am

Re: Sharing a microcontroller pin via a transistor

by zener on Thu Jul 01, 2010 5:00 pm

I am guessing the 4066 has a separate enable for each switch. So you would need two I/O lines for that, or an inverter. The other parts you would just need one I/O line and no inverter.

zener
 
Posts: 4567
Joined: Sat Feb 21, 2009 2:38 am

Please be positive and constructive with your questions and comments.