Maker Pro
Maker Pro

Using a transistor as a relay

CocaCola

Apr 7, 2012
3,635
Joined
Apr 7, 2012
Messages
3,635
In theory then the same design should work, make sure to bond all the grounds common between devices...
 

StealthRT

Sep 4, 2010
146
Joined
Sep 4, 2010
Messages
146
Well i tested this out and i'm not sure about the setup values.

At both times i get 0v when the 5v port is on (HIGH) or when its off (LOW) using a 330ohm resistor.

At this point it would seem it would turn on the pc even in the off (low) state?

Any ideas?
 

CocaCola

Apr 7, 2012
3,635
Joined
Apr 7, 2012
Messages
3,635
Its just as the image i posted shows.

If it isn't working, then it differs from what was shown...

4600d1339556469-using-transistor-relay-npn.jpg


You either have made a mistake in hooking it up or laying it out...
 

CocaCola

Apr 7, 2012
3,635
Joined
Apr 7, 2012
Messages
3,635
Without getting into all the details, it appears the transistor is in backwards...

0639301452-0.gif
 

StealthRT

Sep 4, 2010
146
Joined
Sep 4, 2010
Messages
146
Its a radioshack brand... Its labeled With the FLAT end down...

Code:
 ----
(____)
3 2 1

Which is
1 = emitter
2 = base
3 = collector

So in the previous pic it was

1 = arduino gnd
2 = digital output > 330 ohm
3 = out to switch
 

CocaCola

Apr 7, 2012
3,635
Joined
Apr 7, 2012
Messages
3,635
Rat Shack is notorious for having improper labeling on their packages as they source new suppliers of the components and/or switch up to a new 'compatible' parts with no regard for any differences... Been there and seen it personally several times over the years, they really have become a joke...

Go down to the Sept 9, review here: http://www.radioshack.com/product/index.jsp?productId=2062586

And go down to the second review here: http://www.buzzillions.com/reviews/radio-shack-mps2222a-transistor-reviews

See a trend ;)

So personally I would ignore their packaging and go with the common pin out if it is indeed a 2n2222...
 

Rleo6965

Jan 22, 2012
585
Joined
Jan 22, 2012
Messages
585
@stealthRT
Its better to to see the manufacturer datasheet.

Always verify all continuity of your component on a solderless breadboard. Most of the time there's a loose connection and resulting intermittent problem.

Once powered on. Test all voltage on important test point to identify abnormal voltage that cause circuit malfunction.
 

StealthRT

Sep 4, 2010
146
Joined
Sep 4, 2010
Messages
146
i get 0v when off and 0.01v when on...... That wont work since it would turn on the motherboard when the arduino is off or on...
 

CocaCola

Apr 7, 2012
3,635
Joined
Apr 7, 2012
Messages
3,635
Disconnect the 'pc' wires so it's no longer part of the circuit, take a volt meter, positive lead to +3 (or 5) that you are running the Ardunio from... Take the negative lead and connect it to the Collector of the transistor...

Now toggle the Base of the transistor high/low with the Arduino and confirm the volt meter jumps from 0 to +3...

If not take the positive lead of the volt meter and attach it to the Base of the transistor, and the negative lead to ground... Now toggle the base high/low with the Arduino to confirm the base is in fact getting toggled...
 

StealthRT

Sep 4, 2010
146
Joined
Sep 4, 2010
Messages
146
OK im going to switch gears here. I got a 5v relay that i will now be using.

I hooked it up and it triggers the relay closed when the digital output is high. And i have it feeding a gnd to the middle and the output pin on the relay is reading 0v. However when i hook that end up to one side of the switch and the other side to the arduino gnd it does not trigger the motherboard on once the relay is closed.

relay2.jpg
 

CocaCola

Apr 7, 2012
3,635
Joined
Apr 7, 2012
Messages
3,635
If you are using a relay, no need to bind the grounds, just make the outputs of the relay common to the switch... In other words take one side of the switch and connect it to one of the relay outputs, and connect the other side of the switch to the other relay output...
 

StealthRT

Sep 4, 2010
146
Joined
Sep 4, 2010
Messages
146
If you are using a relay, no need to bind the grounds, just make the outputs of the relay common to the switch... In other words take one side of the switch and connect it to one of the relay outputs, and connect the other side of the switch to the other relay output...

Care to draw that out?
 
Top