Tri State Switch

Hi All, Need some suggestions on how to do this,

Using one pin set to input, then set to output pulsed LOW pulse relay 1, when pulsed HIGH then pulse relay 2.

I dont have to use relays a Darlington transistor array would do, the current for switching the device's is 1 amp at 12v .


Connect pin to NPN and PNP transistor drivers or N/P channel MOS FETs

Assuming relays are 5v coils.

NPN needs + at base to turn on.
PNP needs gnd on base to turn on.
Hi Z both transistors turn off.


Thank you so much, I should have thought of that, sometimes you just need a push, will be using this. IRF7509TRPBF - Dual MOSFET, N and P Channel

A logic level version might be a better choice.

Hi all, I have been doing some study on Mosfets, but still cant figure out the circuit, digital Mosfets look like the go but I am open to suggestions, keeping in mind that I need this to be as cheap as possible, with the fewest amount of components, and that one pin to control 2 switches, one pulsed HIGH and 1 Pulsed LOW.

And yes I have already written the software so to change things would take more time.

Logic level mosfets would be good, and an n-ch and p-ch on the same I/O pin is fine. They are actually just opposites of each other as far as hooking them up (source/drain).

What could have a bearing on the simplicity is what you are trying to control. What voltages? Post a picture of whatever circuit you have in mind and others can give better tips

Morbid: Using one pin set to input, then set to output pulsed LOW pulse relay 1, when pulsed HIGH then pulse relay 2.

Sounds like you don't have enough pins available. Do you know you can use the analogue pins as normal digital pins. digitalWrite(A0, HIGH); or digitalWrite(14, HIGH); on an Uno Leo..

Hi again,
So to elaborate further on my project, It is for my sisters model trains, I am using a UNO to control the switch points, thanks for the tip on using the analog pins but yes I am already doing that, the number of points the UNO is switching is 7, here is what the pins are being used for.

Pins 2 to 8 are used to switch the points as a pulsed output, pulse HIGH to switch one way and pulsed LOW to switch the other way.

Pin 9 is used for a button to write the current state of the points to the EEPROM, so when the power turn’s back on the preferred states are set, one led is used to indicate when the config is being saved.

Pins 10,11,12 are used to drive 2 shift registers that control red(7) and green(7) leds indicating which way the points are switched.

Pins 13 to 19 are for the momentary buttons to tell the Arduino which points and leds to change.

Hope this explains things in more depth, attached is a schematic of what I am hoping is correct, any and all advice is most appreciated

IRF540 mosfets are not logic level, and using them with 5volt logic could be unreliable.

I don't see how your diagram could work. The pin is LOW, both in OUTPUT LOW and INPUT state. The p-channel fet is always conducting through the body diode. Turning that one the right way round (source to batt+) will have other problems.

You are already using shift registers. Why don't you add another one (to the same pins) for the solenoids. Then you only need two logic level n-channel mosfets (and diodes across the solenoids to protect them).

Don't know how much current these solenoids draw. If it's a few hundred milliamps, then you can maybe use a TPIC6x595 shift register. They have buildin mosfets to directly drive the solenoids (no external fets needed). Leo..

Sorry forgot to mention that the solenoids draw 2amp peak @12v, the way I am pulsing is as follows,

This pulses a LOW, swap the "LOW" to a "HIGH" and it will pulse the other way. pinMode(2, OUTPUT); digitalWrite(r2, LOW); delay(15); pinMode(2, INPUT);

The circuit I have is only a thought, I have never had anything to do with FETS, so it is a learning curve for me.

I suggest you get two logic level n-channel mosfets, two 1N4004 diodes, and another 74HC595 shift register to add to the existing chain. Leo..