I just got my Arduino for Christmas and have been fiddling with it feverishly. I am trying to learn all the basics before venturing on to a large project but the one thing that is bugging the heck out of me is I can't figure out how to make it close a circuit. I just want it to "connect two wires" basically. I've read on the forums about relays and transistors but they all seem to imply passing voltage off some sort. I just want continuity when an event happens. Did I make any sense? I'm a noob btw.
they all seem to imply passing voltage off some sort
Not really sure what you mean there.
I think Relays/Transistors are the way to go. You could get away with just using transistors if it's a small current / voltage (and I think DC Only), but if it's something larger (such as 120V AC, which is standard for things you plug into a wall outlet if you're in the USA), you should probably use a relay. Commonly, you will have to power the relay through a transistor, but it's not as complicated as it sounds.
If you get a bit more specific about what you're trying to achieve, we could help more :).
I'll try to be a little more specific. I am looking to have a PIR sensor close a circuit on a hacked keyboard so it types a letter. The PIR sensor sends 1.85v DC when it is triggered from what I read on my multimeter. Could you provide me with which model of transistor would work? I was thinking about using a 2n2222 transistor, but am not sure if that's what I need. I'm not sure what current is being passed in the project either. I guess I could use Ohm's law to figure that out? I also want to use this same project to snap a picture with a 35mm camera instead of typing a key. Does that make it clearer or foggier lol.
Which PIR sensor are you using and how is it wired when you connect it to the meter?
I haven't hooked it up to the board yet, ive used this tutorial to work with it before I got the board. The 1.85v is coming from the output pin.
So you have the Adafruit sensor?
I bought it from Radio Shack it seems to be the same. Here is the datasheet:
Both Radio Shack and Adafruit reference the Parallax datasheet so it's safe to assume they're all very similar.
This is how I got the Parallax module to work...
- Connect Vdd to +5V
- Connect Vss to GND
- Connect OUT to one of the Arduino pins
- Configure the Arduino pin as an input
- Use digitalRead to read the PIR output. If digitalRead returns TRUE, motion is detected.
Bear in mind that PIR sensors have a warm-up time. You may be reading a "strange" output voltage because the PIR is warming-up.
Thank you for the explanation of the sensor. I understand all of that but what I don't understand is how I can take that input and close a circuit.
ok, lets go back to the top
what is the voltage and amperage of the load your going to be switching on and off?
you need to know that so you can choose the correct part, if its low voltage and amperage (~ <500ma) your 2222 nPn transistor should do fine
If it is mains (120-240vac) and switching a 4 amp motor then were in a whole new world, but the basic's of operation are the same
arduino (or even the sensor in this case) toggles a ping "high", that voltage (after passing tru current limiting / safety stuff) connects to a switching device, which could be
Transistor
FET (big transistor)
Relay
or SSR (solid state relay, which is not really a relay)
which opens and closes the switch for the other circuit
I understand all of that but what I don't understand is how I can take that input and close a circuit.
Your software program would read that input and using a digital output pin perform a digitalWrite command turning a output pin on or HIGH (+5vdc). This digital output voltage then needs to wire to external components (resistor/transistor) that would then drive a simple relay, and the relay's two contact output pins would close (conduct) completing your external circuit.
Lefty
I hope I'm not asking too much, but I don't know how to "wire to external components (resistor/transistor) that would then drive a simple relay, and the relay's two contact output pins would close (conduct) completing your external circuit."
This help?
Lefty
What is the transistors role? Why can't I just use a relay?
relays use more current than the arduino can directly handle
the arduino switches the transistor, which can handle a different, maybe higher voltage and current, the transistor then switches the relay
Ah, thanks for the explinatipn, I appreciate it. Keep in mind that I'm not relaying any voltage or current. Just closing a circuit. Would I still need a transistor. I know I won't need a diode.
if there is electricity in the circuit then voltages and amperage are flowing, your selection of device depends on what that is
if your just trying to hack a keyboard, use a transistor
Keep in mind that I'm not relaying any voltage or current. Just closing a circuit.
If there wasn't any electricity flowing through it, then what would be the point of closing the circuit?
If it's a keyboard, then when you press a key, it completes a connection and current flows through. I assume you are trying to bypass this through the Arduino to simulate keypresses?
[edit]Doh. Didn't see your post Osgeld :P. This is essentially a repeat of it..Ah well ;D[/edit]
Thanks for being so patient with me, I'm learning alot. I'm going to try to just use a transistor first. I've measured the voltage across the two terminals on the keyboard I want to connect and am only seeing 0.01 volts. Would a 2n2222 transistor be ideal since I will be sending 5v to it's base. Do I need to implement any other component to protect the arduino? The way that I think I should hook it up is to have the arduino's 5v power going to the transistor's base, have terminal 1 go to the emitter and terminal 2 go to the collector.
A resistor between the arduino pin and the base of the transistor.