Go Down

### Topic: Using one circuit to switch another - (basic!) (Read 3002 times)previous topic - next topic

#### mrboni

##### May 17, 2011, 04:05 pm
Hi. Here's a noob question for you

I have one circuit with a power source (batteries) powering an led, controlled by a switch.

I want this same switch (single pole) to also set an arduino pin HIGH when it is pressed.

Can I use a transistor? From what I've been reading here - http://www.ermicro.com/blog/?p=423 I should be able to use something like a 2n3904 transistor to switch the arduino pin high when there is a current in the other circuit, but I cant work it out.

Am I going about this the right way?  And do both circuits need to be powered from the same power source for this to work?

Thanks

#### cmiyc

#1
##### May 17, 2011, 04:11 pm
An Arduino pin set as an INPUT is a high impedance input.  So you do not need to "switch" it on.  What is the high voltage of the switch that turns on the LED?  If it is 5V you can just connect the Arduino INPUT pin to the same point as the high-side of your switch.

Quote
And do both circuits need to be powered from the same power source for this to work?

Voltages are based on references, so all components which are connected to each other much share the same reference.  In this case, it means the GROUND of each "circuit" should be connected together.

GROUND is another way of saying "reference plane."
Capacitor Expert By Day, Enginerd by night.  ||  Personal Blog: www.baldengineer.com  || Electronics Tutorials for Beginners:  www.addohms.com

#### graynomad

#2
##### May 17, 2011, 04:14 pmLast Edit: May 17, 2011, 04:17 pm by Graynomad Reason: 1
You have to share GNDs between the two systems. If the current circuit has a voltage approx 4.5-5v (say 3 AA cells) you could feed the signal that powers the LED directly into an Arduino pin.

If it's a higher voltage (or a lot lower) a transistor would work, using a diagram from that link

you would run a wire from where it says "non-inductive load" to the Arduino input, and "Microcontroller IO port" is your LED circuit. The signal will be inverted so if you read a LOW the button is pressed.

Quote
And do both circuits need to be powered from the same power source for this to work?

No, just share GND.
______
Rob
Rob Gray aka the GRAYnomad www.robgray.com

#### mrboni

#3
##### May 17, 2011, 04:20 pm
Thanks, I'll have a play and get back to you

#### mrboni

#4
##### May 17, 2011, 04:25 pm
The voltage is 5.9v  Will this be too much for the arduino pin?

#### graynomad

#5
##### May 17, 2011, 05:01 pm
Quote
The voltage is 5.9v

Then another (simpler) option is to step it down with a voltage divider.

______
Rob
Rob Gray aka the GRAYnomad www.robgray.com

#6
Yes that worked.

Thanks!

Go Up