Controlling 2 relays with one arduino pin

Hey guys, so my project has gotten to a point where I have used up all but one of my arduino pins. Problem is, I want to control two relays (via transistors ofc) with that single pin. Is there a way to bias the transistors so one turns on at 2.5v (and off when its > 2.5v) and the other turns on at 5v?

thanks for your help guys.

Might have answered my own question here while messing around in easyeda, but for future reference, see attachment. Still have to run it through an emulator, though logically everything makes sense.

swagguy8:
Hey guys, so my project has gotten to a point where I have used up all but one of my arduino pins.

Including the analogue pins?

Analogue pins are just digital pins with the added functionality of analogue-in.

Can use pinMode(A0, OUTPUT); in setup().
And digitalWrite(A0, LOW); in loop().
Can also use pin number 14-19 for A0-A5 (assuming Uno).
Leo..

Wawa:
Including the analogue pins?

Analogue pins are just digital pins with the added functionality of analogue-in.

Can use pinMode(A0, OUTPUT); in setup().
And digitalWrite(A0, LOW); in loop().
Can also use pin number 14-19 for A0-A5 (assuming Uno).
Leo..

Yeah unfortunately. I went the google route first before I'd ask on here :slight_smile: I have used up all the pins to the point where I'm implementing the above on a attiny13 "daughter board", I said these are going into an arduino to avoid detracting from the topic.

OK I have put it in circuitmod, and it seems to have worked after I adjusted the sensitivity settings on the base voltage divider. The ON voltage of the npn transistors in circuitmod seem to be @ 0.6ishV, I expected 0.5V. This with a bit of modification should in theory be able to easily scale up to multiple channels.

circuitmod.gif

godamn, I'm hijacking my own thread. I have attached a motor control circuit below, allowing a motor to be driven in forward/reverse, only using 1 pin. I have ditched the s9014 for some more beefy s8050.

Not sure what you're trying to do.
Are you expecting a variable voltage from a digital pin?
Digital pins (inclding PWM pins) are only 0volt or 5volt (assuming VCC is 5volt), nothing in between.
Your DMM might show 2.5volt with a PWM value of 128, but that's because it's too slow to react.
Leo..

I think that he wants somethink like
If pin is LOW relai 1 is HIGH
if pin is HIGH relai 2 is HIGH

Bit everyway are youbsure that you can use alla pins of Arduino? I remember that it has some straight limitatiin about corrent, and that limitation is less than all pins HIGH

Wawa:
Not sure what you're trying to do.
Are you expecting a variable voltage from a digital pin?
Digital pins (inclding PWM pins) are only 0volt or 5volt (assuming VCC is 5volt), nothing in between.
Your DMM might show 2.5volt with a PWM value of 128, but that's because it's too slow to react.
Leo..

might have to use a capacitor to smooth it out, but otherwise it should be fine. transistors have a bit of internal capacitance themselves as well.

smoothing:

swagguy8:
Hey guys, so my project has gotten to a point where I have used up all but one of my Arduino pins.

OK, so here's the problem. It's called the "XY problem". You have made a design piecemeal, found an unplanned-for problem and looking for a patch-up solution.

You need to review the overall design, and unless you give us a description of what you have done so far with an explanation of to which purpose you have put each pin, please do not expect us to offer a simple and reliable solution.

6672291df63fc2a6d9bfe57d4fec12b9de6623d3.png

3beca8ed4f5195ddbddfffbc8c8c4d173894a7bd.png

OK, so the first circuit is distinctly flaky, the second is complete nonsense.

Tell us the whole story and we may be able to help.

Paul__B:
OK, so here's the problem. It's called the "XY problem". You have made a design piecemeal, found an unplanned-for problem and looking for a patch-up solution.

You need to review the overall design, and unless you give us a description of what you have done so far with an explanation of to which purpose you have put each pin, please do not expect us to offer a simple and reliable solution.

6672291df63fc2a6d9bfe57d4fec12b9de6623d3.png

3beca8ed4f5195ddbddfffbc8c8c4d173894a7bd.png

OK, so the first circuit is distinctly flaky, the second is complete nonsense.

Tell us the whole story and we may be able to help.

What I'm trying to do here is control two relays/states with a single arduino pin. The relays/states are to be on one at a time, not both. What my circuit does is through biasing transistors at their cutoff/ON region, I am able to create simple logic gates that are controlled by different voltages. (referring to 1st schematic) If I were to put 2.5v at "pin", top transistor(Q1) will get around 600mv of base voltage, enough to turn ON, triggering the top relay, yet the bottom transistors (Q2 and Q3) will stay off as the voltage divider would only give them around 300mv. When it is at 5v, Q2 and Q3 will both turn ON, Q3 will turn on the bottom relay, and Q2 will short out the base of Q1, therefore turning off the top relay. Please refer to post #4 where I have posted a gif of the circuit working in the simulator. The second circuit just replaces Q1 and Q3 with a simple reversible motor driver circuit, normally requiring 2 pins to drive (one for forward and another for reverse) yet my circuit allows it to be driven with one pwm pin.

Please read through what people post before you start criticizing. Although I am new to the forum, I am no newbie to electronics. I am just seeing if anyone had a better way to do this. I explained what I was trying to do in post #1:
"Problem is, I want to control two relays (via transistors ofc) with that single pin. Is there a way to bias the transistors so one turns on at 2.5v (and off when its > 2.5v) and the other turns on at 5v?"

Now design a circuit that turns both relays off when the Arduino pin is set to input (floating/mid-voltage),
and one relay on when the pin is output/LOW, and the other relay on whe the pin is output/HIGH.
Then you can use any pin. Not just a PWM pin.
Leo..