Using Transistors as switches for 9V relays

Hi guys,

I am pretty new to arduino and I seem to be running into a probably very simple problem. I am using the exact circuit diagram as shown here, which is a basic relay circuit:

but with a 9V relay instead of a 5V relay and the transistor is switching a 12V supply (12V, 500ma wall wart) running from the Vin of the arduino.

I had already made a prototype that worked, using a P2N2222A transistor. I am trying to replicate this, and I noticed that when I used a transistor labelled 2N2222-331 instead of the P2N2222A, the relay would switch on even if the base pin was not connected. I thought this may have been due to a faulty transistor, but all of the 2N2222-331 transistors I have do the same thing (bought from 2 different sources). The datasheets of these two transistors are basically identical, so I don't understand what is going on. Does anybody know what is going on?

Thanks,

Rodger

Do they physically look the same?
What are all the numbers written on them?
Show a link where you bought them.

Larry,

They do physically look the same. The working one is labelled "P2N2222A-B20" and the one that is leaking is labelled "2N2222-331". The P2N2222A-B20 was obtained from an Arduino Starter Kit (link below):

The 2N2222-331 was obtained from the link below:

Hope this helps,

Rodger

If you have a multimeter check to see if they measure the same.
See:

It's very common to find the emitter and base are swapped on some transistors. It all depends on the manufacturer's whims. If you can sacrifice one try it with the outside legs reversed. Or, do a search on how to determine which legs are emitter and collector.

There are cheapo, $4 meters nowadays, (Harbor Freight) that will have a transistor checker built in. (Actually designed to measure gain, but will show you if you have the polarity correct.)

whats a relay exactly?

Google what is a relay

but im in the forum now. why go to a whole new page to figure it out when i have what seems to be a thread full of arduino masters.

plus im still downloading the pdf in the first post. slow internet. i will google it after it finishes. thanks for killing the pip in my step. im sure it wasnt on purpose.

The point is, if there is already an answer out there (and videos) it is best to not repeat ourselves.
Your question was too vague, it's best narrow your questions down.

i didnt know how to narrow it down. so based of your answer i suspect different kinds of relays.

so the real answer would be
"hey Doopa! glad you have the same interest as me! we could be friends! anywho, there are various forms of relays and couldnt possibly teach you everything in one session. but to help you out i would advise using a search engine or some videos. some videos i recomend looking at are (insert noun). if you have questions after doing so i would be happy to help!"

Thanks!!