How to emulate a push button using an Arduino Uno without transistor or relay?

Hi, first of all, I'm completely new to Arduino and Electronics, so please dumb any replies down to an understandable level.

I have a small DC fan that works with a 18650 battery, and has a push button switch to turn it on or off. (this means pressing it once will turn it either on or off, not a mechanical switch that stays in two physical positions when on and off)

I want to take the two wires from this push button switch, and use an Arduino Uno to flip it. The ideal way would be to connect those wires to some 2 inputs of the Arduino Uno, and run some code that can make a momentary connection (perhaps for 50ms and break) between the two inputs. Kind of like the current momentarily flowing through the Arduino instead of the push button.

I repeat the word MOMENTARILY. The current doesn't have to flow continuously. (Similar to taking a jumper from one input and just touching it on the other input.)

The voltage between the two terminals is very low at about 3.6V. Momentary current as far as I can find from my multi-meter is less than 20mA (very short pulse). The fan DOES NOT run using the current through the switch. It's just a push button somehow integrated to it. Therefore, I think Arduino Uno wouldn't be damaged in anyway from letting the said current run through it instead of the push button.

So Is there a way to do this? I searched online and found some ways to flip a switch using a relay or a transistor and a resistor, providing the input from one Arduino Uno output. Is that the only way to do this? Isn't there a code to temporarily connect some two inputs and let a current flow through them momentarily, without using external components?

Thank you in advance. Sorry if my English is bad. :blush:

[quote="indrajithgamage, post:1, topic:904393"]
I want to take the two wires from this push button switch, and use an Arduino Uno to flip it.
[/quote]strong text

That's typically done by use of an optocoupler.

1 Like

Is one of the two wires to the fan switch also (internally) connected directly to one of the poles of the 18650 battery ?

or a reed relay

IMO
The FAN probably has a controller that controls the momentary switch, and the button switch is I thought to be just a tact switch with pulled-up.
If the Arduino shares GND with the FAN, why not just pull the pin connected to the switch to GND?

For the sake of clarity, I think it's a good idea to upload a photo of the disassembled FAN.

"SWITCH" is both a category and a specific term.

In the hobby world, most people think of a 'switch' as a device that changes state from off to on or on to off.
In one state, it would pass power, in the other state, it would open the circuit.

A button, is a momentary switch. it passes power only when pressed. as soon as it is released, it stops passing power.

A momentary switch is just that. momentary.

There are two states. Normally Open and Normally Closed.

A normally closed, momentary switch or button will pass power until it is activated.
then it breaks power until released and it goes back to passing power.

What you described is that you have a normally open button and want a normally closed signal.

The concern is that you said battery. a simple LED will drain a fully charged 18650 in short order.
A normally closed circuit might drain the battery quickly.

The simplest way to get what you want is a normally closed button.
The next is to use a transistor. They are really easy to use. And with the low power, pretty much any one you have would work.
An Opto is just a transistor in a package, but it would also be very easy to use and again, almost any you have could work.relased

I would not suggest a relay as it sucks/uses power and for a low power signal is overkill.
If you get a micro-relay they are expensive.

a reed-relay (see post#4) does not consume power as it works with magnets. Very clever idea.
that might be as simple as you get.

but, you asked is an Arduino could be used.
the answer is YES.
it is very easy (beginner) to take a signal in and send a signal out.
you could send in a 0 volt signal and output a 5V signal

And just what is your objection to using a transistor?

Connect Arduino GND to the negative side of the button and a pin to the positive. OUTPUT LOW is button pressed while INPUT is not pressed.

Long reply, but what the heck are you talking about?? A simple LED uses something like 50mW right? 18650 battery has around 10Wh of capacity, so simple maths says it can run the LED continuously for 200 hours. So your "short order" is like 8 DAYS?? Okay! :rofl: :rofl:

Your long explanation about normal open and normal closed are unhelpful too. If you can read my post again, this is just a momentary switch. I think powering the Arduino will take much more power than that.

All I asked is, IS IT POSSIBLE TO CONNECT AND DISCONNECT SOME TWO TERMINALS OF AN ARDUINO UNO WITH A CODE. If that's not possible, Please say so.

Nobody seems to be able to explain how to calculate the correct base resistor value.

Fan is not disassembled, and it's not that relevant. I just want to take the two wires and connect/disconnect them with a code. That's all. Just emulate touching the two wires in a Microcontroller way. Is this so hard for people to understand? :sleepy: :sleepy: :sleepy:

How?

Did you see reply #2?
It's a very simple and correct approach to your problem.
Use the Arduino pin to turn on an optoisolator for a pulse and it ill make the connection in place of the switch. This also protects the Arduino.

Well, if powered by an 18650 lithium battery, that is exactly what you expect. :grin:

What do you mean by "very short pulse". You measure by connecting the meter on "current" range, across the button terminals and reading the value. Is it not stable?

You didn't ask!

If the current in the switched circuit was 20 mA, you would want to drive it with about 1 mA, so a UNO at 5V, less the base voltage; 4k7.

Even better, use a 2N7000 logic-level FET with a 47k pull-down on the base to stabilise it until and unless the UNO code is running.

The reason for using a transistor/ FET, is isolation when one part may be powered and the other not. If the fan has no other connections to a power supply or anything else, but is battery powered (or even powered by a double-insulated "plug pack") you do not need an opto-isolator but you could use one. An opto-isolator would not be quite so practical if your switch current was 20 mA or more as you would need the CTR to be guaranteed to exceed 1.0 - 100%. :roll_eyes:

so the simple explanation so we have a common ground to discuss your needs as you asked for in your first line of your first post was not what you really wanted ?

the answer to your most recent question of it if can be done, is NO

to put a price tag on it.
resistor and transistor 10 cents USD
opto and resistor 25 cents USD
Arduino, power supply $25 dollars USD
clone Arduino and power supply $8 dollars USD ????

if you have a power supply on one wire and want to connect THAT wire to a second wire, you CANNOT do that with the micro-controller.
you CAN use a microcontroller to turn on a relay to connect two wires
you CAN use a microcontroller to control a transistor to allow the power from one power supply on a wire to the thing that gets that power.

the microcontroller cannot connect two wires like a switch.

The very first examples of how to light an LED explain this is detail, with code.

using the example that is part of the IDE is much better than us trying to tell you how to do it.

Again: this in NOT how it should be done. It can even lead to a big bang:

You should switch by pinMode(INPUT) and pinMode(OUTPUT).
IIRC LED example uses digitalWrite HIGH/LOW.
Now imagine the switch is implemented as a bare MCU pin with pull-up to battery positive. When you write Arduino pin OUTPUT HIGH it will try to apply 5 V on the pin. If the pin is not 5V tolerant its protection diode will clip the voltage by recharging the battery. This is surely unexpected for the manufacturer and so it may bypass the battery overcharge protection. BANG!

Ergo my careful explanation in #14.

To help you, it would be good to know the existing circuit of the fan. In #5 you have been asked to show a picture of the disassambled fan. I can only repeat that request. And please add a drawing if the picture is not clear enough.
You mentioned that the switch produces only a short puls. I assume that this happens also if the switch is pressed for some seconds. I am curious how this is done. Is there some electronics at the switch? The small fans I know dont have electronics. They consist of the the fan itself, the battery and a switch. The switch often looks like a push button, because the push button mechanically controls the switch. You find this type of switch often at flashlights.
The arduino needs a power supply. Do you plan to use a separate supply and still have the battery for the fan?

Post 11

It appears to me that the OP is specific about not discussing the fan.

And is not interested in discussing how to make a workable cicuit.