Arduino Output Pin to Switch a Transistor

Thread Starter

CoachKalk

Joined Sep 20, 2011
141
Hello again! I have not visited here for quite some time. This forum was incredible with the help I was given to get my laser maze up and running.

Now, several years down the road, I am on to another project. I have built a DIY motion simulator for driving games and a roller coaster game.

The software I use to drive my motors also has the ability to output "virtual" speed to an Arduino. I have included a drawing of a basic transistor circuit that I copied from this site. The transistor switches like expected when I close the switch.

My question is, can I use an output pin from an Arduino UNO instead of the switch? The ultimate goal is to use PWM to vary fan speed based on ride speed.

Thank you in advance for any help.
Steve
 

GopherT

Joined Nov 23, 2012
8,009
Yes, just remove the 10k transistor and switch from your circuit. Add a 4.7k transistor from your output pin on Arduino to the base of the transistor. If you are not getting enough current to the fan, you can boost the current from the Arduino to the transistor by using a smaller resistor to the base (down to 220 ohm should be ok).
 

wayneh

Joined Sep 9, 2010
17,498
And in case it isn't clear, the Arduino and the fan need to share the same ground, so that the Arduino signal causes the transistor base voltage to rise above that ground.
 

Thread Starter

CoachKalk

Joined Sep 20, 2011
141
Thank you both! I am currently just powering my Arduino via the USB connection and am using a separate 12v power supply for my fan. I thought I read that the PWM pins have a 5v max. Should a use a jumper from the prototype board ground to the Arduino ground?

Thanks
 

Thread Starter

CoachKalk

Joined Sep 20, 2011
141
I am currently just using an extra PC cooling fan 12v .13A in order to figure everything out. I have a bigger 12v 2.5A fan that I hope to use to really add some fun to the roller coaster ride. Hopefully my current transistor can be used for both the debugging and the final fan.

While running the game, I can see the RX led blinking which I assume means the game is sending data. At this time, the fan just stares back at me ...

I will take another look at my simulation software settings as well as the Arduino code.
 

Thread Starter

CoachKalk

Joined Sep 20, 2011
141
Ok, I made a change to my simulation software and the fan spins! The problem is the fan now spins whether I have the game running or not. As soon as I plug the USB into the computer, the fan starts.

Do I need to change the resistor value or is it likely an issue with my output pin not ever be "off"?
 

GopherT

Joined Nov 23, 2012
8,009
Draw out how you connected the circuit. It could be that the arduino output pin is never turning off. Measure the voltage at the transistor base, and let us know what that is as well.
 

wayneh

Joined Sep 9, 2010
17,498
The transistor and the fan will turn on if/when that transistor sees >~0.6V on the base pin, compared to the emitter pin. You can check that with a meter and maybe track down where the ∆V is coming from.

Be careful with "ground". Depending how these things are powered, and particularly if there are two mains-powered supplies involved, the ground of one may not be at the same voltage as another, and current can flow from one to another when you connect them. A schematic, diagram or photo might help folks see the problem for you.
 

Thread Starter

CoachKalk

Joined Sep 20, 2011
141
I have included a pic of my circuit below. I checked again and my first description of the condition was not accurate.

When I plug the USB into the computer, the fan stays off. As soon as I start the game, the fan starts turning, but does not change speeds per the game. After I exit the game, the fan continues to turn until I unplug the USB. When plugged back in, it again stays off until I open the game.

Let me know if you have questions about the pic.

Thanks again for your help.
 

MrChips

Joined Oct 2, 2009
30,824
What is the part number on your transistor?
There are different lead identifications for 2N2222. Try turning the transistor around.
 
Top